[antlr-interest] Composite Grammar [C Target]
Justin Murray
jmurray at aerotech.com
Tue Sep 25 14:18:30 PDT 2012
Juancarlo,
Thank you for the suggestion, but that just results in a new error (which at least makes some sense):
error(103): CommonTokens.g:57:1: parser rule nothing not allowed in lexer
Any other ideas?
- Justin
From: juancarlo.anez at gmail.com [mailto:juancarlo.anez at gmail.com] On Behalf Of Juancarlo Añez
Sent: Tuesday, September 25, 2012 4:37 PM
To: Justin Murray
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Composite Grammar [C Target]
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