[antlr-interest] Strange Behavior

X f linkspeed2000 at yahoo.com
Sun Feb 2 13:41:20 PST 2003


options {
language = "CSharp";
}

class CSParser extends Parser;
options {
buildAST = true; // uses CommonAST by default
}

identifier : IDENT (DOT^ IDENT)*
;


class CSLexer extends Lexer;

// Whitespace -- ignored
WS : ( ' '
| '\t'
| '\f'
| ( options {generateAmbigWarnings=false;} 
: "\r\n" // Evil DOS
| '\r' // Macintosh
| '\n' // Unix (the right way)
)
{ newline(); }
)+
{ _ttype = Token.SKIP; }
;

DOT : '.' ;

IDENT : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
; 
class CSTreeWalker extends TreeParser; 
identifier 
: #(ASDF identifier IDENT) 
; 
This file is to parse string like "aaa.bbb.ccc". The tree should be like (. (. bbb ccc) aaa) 
Please look at second last line. Token ASDF is not defined at all. But this grammar works. 
If I changes ASDF into DOT, or I remove the Treewalker section, it will have IndexOutOfRangeException. 
Can anyone tell me why? 
Thanks




---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20030202/1edbee08/attachment.html


More information about the antlr-interest mailing list