[antlr-interest] Disabling look ahead or ???
John B. Brodie
jbb at acm.org
Mon Mar 2 11:25:45 PST 2009
Greetings!
On Monday 02 March 2009 10:51:20 am Paul Bouché (NSN) wrote:
> I have the following grammer, problem described below.
> start : outerPropertynode | EOF;
> outerPropertynode : outerProperties;
> properties : (property delim)*; // simplified
> property : key '=' value;
> value : plain | '{' propertynode '}'
>
> As you can see the value rule recursively calls the propertynode rule.
> Empty propertynode values are ok. This is what the grammar expresses.
Ok, I believe you. But the above grammar fragment does not express that - in
fact the fragment is incomplete and so it is really hard to infer anything
about it.
> Yet, now I installed error recovery on the rule property, which says
> that if there is an erroneous token found in rule property consume
> everything until you find a delimiter, effectively discarding this
> property. Yet from the start if there is an erroneous token for key the
> lookahead in rule properties will decide that this has to match as an
> empty property and an exception occurs in the start rule. In the case of
> a non empty stream and when parsing from the start I would like to force
> rule invocation of rule property even though the look ahead decides for
> empty match. I still want the non empty stream to be matched correctly
> without error generation, but anyother input to be tried to be matched
> by rule property.
I am sorry but I am really confused by what it is you are trying to
accomplish.
Can you please post the smallest - yet COMPLETE - example grammar of your
problem?
Speculating on what your problem might be ... have you tried something like
this (untested):
start : ( key '=' value delim )* EOF ;
value = plain | '{' propertynode ? '}' ;
propertynode : /* the non-empty version of whatever this is */ ;
key = /* whatever this is */ ;
delim = /* whatever this is */ ;
Hope this helps
-jbb
(looking forward to finding out more about your problem)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090302/baba01c3/attachment.html
More information about the antlr-interest
mailing list