class UseLexer { public static void main(String [] args) throws java.io.IOException { MyLexer2 lexer=new MyLexer2(System.in); Token t; while ((t=lexer.yylex())!=null) System.out.println(t.toString()); } } class Token { String type; String text; int line; Token(String t, String txt, int l){type=t; text=txt; line=l; } public String toString(){ return text+" " +type + " " +line; } } %% %line %type Token %class MyLexer2 %eofval{ return null; %eofval} IDENTIFIER = [a-zA-Z_][a-zA-Z0-9_]* %% "int" { return(new Token("INT", yytext(), yyline));} {IDENTIFIER} { return(new Token("ID", yytext(), yyline));} \r|\n {} . {}