KittyCAD / kcl-experiments

KittyCAD Language
9 stars 0 forks source link

KCL parser #9

Closed adamchalmers closed 1 year ago

adamchalmers commented 1 year ago

We can parse function declaration, invocation, and let-in! E.g.

bigCircle = (center: Point2D -> Solid2D) =>
    let
        radius = 14
    in circle(radius, center)

Here's an example of the CLI functionality.

Screenshot 2023-07-25 at 11 19 40 PM

Compilation errors give you a stack trace of the parser, showing what it's trying to parse and where.

Screenshot 2023-07-25 at 11 21 31 PM
Irev-Dev commented 1 year ago

The AST just being Vec<FnDef>; is very interesting.

I definitely got a bit lost in the parsing, so you're not tokenising first, going straight from string to AST?

adamchalmers commented 1 year ago

Yeah this is tokenization and parsing in one step. AST will eventually have other things like a main function, comments, imports.