[antlr-interest] How do I get rid of "unexpected token:null" error
sachin_sawant10
sachin_sawant10 at yahoo.com
Tue May 28 03:10:22 PDT 2002
I am using following grammer to parse JSP file. I want to read
<i18n:img tags from the jsp page.
My grammer ---
class JSPParser extends Parser;
file: (statement)+
;
statement: ( WORD
| STRING
| i:IMG {System.out.println("IMG Tag " + i.getText());}
)
;
class JSPLexer extends Lexer;
options {
caseSensitive=false;
k=7;
filter=SCARF;
charVocabulary='\3'..'\177';
}
IMG
: "<i18n:img"
(WS (ATTR)*)?
"/>"
;
protected
ATTR
options {
ignore=WS;
}
: w:WORD '='
( s:STRING
| v:WORD
)
;
/** Match until next whitespace; can be file, int, etc... */
protected
WORD: (
options {
generateAmbigWarnings=false;
}
: 'a'..'z' | '0'..'9' | '/' | '.' | '#' | '_'
)+
;
protected
STRING
: '"' (~'"')* '"'
| '\'' (~'\'')* '\''
;
protected
WS : ( ' '
| '\t'
| '\f'
| ( "\r\n" // DOS
| '\r' // Macintosh
| '\n' // Unix (the right way)
)
{ newline(); }
)
;
protected
SCARF
: WS // track line numbers while you scarf
| .
;
-----------------------end of grammer --------------------------------
When I used the above grammer with any jsp files which does not
have "<i18n:img" tag I get "unexpected token:null" error. I also get
the error when I use empty file as an input.
How do I get rid of it?
Regards
Sachin
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list