Table 1-3 shows syntactic rules, the non terminals are represented by lowercase letters, the terminal symbols are represented by uppercase letters, and the symbols enclosed in double quotes are terminal symbols. There is no precedence assigned to the operators. You must use square brackets to establish precedence.
Table 1-3 Syntactical Rules of Expressions
expr : term | expr "+" term | expr "-" term | expr "\*" term | expr "\/" term | expr "&" term | expr "|" term | expr ">>" term | expr "<<" term | expr "\%" term | expr "!" term | expr "^" term term : id | number | "-" term | "[" expr "]" | "<o>" term | "<s>" term ; id : LABEL ; number : DEC_VAL | HEX_VAL | OCT_VAL | BIN_VAL ; |
The terminal nodes are given by the following regular expressions:
LABEL = [a-zA-Z_][a-zA-Z0-9_]*: DEC_VAL = [1-9][0-9]* HEX_VAL = 0[Xx][0-9a-fA-F][0-9a-fA-F]* OCT_VAL = 0[0-7]* BIN_VAL = 0[Bb][0-1][0-1]*
In the above regular expressions, choices are enclosed in square brackets; a range of choices is indicated by letters or numbers separated by a dash (-); and the asterisk (*) indicates zero or more instances of the previous character.