qooxdoo

Universal JavaScript Framework

 

ASTlets - AST Fragments

Note

Work in Progress

This is an ongoing page to record and document the AST (abstract syntax tree) fragments ("ASTlets"), as they are generated by the tool chain Javascript parser. It shows how certain JS syntax constructs get translated into the corresponding AST representation. This serves mainly internal purposes and should not be relevant for a qooxdoo application developer.

The notation is a simplified tree structure that names token symbols and their nesting through indentation. "|" denotes alternatives.

Syntax Constructs

a[i]

accessor
  identifier ("a")
  key
    variable
      identifier ("i")

a()

call
  operand
    variable
      identifier ("a")
  params

{a : 1}

map
  keyvalue ("a")
    value
      constant (1)

a = b

assignment
  left
    variable
      identifier ("a")
  right
    variable
      identifier("b")

a.b.c(d)

call
  operand
    variable
      identifier ("a")
      identifier ("b")
      identifier ("c")
  params
    variable
      identifier ("d")

a.b().c(d)

accessor
  left
    call
      operand
        variable
          identifier ("a")
          identifier ("b")
  right
    call
      operand
        variable
          identifier ("c")
      params
        variable
          identifier ("d")

[file:] a.b("c",{d:e})

file
  call
    operand
      variable
        identifier ("a")
        identifier ("b")
    params
      constant  ("c")
      map
        keyvalue ("d")
          value
            variable
              identifier ("e")

(function () {return 3;})()

(anonymous function immediately called)

call
  operand
    group
      function
        params
        body
          block
            return
              expression
                constant ("3")

function () {return 3;}()

(anonymous function immediately called - no paren)

call
  operand
    function
      params
      body
        block
          return
            expression
              constant ("3")

if (1) {} else {}

loop
  expression
    constant ("1")
  statement
    block
  elseStatement
    block

for (var i=0; i<l; i++) {}

loop
  first
    definitionList
      definition
        assignment
          constant ("0")
  second
    operation
      first
        variable
          identifier ("i")
      second
        variable
          identifier ("j")
  third
    operation ("inc")
      first
        variable
          identifier ("i")
  statement
    block

for (var i in j) {}

loop
  first
    operation ("in")
      first
        definitionList
          definition ("i")
      second
        variable
          identifier ("j")
  statement
    block