[antlr-interest] strange behavior

linkspeed2000 <linkspeed2000 at yahoo.com> linkspeed2000 at yahoo.com
Sun Feb 2 13:43:38 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




 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list