Parses a FunctionalScript module and draws its source AST beside the Foundation AST (FAST) it normalizes to. A binding is one node however many places use it; source bindings carry their names, FAST bindings are numbered in definition order. Dashed arrows mark operands that may not be evaluated, and arrows back to a function or loop are the exits that leave it. Expand "As DataJS" under a graph to check it against the exact tree.
Example Overview A failure at run time Parse error Comments Whitespace Non-breaking space Identifiers Non-ASCII identifier String escapes Hex escape Primitives Template literals Objects A repeated object key Shorthand members Named exports An import A named import and a call Sharing: a const used twice Sharing: a repeated expression Variables Variables: a snapshot for a closure Destructuring Destructuring: an elision Operator precedence Arithmetic Logical not typeof Laziness: && || ?? Laziness: ?: Comma: the assertion form Comma: a detached call instanceof in Number conversion Methods and properties Optional chaining Optional chaining: a long chain The entry helper Laziness Function with a rest parameter Closure Recursion Recursion: Ackermann Call statements Early return Throw Loop Loop over a parameter Loop with two variables Loop with a conditional Loop with alternative branches Nested loops Loop with break and continue Loop with return and throw Loop with switch Loop with no state Sequential loops Loop in a guard Module loop Loop between exports Switch Static functions Object.entries
Source const a = 1 + 2 ;
const checked = a .x ;
export default [a , a , a * 3 , a < 4 && a , (...x ) => x , undefined ];
Source AST module [body] → block block [initialize] → initialize block [initialize] → initialize block [yield] → {} initialize [=] → a initialize [value] → + initialize [=] → checked initialize [value] → . {} [default] → [] . [obj] → a [] [0] → a [] [1] → a [] [2] → * [] [3] → && [] [4] → => * [left] → a && [left] → < && [right] → a => [rest] → x => [body] → block < [left] → a block [return] → return return [to] → => (recursive) return [value] → x module body block initialize initialize yield initialize = value initialize = value {} default + left right 1 2 checked . obj key a "x" [] 0 1 2 3 4 5 a a * && => undefined * left right a 3 && left right => length rest body 0 x block < left right a 4 block return a return to value x As DataJS const $0 ={"index" :0 };const $1 ={"kind" :"function" ,"index" :9 };const $2 ={"index" :0 };export default {"imports" :[],"body" :{"statements" :[["initialize" ,{"reads" :[{"source" :null ,"spread" :false }],"ids" :[$0 ]},["+" ,1 ,2 ]],["initialize" ,{"reads" :[{"source" :null ,"spread" :false }],"ids" :[{"index" :0 }]},["." ,["ref" ,$0 ],"x" ]]],"exit" :["yield" ,["object" ,[[":" ,"default" ,["array" ,[["ref" ,$0 ],["ref" ,$0 ],["*" ,["ref" ,$0 ],3 ],["&&" ,["<" ,["ref" ,$0 ],4 ],["ref" ,$0 ]],["function" ,{"target" :$1 ,"length" :0 ,"parameters" :[],"rest" :{"reads" :[{"source" :null ,"spread" :false }],"ids" :[$2 ]},"self" :null ,"body" :{"statements" :[],"exit" :["return" ,$1 ,["ref" ,$2 ]]}}],undefined ]]]]]]}};FAST module [body] → block block [define] → $0 block [define] → $1 block [yield] → {} $1 [value] → . {} [default] → [] . [obj] → $0 [] [0] → $0 [] [1] → $0 [] [2] → * [] [3] → block [] [4] → => * [left] → $0 block [define] → $2 block [yield] → if => [rest] → $3 => [body] → block if [cond] → $2 if [then] → block if [else] → block block [return] → return block [yield] → $0 block [yield] → $2 return [to] → => (recursive) return [value] → $3 $2 [value] → < < [left] → $0 $0 [value] → + module body block define define yield $1 value {} default . obj key $0 "x" [] 0 1 2 3 4 5 $0 $0 * block => undefined * left right $0 3 block define yield => rest body if cond then else block return block yield block yield return to value $2 value $3 < left right $0 4 $0 value + left right 1 2 As DataJS const $0 ={"index" :0 };const $1 =["ref" ,$0 ];const $2 ={"index" :0 };const $3 =["ref" ,$2 ];const $4 ={"kind" :"function" ,"index" :9 };const $5 ={"index" :0 };export default {"parameters" :[],"body" :{"statements" :[["define" ,$0 ,["+" ,1 ,2 ],"required" ],["define" ,{"index" :0 },["." ,$1 ,"x" ],"required" ]],"exit" :["yield" ,[["object" ,[[":" ,"default" ,["array" ,[$1 ,$1 ,["*" ,$1 ,3 ],["block" ,{"statements" :[["define" ,$2 ,["<" ,$1 ,4 ],"required" ]],"exit" :["yield" ,[["if" ,$3 ,{"statements" :[],"exit" :["yield" ,[$1 ]]},{"statements" :[],"exit" :["yield" ,[$3 ]]}]]]}],["function" ,{"target" :$4 ,"parameters" :[],"rest" :$5 ,"self" :null ,"captures" :[],"body" :{"statements" :[],"exit" :["return" ,$4 ,["ref" ,$5 ]]}}],undefined ]]]]]]]}};