Posted By:
Andrew_Ferguson
Posted On:
Thursday, June 3, 2004 05:21 AM
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 { import java.io.*; } class TestLexer extends
More>>
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
{
import java.io.*;
}
class TestLexer extends Lexer;
options { charVocabulary='3'..'377'; }
COMMENT : ';' (~('
'|'
'))+
{ System.out.print("COMMENT "); }
;
NEWLINE : ('
''
')=> '
''
' //DOS
| '
' //MAC
| '
' //UNIX
{ System.out.println("NEWLINE"); }
;
WS : (' '|' ')
{ System.out.print("WS ");
$setType(Token.SKIP); } ;
<<Less