phylum: Operator( sub-phyla ) | ... ;
(we borrowed this syntax to define phyla from SSL (the Synthesizer Specification Language that is the input language of the Synthesizer Generator, a system to generate language-based editors))
The abstract syntax for our language can defined as follows:
We expect here only non-negative
expr: Const( int ) /* int is predefined */ | Plus( expr expr ) | Times( expr expr ) ;
intvalues, if needed we can check for this. Note that parentheses are implied by the form (structure) of the tree -- with the Operator we can distinguish between the rule for the plus (+) and the times (*) operators.
Phyla can have attributes, as we will see later.
(1 + 1) * (1 + 1)we can write:
expr e = Times( Plus( Const( 1 ), Const( 1 )), Plus( Const( 1 ), Const( 1 )) );
next overview up