AST - PatrickDahlin/LuaExe GitHub Wiki

The second step after tokenizing is the AST generation (shorthand for Abstract Syntax Tree). In this step we build a tree out of the input tokenstream, this is also where some syntactical errors can be caught. Some examples of AST output from the compilation:

Example 1:

a = 1

gives output:

ident: "a"
op (binary) =
num: 1

Example 2:

b = (a * 4) - 3

output:

ident: "b"
op (binary) =
    num: 5
    op (binary) *
    ident: "c"
  op (binary) -
  num: 1