lambdaclass / concrete

Concrete is a simple programming language specifically crafted for creating highly scalable systems that are reliable, efficient, and easy to maintain.
Apache License 2.0
123 stars 11 forks source link

Parser work #61

Closed edg-l closed 8 months ago

edg-l commented 8 months ago

Depends on #60 because it changes 1 thing there.

With this, we can parse the following program

mod ModuleName {
    import Std.io.{print};

    const MY_CONSTANT: u8 = 2;
    const MY_CONSTANT2: bool = true;
    const MY_CONSTANT3: string = "hello world!";

    pub fn my_func(hello: u64) -> u64 {
        let mut x: u64 = hello / 2;
        x = x + 4;
        x = x - 2;
        x = x % 2;

        match x {
            0 -> return 2,
            1 -> {
                let y: u64 = x * 2;
                return y * 10;
            },
        }

        if x == 2 {
            return 0;
        }

        let lol: u64 = if x == 3 {
            return 4;
        } else {
            return 5;
        };

        print("hello world\nwith newlines and \" escapes ");
        my_func((4 * 2) / 5);

        while x > 0 {
            x = x - 1;
        }

        return x;
    }
}