[antlr-interest] charVocab

nagii5 nagii5 at yahoo.com
Sun Feb 3 13:00:19 PST 2002


Gurus,
I had a question about the usage of charVocabulary.

i specified the following in my .g but still havent been 
aable to get antlr to recognize characters like
'(' ')' '*' '/'

im using antlr (2.7.0)
heres some grammer i used..... assuming DECLARATION is one on the list 
of TOKENs.

options {
  charVocabulary='3'..'\uffff';
  k=3;
  filter=TEXT
}

protected DECLARATION 
  : "<%!" d:STD_CONTENT "%>"
{
  System.err.println(d.getText());	
}
;

protected STD_CONTENT : ( {! (LA(1) == '%' && LA(2) == '>') }? 
NEWLINE)* ;

protected NEWLINE : c:. { if(c == '\n') newline();} ;

protected TEXT : c:. { if(c == '\n') newline(); 
System.err.println((char)c); };

------------------------------------------------

The Problem: 

if the input for the following lexer is 

<%!  String abc = new String("aaa"); %>

fails on being recognized as a DECLARATION... if i add an extra 
grammer as follows it passes..

The only soln i know of :
-------------------------

protected VOCAB: ('('| ')' );

any character which is not defined in the grammer is being ommitted.
Am i defining charVocabulary in the wrong manner ? 

thanks
Nagesh


 

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



More information about the antlr-interest mailing list