[antlr-interest] Error in "rewriteTokenRef" template

Shmuel Siegel ssiegel at finjan.com
Wed Feb 14 02:18:01 PST 2007


There is a bug in the rewrite rules when trying to create an artificial token using one of the token IDs that is in the pattern. I dealt with this by creating a new token type, XINT. I then treated XINT and INT as identical during tree walking.

In other words, make you rewrite rule ^(vars ID XINT["1"])

 

________________________________

From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Dr. Hartmut Kocher
Sent: Tuesday, February 13, 2007 11:29 PM
To: 'ANTLR Interest'
Subject: [antlr-interest] Error in "rewriteTokenRef" template

 

The following grammar triggers a 

"error(10):  internal error: Simple.g : java.util.NoSuchElementException: no such attribute: args in template context [rewriteTokenRef]

"

rewriteTokenRef does not have an args parameter. But I couldn't figure out, how to fix it.

 

 

The rewrite rule -> ^(vars ID INT["1"])  triggers the error.

 

Any ideas?

 

Hartmut

 

 

grammar Simple;

 

options {

     language=Java;

     output=AST;

     ASTLabelType=CommonTree;

     }

 

 

t :

vars (

     'in' 'table' ID 

          ( '>' INT -> ^(vars ID INT)

          |               -> ^(vars ID INT["1"])  // The INT["1"] triggers the error

          )

);

 

vars : 'abc' | 'abd';

 

fragment DIGIT  :    '0'..'9';

 

 

INT :    DIGIT+;

 

 

ID   :    ('abc' DIGIT) => 'abc' {$type = ABC;} | ('a'..'z'|'A'..'Z') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')+ ;

 

 

WS  :  (' '|'\r'|'\t'|'\f'|'\n')+ { $channel=HIDDEN; };

 

 

Dr. Hartmut Kocher

Cortex Brainware Consulting & Training GmbH

Kirchplatz 5
D-82049 Pullach

Tel: +49 (89) 744  850 0
Fax: +49 (89) 744  850 11

http://www.cortex-brainware.de <http://www.cortex-brainware.de/> 

E-Mail: hwk at cortex-brainware.de

Handelsregister:
Registergericht: Amtsgericht München
HRB-Nr. 120614

Vertretungsberechtigte Geschäftsführer:
Dipl.-Inform. Dorothea Burger, Dr.-Ing. Hartmut Kocher, Dr.-Ing. Martin Lang, Dr. rer. nat. Rolf Peter Wehrum 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070214/ca06c2c4/attachment.html 


More information about the antlr-interest mailing list