.. _pages/tool/astlets#astlets_-_ast_fragments:

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
=================

.. _pages/tool/astlets#a[i]:

a[i]
----

::

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

.. _pages/tool/astlets#a:

a()
---

::

    call
      operand
        variable
          identifier ("a")
      params

.. _pages/tool/astlets#a_:_b:

{a : 1}
---------

::

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

.. _pages/tool/astlets#a_=_b:

a = b
-----

::

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

.. _pages/tool/astlets#a.b.cd_1:

a.b.c(d)
--------

::

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

.. _pages/tool/astlets#a.b.cd_2:

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
