[antlr-interest] Invalid parser generation
Stefan Mätje
Stefan.Maetje at esd-electronics.com
Tue Sep 4 05:26:55 PDT 2012
Am 04.09.2012 13:20, schrieb mark4 at voila.fr:
> Hi everyone,
>
> I've built a grammar file, checked it with AntlrWorks, and ran the code generation for the C# language. Though, some invalid code has been generated.
>
> This rule:
> compte : ('0'..'9')+
> ;
This is a parser rule (lower case rule name) but you're using lexer
syntax on the right side of the ":". This won't work.
I think that is the origin of your problems.
Use
COMPTE: ('0'..'9)+
making a lexer rule of it.
> translates to:
>
> [GrammarRule("compte")]
> private void compte()
> ...
> try { DebugEnterSubRule(5);
> while (true)
> {
> int alt5=2;
> try { DebugEnterDecision(5, decisionCanBacktrack[5]);
> int LA5_0 = input.LA(1);
>
> if (()) <= This triggers an error!!!
> {
> alt5 = 1;
> }
> ...
>
> I have a similar void if, a bit farther in the compte() method. What's wrong with this simple rule?
>
> Thanks in advance,
> Mark
> ___________________________________________________________
> Quand Jean-Luc Delarue parlait de son grand amour… à lire sur Voila.fr http://people.voila.fr/people/actu-stars/personnalites/quand-jean-luc-delarue-parlait-d-anissa-kehl-son-grand-amour-people_8397.html
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
I hope that helps and is what you really want to do.
Best regards,
Stefan Mätje
More information about the antlr-interest
mailing list