[antlr-interest] help understanding the parsing error

Mikhail Kruk meshko at gmail.com
Fri May 11 13:10:06 PDT 2012


The reason the options are there is because I'm working with a much
larger grammar which I didn't write, but am trying to modify.
Removing them doesn't make a difference.

On Fri, May 11, 2012 at 3:17 PM, Jim Idle <jimi at temporal-wave.com> wrote:
> Try taking out the backtrack, k, and memorize options. You should not use
> backtrack unless you have no choice and you are usually better letting
> ANTLR deal with k. Have you followed the getting started articles in the
> wiki?
>
> Jim
>
>> -----Original Message-----
>> From: Mikhail Kruk [mailto:meshko at gmail.com]
>> Sent: Friday, May 11, 2012 11:57 AM
>> To: Jim Idle
>> Cc: antlr-interest at antlr.org
>> Subject: Re: [antlr-interest] help understanding the parsing error
>>
>> I tried it and it doesn't seem to make a difference.
>>
>> On Fri, May 11, 2012 at 2:28 PM, Jim Idle <jimi at temporal-wave.com>
>> wrote:
>> > Do not use 'XYZ'. Create a token in the lexer:
>> >
>> > XYZ : 'XYZ' ;
>> >
>> > And declare it before your ID rule. Do this for all the literals in
>> > your parser grammar.
>> >
>> > Jim
>> >
>> >> -----Original Message-----
>> >> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>> >> bounces at antlr.org] On Behalf Of Mikhail Kruk
>> >> Sent: Friday, May 11, 2012 8:30 AM
>> >> To: antlr-interest at antlr.org
>> >> Subject: [antlr-interest] help understanding the parsing error
>> >>
>> >> I have a very simple grammar (attached, but here's the relevant
>> part):
>> >>
>> >>
>> >> start
>> >>       :       (simple_expression | dotted_identifier)*
>> >>       ;
>> >>
>> >> simple_expression
>> >>       :       'XYZ' 'HAHA'
>> >>       ;
>> >>
>> >> identifier
>> >>       :       ID
>> >>       ;
>> >>
>> >> dotted_identifier
>> >>       :       identifier ( DOT identifier )*
>> >>       ;
>> >>
>> >> It pretty much works as expected, accepting "XYZ HAHA", "BLAH.TEST"
>> >> and "ABC".  But when I try to parse "XYZ.A" or "A.XYZ" it gets
>> >> confused trying to apply simple_expression to 'XYZ'.  I don't
>> >> understand why this is happening.  Shouldn't backtracking tear right
>> through this?
>> >>
>> >> Thanks!
>> >> -m
>> >
>> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
>> > Unsubscribe:
>> > http://www.antlr.org/mailman/options/antlr-interest/your-email-
>> address
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.g
Type: application/octet-stream
Size: 454 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20120511/8f735e12/attachment.obj 


More information about the antlr-interest mailing list