[antlr-interest] Grammar Problem
Henrique
hjrnunes at student.dei.uc.pt
Thu Aug 7 11:20:20 PDT 2008
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:
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<http://hjrnunes.googlepages.com/antlrgrammar>
> .
>
> 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/e613cdfc/attachment.html
More information about the antlr-interest
mailing list