[antlr-interest] Literals not handled in grammars with import

Raphael Reitzig r_reitzi at cs.uni-kl.de
Mon Aug 25 01:06:06 PDT 2008


Hi Thomas!

I do not know what goes wrong there, but I learned the general rule:

Thou shalt not use literals in parser or walker rules!

Thus, I would expect your problem, be there a bug or not, to vanish if  
you create a lexer rule and refer to this token at all occurrences of  
your string.
Improves maintainability, too.

Regards

Raphael

"Thomas Brandon" <tbrandonau at gmail.com> wrote (Mon Aug 25 09:08:55 2008):

> In 31, imported literals are not being handled correctly in tree
> grammars utilising import.
>
> Given the included grammars, while TestTree.g works properly, in
> TestTree2.g the literals are not correctly imported and new token
> types are assigned. This occurs in both rules from the imported
> grammar (tok1 in TestTree2_TestTree.java) and new rules in the
> importing grammar (tok1_2 in TestTree2.java).
>
> Tom.
>
> <Test.g>
> grammar Test;
>
> tok1: 'tok1';
> </Test.g>
>
> <TestTree.g>
> tree grammar TestTree;
>
> options {
> 	tokenVocab=Test;
> 	ASTLabelType = CommonTree;
> }
>
> tok1:
> 	'tok1'
> 	;
> </Test2.g>
>
> <TestTree2.g>
> tree grammar TestTree2;
>
> options {
> 	tokenVocab=Test;
> 	ASTLabelType = CommonTree;
> }
>
> import TestTree;
>
> tok1_2:
> 	'tok1'
> 	;
> </TestTree2.g>
>



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: PGP Digital Signature
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20080825/84fb2ce2/attachment.bin 


More information about the antlr-interest mailing list