small medium large xlarge

Generic-user-small
04 Sep 2017, 16:36
Attila Goher (2 posts)

Section 5.4, Dealing with Precedence, Left Recursion, and Associativity, on page 70:

“[…] so ANTLR resolves the operator ambiguity for 1+2*3 in favor of the multiplication”

I think it’s ambiguous because the sentence could have two meanings:

(a) ANTLR uses the multiplication in the first level of the parse tree, just after the root node. That would imply the third alternative of Figure 3 and so: 1+2*3->9

(b) ANTLR uses the multiplication in the bottom of the parse tree. That implies the second alternative of Figure 3 and so: 1+2*3->7

We know that (b) is true, but it might not be obvious from the text.

Ter-brew-pub_pragsmall
05 Sep 2017, 18:25
Terence Parr (52 posts)

Hi. Yep, expressions are inherently ambiguous. Do you have a question?

Generic-user-small
06 Sep 2017, 11:12
Attila Goher (2 posts)

Hi. Thank you for answering my comment. I have no question, I only had that remark but it’s OK.

You must be logged in to comment