3 ms·
I wonder how they handle cases like "a*(b+c)".
by sklogic 12y ago
I wonder how they handle cases like "a*(b+c)".
- ecaradec 12y agoI 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.