3 ms·
I agree. I'm very weak in grammar, but I dont understand how this one would work. Shouldn't it be ? Expr ::= Expr + Term | Expr - Term | Term; Term ::= Ter
by ecaradec 12y ago
I agree. I'm very weak in grammar, but I dont understand how this one would work. Shouldn't it be ?
Expr ::= Expr + Term | Expr - Term | Term;
Term ::= Term * Factor | Term / Factor | Factor
Factor ::= Int | ( Expr )
- sklogic 12y agoExactly. And yet it's not easy to infer mechanically that an Expr (but not its Term branch) must be printed in "( ... )" when it's in the Factor branch of an AST.
- david-gudeman 12y agoThere are precedence indicators to describe precedence (BTW, this is needed for formatting as well as parsing). The details are too complicated for a reply, but they are in the language manual.