[antlr-interest] Grammar Problem
Jim Idle
jimi at temporal-wave.com
Thu Aug 7 14:52:35 PDT 2008
On Thu, 2008-08-07 at 19:20 +0100, Henrique wrote:
> Thanks for your replies guys!
> Jim, I tried your suggestion but I get the same error...
> Johannes, I believe I followed the approach suggested but the thing is
> I need buncha_replacements optional...
> Furthermore, when I try to parse this:
Would probably need to see your whole grammar and sample input then to
be honest.
Jim
>
> rule Foo {
> CIRCLE {}
> }
>
> I works good. So I'm guessing it's got something to do with me not
> making buncha_adjustments optional the right way:
>
> rule : RULE USER_STRING (USER_RATIONAL)? LEFTBRACKET
> buncha_replacements? RIGHTBRACKET;
>
>
>
>
> buncha_replacements
> : (replacement)+
> ;
>
> replacement
> : USER_STRING modification
> | USER_STRING STAR modification USER_STRING modification
> ;
>
>
>
> modification
> : LEFTBRACKET buncha_adjustments? RIGHTBRACKET
> | LEFTBRACE buncha_adjustments? RIGHTBRACE
> ;
>
> buncha_adjustments
> : (adjustment)+
> ;
>
> Any more suggestions?
> Thanks!
>
> Henrique Nunes
>
>
>
> On Thu, Aug 7, 2008 at 6:53 PM, Jim Idle <jimi at temporal-wave.com>
> wrote:
>
> On Thu, 2008-08-07 at 18:40 +0100, Henrique wrote:
>
> > Hi guys!
> > I'm having some trouble with my grammar for parsing CFA
> > files... As I posted before, I'm trying to convert their
> > Yacc grammar to ANTLR and now I'm having some trouble. I
> > suspect it's the left recursions or rather the way I got
> > ridden of them.
> > The grammar is attached and can also be seen here.
> >
> > here's the rules I'm having trouble with:
> >
> > rule : RULE USER_STRING LEFTBRACKET
> > buncha_replacements? RIGHTBRACKET
> > | RULE USER_STRING USER_RATIONAL LEFTBRACKET
> > buncha_replacements? RIGHTBRACKET
> > ;
>
>
>
>
> Try
>
> rule: RULE USER_STRING (USER_RATIONAL {set flag to say this is
> here or something} )? LEFTBRACKET buncha_replacements?
> RIGHTBRACKET;
>
> Jim
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080807/3b3ceace/attachment.html
More information about the antlr-interest
mailing list