public static void main(String args[]) throws Exception { Yylex l = null; parser p; try { if (args.length == 0) l = new Yylex(System.in); else l = new Yylex(new FileReader(args[0])); } catch (FileNotFoundException e) { System.err.println("Error: File not found: " + args[0]); System.exit(1); } p = new parser(l); /* The default parser is the first-defined entry point. */ /* You may want to change this. Other options are: */ /* */ try { pl.edu.mimuw.cloudatlas.interpreter.query.Absyn.Program parse_tree = p.pProgram(); System.out.println(); System.out.println("Parse Succesful!"); System.out.println(); System.out.println("[Abstract Syntax]"); System.out.println(); System.out.println(PrettyPrinter.show(parse_tree)); System.out.println(); System.out.println("[Linearized Tree]"); System.out.println(); System.out.println(PrettyPrinter.print(parse_tree)); } catch (Throwable e) { System.err.println( "At line " + String.valueOf(l.line_num()) + ", near \"" + l.buff() + "\" :"); System.err.println(" " + e.getMessage()); System.exit(1); } }
public static void main(String argv[]) throws java.io.IOException { int numparams = argv.length; // número argumentos pasados if (numparams != 1) { // error: nr. Parámetros incorrecto System.out.println("Número parámetros incorrecto!. Uso: "); System.out.println("\tjava yylex archivo.EXT"); return; } else { fInName = argv[0]; Yylex yy = new Yylex(new FileInputStream(fInName)); while (yy.yylex() != -1) ; } }
public int getPosition() { return lexer.getPosition(); }
public void reset(Reader in) { lexer.yyreset(in); reset(); }
private void nextToken() throws ParseException, IOException { token = lexer.yylex(); if (token == null) { token = new Yytoken(Yytoken.TYPE_EOF, null); } }