[antlr-interest] Import problems with Antlr 3.1.1 - Whitespace
Terence Parr
parrt at cs.usfca.edu
Fri Nov 14 14:08:57 PST 2008
I'll add to my list to look at.
Ter
On Nov 14, 2008, at 12:21 PM, Peterson, Joe wrote:
> Hello all,
>
> I'm having several some problems with import and I'm hoping y'all
> can help me understand the problems. I'll list them in separate e-
> mails as I fully qualify the problems.
>
> Basically, I have 15 or so related files that I need to parse. They
> all should use the same lexer rules, so I started out trying to put
> all the lexer rules into a single file that all the root grammars
> would import. But that didn't work. I'm using Antlr 3.1.1
> (AntlrWorks 1.2) and when I compile, I'm using VC2008 (but my
> current problem happens even using the AntlrWorks interpreter).
>
> Here is my first problem... I can't seem to put all my lexer rules
> in a separate file because when I put the WS definition in a
> separate file, I get errors. Take these overly simple sample files
> that demonstrate one of my issues:
>
> //// test.g Starts here
> grammar test;
> import testlexer;
> version_info : VERSION VERSION_IDENTIFIER SEMICOLON ;
> //// test.g Ends here
>
> //// testlexer.g starts here
> lexer grammar testlexer;
> VERSION : 'Version';
> VERSION_IDENTIFIER : ('0'..'9')+ '.' ('0'..'9')+ ;
> SEMICOLON : ';';
> WS : (' '|'\t' | '\r' | '\n')+ {$channel=HIDDEN;};
> //// testlexer.g ends here
>
> //// input starts here
> Version 1.0;
> //// input ends here
>
> When I run it on a simple file it blows up after the version
> keyword... it's like it doesn't send the WS to the hidden channel.
>
> If I move the WS declaration into test.g, it works fine.
>
> Am I missing something with how imports work? Shouldn't I be able to
> put the WS declaration in the common lexer file?
>
> (I apologize if this goes through twice, I sent it yesterday and
> still haven't seen it come through...)
>
> Thanks,
> -JEEP
> Joe Peterson
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list