[antlr-interest] Mask shift-reduce warning?
clifford.heath at gmail.com
Thu Nov 15 01:10:24 PST 2007
Kevin J. Cummings wrote:
> That's what syntactic predicates do. If you can view far enough ahead
> to see what you want, you can avoid ANTLR doing the "wrong" thing.
Perhaps. But in this case, either alternative is ok, and the chosen one
especially so, and I can't look far enough ahead anyhow (using k=5), so
I just want to hide the warning. It's a kind-of awkward grammar, as it
has a strong natural-language element in parts:
role: quantifier? word+ ( '(' 'as' ID ')' )? (literal | restriction )?;
word: ID | <various keywords not in their keyword contexts>;
You see that role can eat up any number of successive words, and so can
a reading (and I'd be able to cope if it did anyhow); but a quantifier
always starts a new word group and 'as' or a literal or a restriction
always ends one.
I have to walk through the words doing various complex symbol-table
matching to resolve the word groups (which is why I can cope either way),
but that's something I do after parsing the whole reading. The grammar
works, but emits warning that will make it hard to see new ones I might
cause. It's worse because all the contextual keywords that can be a
"word" get a separate warning.
More information about the antlr-interest