Consider the following grammar
grammar precedence;
s: expr EOF;
expr: '!' expr | expr '.' ID | ID;
ID: [a-zA-Z];
WS: [ \n] -> skip;
Given the precedence rules of this grammar, the expression !a.b should produce the following parse tree
In an attempt to organize my grammar, I changed it to
grammar precedence;
s: expr EOF;
expr: not | expr '.' ID | ID;
not: '!' expr;
ID: [a-zA-Z];
WS: [ \n] -> skip;
When running it, we get the following parse tree
The ANLTR reference states
ANTLR resolves ambiguities in favor of the alternative given first, implicitly allowing us to specify operator precedence.
However, the position of the not alternative has not changed, yet is given a different precedence. Why? Is there a different rule when there's a layer of indirection like this?

