Production rules

A Metal rule consists of a production rule, or concrete syntax rule, and a tree building function. The parser identifies valid program sentences with these production rules. For instance, the production rule:


 <exp> ::= <exp> "+" <exp> ;

tells the parser that two expressions separated by a + constitute a valid expression. All non-terminals appearing on the right hand side of a rule must themselves appear on the left hand side of at least one other rule. The names chosen for terminals and non-terminals need not be names from the abstract syntax definition, but we suggest using meaningful names (e.g., phyla names) whenever possible. Symbols and keywords to be recognized must appear within double quotes.


Tutorial