Next: , Previous: L structure, Up: L presentation


3.2 L concrete syntax

The parser handle the concrete syntax of the language.

TO_WRITE

S-expressions (sexps): a notation to represent trees.

Concept of tree : a + b * c is converted into (* (+ a b) c). In this representation, the first symbol represents the head of the tree, and subsequents fields represent the sons, that can be trees themselves. So the above code is really:

     *--- + --- a
      \    \----b
       \--c

Another example: L's code

     function1(toto, function2(24,49), 3+i)

has the tree representation:

                     function1
                    /     |    \
                toto function2  +
                       /   \    |\
                      24   49   3 i

And the sexp representation:

     (function1 toto
                (function2 24 49)
                (+ 3 i))

So the sexp notation is just a convenient representation to represent trees.