The Abstract Syntax Tree is the Acorn compiler's intermediate representation of a program or method between its source code form and the compiled byte-code version. It is essentially an s-expression that captures the structured essence of the code. The AST structures closely mirror Acorn's syntactic structures.

Its purpose is to simplify compiler processing by normalizing out the look-ahead complexities found in the more human-readable format, such as: infix operator precedence, syntactic sugar (e.g., '+' for .new), and terms to the left and right of an assignment operator that look the same, but have different meanings. Creation of the AST takes only one pass through the source code and requires almost no state information; the language's syntax guides the reassembly of the lexer's tokens into the AST. Now simplified, only a single recursive descent through the AST is required to generate clean byte-code.

Method
('method', local, parminitstmts, block)
This is always the root node of the AST, for programs and embedded methods alike. local is a list of the method's local variables (with first entry a link to outer method's local variables). closure is a list of the method's closure variables. parminitstmts points to statements that set default values for null value parms. statements is a pointer to the statements node. Implicit returns are managed through this node.
do
('do', locals, exp, block)
Captures a 'do' block. exp may be 'null' or a comma separated list.
This block
('thisblock', this_exp, locals, using_exp, block)
The value of this_exp becomes 'this' within the block of statements. using_exp specifies the method to apply to 'this' on the value(s) returned by every statement in the block.
if
('if', condexp, locals, block, cond2, local2, block2, ..., 'else', elselocal, elseblock)
Captures a full if/elif/else structure. The local/cond/block triples after 'if' are processed together, jumping beyond block if condition fails. A condexp can be 'not','and', 'or', a comparison operator, or an expression (compared to true/false). All but the 'elseblock' jump to the statement after the 'if' structure. A condition of 'else' always evaluates to true.
match
('match', match_exp, using_exp, with1, local1, nexp1, block1, ..., 'else', elselocal, elsenexp, elseblock)
Captures a full match/with structure. match_exp is the value to match against. using_exp is the method used for matching. nexp is the number of expected return values from each match. The local/with/block triples are processed together, jumping beyond block if match fails. 'with' is an expression calculated to a value to match with. All but the 'elseblock' jump to the statement after the 'if' structure. A with of 'else' always matches.
while
('while', locals, condexp, block)
Captures a 'while' structure. If condition fails, it jumps beyond the block (which ends with a jump back to re-evaluate the condition).
each
('each', locals, nexpected, iterator, block)
Captures a 'each' structure. If iterator fails, it jumps beyond the block (which ends with a jump back to re-perform the iterator). locals is the block locals (including 'each' vars). nexpected is how many values to expect back from iterator (usually 2).
break
('break')
Indicates to break from the current inner-most 'while' and continue execution at the first statement following the 'while'.
continue
('continue')
Indicates to jump back to the top of the 'while' block, and reevaluate the condition.
return
('return', expression)
Stop current method and return values to caller. expression can be aNull or a comma separated expression containing multiple values.
yield
('yield', expression)
Suspend current execution context and return values to caller. expression can be aNull or a comma separated expression containing multiple values.
block
(';', stmt1, stmt2, ...)
This holds all statements in a block that have the same level of indentation. A statement node can be another block, a proper statement (e.g., 'if') or an expression with a value. With 'if', 'while', etc. below, a block can point to a ';' statements segment or just a single statement.
not
('not', condexp)
Effectively reverses its condexp and/or status and condition tests
and
('and', cond1, cond2, ..., condn)
Jumps to failure if any listed condition fails
or
('or', cond1, cond2, ..., condn)
Jumps to success if any condition succeeds
Conditional
(condop, value1, value2)
Compares value1 to value2 using condop then jumps around code based on that test. condop can be '===', '~=', '--', '!=', '<', '<=', '>', or '>='
Assignment
('=', lval, rval)
This evaluates rval's value then stores that in lval (using the appropriate 'set' context).
OrAssignment
('||=', lval, rval)
This changes lval to rval if lval is null. lval should be a local.
Closure
('Closure', clovars, newclosure)
clovars is the list of closure variables. newclosure is a 'callprop' used to create a new closure.
Call property
('callprop', self, property, parm1, parm2, ...
If this is an assignment's lval, it is called in 'set' mode, otherwise in 'get' mode.
Active property
('activeprop', self, property)
If this is an assignment's lval, it is called in 'set' mode, otherwise in 'get' mode.
Global variable
('global', symbol-name)
References a global variable, is 'set' if an assignment lval, otherwise is a 'get'.
Local variable
('local', symbol-name)
References a local or closure variable (look up in lexical declared variables to see which). Is 'set' if an assignment lval. Otherwise is a 'get'.
Literal value
('lit', value)
A single literal value (never settable)
this
'this'
Gets the value of 'this' pseudo-variable.
self
'self'
Gets the value of 'self' pseudo-variable.
selfmethod
'selfmethod'
Gets the value of the currently running method or closure
this
'baseurl'
Gets the value of 'baseurl' pseudo-variable.