[antlr-interest] Import problems with Antlr 3.1.1 - Whitespace

Hendrik Maryns qwizv9b02 at sneakemail.com
Mon Nov 17 02:25:13 PST 2008


Terence Parr schreef:
> 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 think I am having the same problem.  I wanted NEWLINEs to be ignored,
but at least the antlrIDE interpreter doesn’t.

H.
-- 
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 257 bytes
Desc: OpenPGP digital signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20081117/475413d0/attachment.bin 


More information about the antlr-interest mailing list