
19 May
2009
19 May
'09
3:54 a.m.
The grammar: expression = "get" | [ "+" | "-" ] term { ( "+" | "-" ) term } term = factor { ( "*" | "/" ) factor } factor = IDENTIFIER | VALUE | "(" expression ")"
I can't make term parse, for instance "1 * 2 / 3"
Indeed, the grammar does not admit "1*2/3" as a sentence of that language although it will admit "(1*2)/3" or "1*(2/3)". If you wish to allow sequences of infix operators without bracketting, then examples of the standard grammar for this can be found by searching the web for "expression term factor", e.g. http://en.wikipedia.org/wiki/Syntax_diagram suggests: expression ::= term | term "+" expression term ::= factor | factor "*" term factor ::= constant | variable | "(" expression ")" Regards, Malcolm