Skip to content

yjlo123/vee-lang

Repository files navigation

Vee lang

The Vee programming language

Playground

Usage

  • <input_file>
  • -t Print tokens
  • -a Print AST
  • -e Evaluate AST
  • -c <output_runtime_script_file> Compile to Runtime Script

Example:

python3 main.py sample.vee -e -c out.runtime

AST

Node Definition

Node = Object{
    type: NodeType
    token: Object{
        value: string
        type: TokenType
        line: integer
        column: integer
    }
    children: Node[]
}

Node Types

Node Name Meaning
IMPORT import statement
EXPR_LIST expression list
STMT_LIST statement list
OPERATOR operator
IDENT identifier
VALUE value
FUNC_CALL function call
FUNC_DEF function definition
ARG_LIST argument list
FOR for loop
WHILE while loop
IF if expression
RETURN return statement
CLASS class definition

Token Types

TypeType = Enum{
    KEY: keyword
    IDN: identifier
    NUM: number
    STR: string
    NEL: newline
    SYM: symbol
    EOF: end of file
}

Examples

Operator

Node{
    type: OPERATOR
    token: Token{
        value: '+'
        type: SYM
    }
    children: [
        Node{<operand>},
        Node{<operand>}
    ]
}

Identifier

Node{
    type: IDENT
    token: Token{
        value: 'my_var'
        type: IDN
    }
    children: []
}

Value

Node{
    type: VALUE
    token: Token{
        value: 24
        type: NUM
    }
    children: []
}

About

The Vee programming language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published