示例#1
0
 public static void main(String args[]) {
   Exp1Parser parser;
   if (args.length == 0) {
     System.out.println(
         "Expressoes 1 PLP Parser Version 0.0.1:  Reading from standard input . . .");
     parser = new Exp1Parser(System.in);
   } else if (args.length == 1) {
     System.out.println(
         "Expressoes 1 PLP Parser Version 0.0.1:  Reading from file " + args[0] + " . . .");
     try {
       parser = new Exp1Parser(new java.io.FileInputStream(args[0]));
     } catch (java.io.FileNotFoundException e) {
       System.out.println("Java Parser Version 1.0.2:  File " + args[0] + " not found.");
       return;
     }
   } else {
     System.out.println("Expressoes 1 PLP Parser Version 0.0.1:  Usage is one of:");
     System.out.println("         java Exp1Parser < inputfile");
     System.out.println("OR");
     System.out.println("         java Exp1Parser inputfile");
     return;
   }
   try {
     Programa programa = parser.Input();
     System.out.println(
         "Expressoes 1 PLP Parser Version 0.0.1:  Expressoes1 program parsed successfully.");
     if (!programa.checaTipo()) {
       System.out.println("Erro de tipo");
     } else {
       programa.executar();
     }
   } catch (ParseException e) {
     System.out.println(
         "Expressoes 1 PLP Parser Version 0.0.1:  Encountered errors during parse.");
   }
 }