[antlr-interest] Mask shift-reduce warning?

Jim Idle jimi at temporal-wave.com
Thu Nov 15 08:38:42 PST 2007


I think that just ((word)=>word)+ will make your warning go away as this 
should emphatically state that you want to consume the word there. 

However, have you considered that as all the other elements of your role 
rule are optional, that you could just remove the plus from word and 
this will match a whole series of role rules instead? Of course if you 
want the whole 
qualifier word word word as XXX 

to match a single role rule, then that would not work as that would 
give:

role -> qualifier word
role -> word
role -> word as XXX


Jim

-----Original Message-----
From: Clifford Heath [mailto:clifford.heath at gmail.com] 
Sent: Thursday, November 15, 2007 1:10 AM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Mask shift-reduce warning?

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:

reading: role+;

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.

Clifford Heath.





More information about the antlr-interest mailing list