/*************** romani.lex - versione 0 ************ riconoscitore di numeri romani ****************************************************/ class NumeriRomani { public static void main(String[] args) throws java.io.IOException { Yylex yy = new Yylex(System.in); yy.yylex(); } } class Yytoken {} %% FineRiga = \r | \n | \r\n Spaziatura = [ \t\f] | {FineRiga} %state CINQUE, DECINE, UNITA, QUATTRO, NOVE %% I | II | III {System.out.print(yytext()); yybegin(UNITA);} V {System.out.print(yytext()); yybegin(CINQUE);} X | XX | XXX {System.out.print(yytext()); yybegin(DECINE);} IV {System.out.print(yytext()); yybegin(QUATTRO);} IX {System.out.print(yytext()); yybegin(NOVE);} {Spaziatura} {} {Spaziatura} {System.out.println ("\nNumero letto correttamente"); yybegin(YYINITIAL);} . {System.out.println("\nCarattere " + " inaspettato: " + yytext()); yybegin(YYINITIAL);}