[antlr-interest] Composite Grammar [C Target]

Juancarlo Añez apalala at gmail.com
Tue Sep 25 13:36:52 PDT 2012


Justin,

I think it is a bug. Just add this to CommonTokens.g:

nothing
    :
    ;

-- Juancarlo

On Tue, Sep 25, 2012 at 3:19 PM, Justin Murray <jmurray at aerotech.com> wrote:

> Hello,
>
> I'm trying to use composite grammars, and can't seem to get off of the
> ground. Basically, I have two separate parsers. One preprocesses the
> source, and the other compiles it. Naturally, they have a few tokens in
> common, such as a newline, and I'd prefer to only define that token
> once. This sounds to me like exactly what composite grammars were
> designed to do. So I made a CommonTokens.g:
>
> lexer grammar CommonTokens;
>
> NEWLINE_ :  ('\r'? '\n');
>
> Then in my grammar, I added an import:
>
> grammar AerobasicPreprocessor;
> import CommonTokens;
>
> options { language=C;  }
>
> line : SOMEOTHERTOKENS_ NEWLINE_;
> ...
>
>
> When I run the ANTLR tool on this grammar, I get some less than helpful
> errors:
>
> error(100): AerobasicPreprocessor.g:4:1: syntax error: antlr:
> org.antlr.runtime.EarlyExitException
> error(150):  grammar file AerobasicPreprocessor.g has no rules
> error(100): AerobasicPreprocessor.g:0:1: syntax error: assign.types:
> org.antlr.runtime.EarlyExitException
> org\antlr\grammar\v3\DefineGrammarItemsWalker.g: node from line 326:1
> required (...)+ loop did not match anything at input ';'
>
> What am I doing wrong?
>
> Thanks,
>
> - Justin
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>



-- 
Juancarlo *Añez*


More information about the antlr-interest mailing list