Skip to content
/ ast Public

Defines the central Abstract Syntax Tree (AST) used for analysis, transformation, and code generation.

License

Notifications You must be signed in to change notification settings

je-es/ast

Repository files navigation


ast

The definitive Abstract Syntax Tree (AST).
Serves as the central data structure for parsing, analysis, transformation, and code generation.

line
  • Install

    npm install @je-es/ast
    import * as AST from "@je-es/ast";

    line
  • Usage

    // suppose we want to represent an abstract syntax tree for this statement:
    pub let mut x: i32 = 42
    const my_let_stmt = AST.StmtNode.asLet(
        // span
        { start: 0, end: 23 },
    
        // Public/Static/Private
        {
            kind: 'Public',
            span: { start: 0, end: 3 },
        }
    
        // Comptime/Runtime
        {
            kind: 'Runtime', // default
            // span: undefined,
        }
    
        // Mutable/Immutable
        {
            kind: 'Mutable',
            span: { start: 8, end: 11 },
        }
    
        // ident
        AST.IdentNode.create({ start: 12, end: 13 }, 'x'),
    
        // type
        AST.TypeNode.asSigned({ start: 15, end: 18 }, 'i32'),
    
        // init
        AST.ExprNode.asInteger({ start: 21, end: 23 }, 42)
    );

    line
  • Related


line

About

Defines the central Abstract Syntax Tree (AST) used for analysis, transformation, and code generation.

Topics

Resources

License

Stars

Watchers

Forks