hi,
I've been working through some simple Lexer examples in ANTLR (java) and
have come across a problem with my grammer (included below). It gets as
far
as I'd expect it to but when complaining about the unknown character
sequence refers to the problem being at "Line 1:293" - when its actually
something like "Line 14:2"
is there some way to get it to recognize lines again? (what in my grammar
has stopped it doing this - charVocabulary??)
any help appreciated,
thanks,
asjf
{
im****t java.io.*;
}
class TestLexer extends Lexer;
options { charVocabulary='\3'..'\377'; }
COMMENT : ';' (~('\r'|'\n'))+
{ System.out.print("COMMENT "); }
;
NEWLINE : ('\r''\n')=> '\r''\n' //DOS
| '\r' //MAC
| '\n' //UNIX
{ System.out.println("NEWLINE"); }
;
WS : (' '|'\t')
{ System.out.print("WS ");
$setType(Token.SKIP); } ;