%% %{ private void echo () { System . out . print (yytext ()); } private java_cup . runtime . Symbol token (int token_class, Object token_value) { return new java_cup . runtime . Symbol (token_class, yychar, yychar + yylength (), token_value); } private java_cup . runtime . Symbol token (int token_class) { return new java_cup . runtime . Symbol (token_class, yychar, yychar + yylength (), null); } %} %function nextToken %type java_cup . runtime . Symbol %char %eofval{ { return token (Symbol . EOF); } %eofval} commenttext=(.|\n)* comment="/*"{commenttext}"*/" digit = [0-9] upper = [A-Z] lower = [a-z] letter = [A-Za-z] %% [\ \t\n] { echo (); } {comment} { echo (); } ";" { echo (); return token (Symbol . SEMICOLON); } "::" { echo (); return token (Symbol . DOUCOLON); } ":" { echo (); return token (Symbol . COLON);} "," { echo (); return token (Symbol . COMMA);} "." { echo (); return token (Symbol . DOT);} "(" { echo (); return token (Symbol . LPAREN);} ")" { echo (); return token (Symbol . RPAREN);} "class" { echo (); return token (Symbol . CLASS);} "extends" { echo (); return token (Symbol . EXTENDS);} "end" { echo (); return token (Symbol . END);} ({digit}+)|(({digit}+)"."({digit}+)"E+"{digit})|({lower}{letter}*)|"+"|"-"|"*"|"/"|">"|"<"|"="|">="|"=<" { echo (); return token (Symbol . PROTONOTION, new String (yytext ())); } {upper}{letter}*{digit}? { echo (); return token (Symbol . METANOTION, new String (yytext ())); } . { echo (); ErrorMessage . print (yychar, "Illegal character");}