// Classe abstraite pour lexer simple écrit à la main public abstract class SimpleLex { public abstract int next_token(); // lire entrée pour un token // fragment du token courrant public String yytext; public void yytext_reset(){ yytext=new String(); } // EOF atteint public boolean yyeof; // lecture avec lookahead de 1 public char yychar; public void advance() { try { yytext+=yychar; yychar= (char)System.in.read(); yyeof = (yychar==(char)-1); } catch (java.io.IOException e) { e.printStackTrace();} } // initialisation public void init(String[]args) { try { if (args.length > 0) System.setIn(new java.io.FileInputStream(args[0])); advance(); } catch (java.io.IOException e) { e.printStackTrace(); } } }