How can I allow single-line comments with EOF on the end instead of a newline?
Created May 4, 2012
Terence Parr Here is a simple example that works for me.
class CL extends Lexer; options { charVocabulary = 'u0000'..'u007f'; } { public static void main(String[] args) throws Exception { CL lexer = new CL(System.in); Token t = lexer.nextToken(); System.out.println("Token: "+t); while ( t.getType()!=Token.EOF_TYPE ) { System.out.println("Token: "+t); t = lexer.nextToken(); } } } ID : ( 'a'..'z')+; WS : ' ' | ' ' ; CMT : "//" (~' ')* (' ')? ;