示例#1
0
 public final void id() throws ParseException {
   /*@bgen(jjtree) id */
   SimpleNode jjtn000 = new SimpleNode(JJTID);
   boolean jjtc000 = true;
   jjtree.openNodeScope(jjtn000);
   Token tk = null;
   try {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case IDENTIFIER:
         tk = jj_consume_token(IDENTIFIER);
         break;
       case STRING_LITERAL:
         tk = jj_consume_token(STRING_LITERAL);
         break;
       default:
         jj_la1[18] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
     }
     jjtree.closeNodeScope(jjtn000, true);
     jjtc000 = false;
     jjtn000.addTerm(createString(tk.image), 0);
   } finally {
     if (jjtc000) {
       jjtree.closeNodeScope(jjtn000, true);
     }
   }
 }
示例#2
0
 public final void dotRecordElement() throws ParseException {
   /*@bgen(jjtree) dotRecordElement */
   SimpleNode jjtn000 = new SimpleNode(JJTDOTRECORDELEMENT);
   boolean jjtc000 = true;
   jjtree.openNodeScope(jjtn000);
   Token tk;
   try {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case STRING_LITERAL:
         tk = jj_consume_token(STRING_LITERAL);
         jjtree.closeNodeScope(jjtn000, true);
         jjtc000 = false;
         jjtn000.addTerm(createString(tk.image), 0);
         break;
       case LBRACE:
         dotRecordV();
         break;
       default:
         jj_la1[25] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
     }
   } catch (Throwable jjte000) {
     if (jjtc000) {
       jjtree.clearNodeScope(jjtn000);
       jjtc000 = false;
     } else {
       jjtree.popNode();
     }
     if (jjte000 instanceof RuntimeException) {
       {
         if (true) throw (RuntimeException) jjte000;
       }
     }
     if (jjte000 instanceof ParseException) {
       {
         if (true) throw (ParseException) jjte000;
       }
     }
     {
       if (true) throw (Error) jjte000;
     }
   } finally {
     if (jjtc000) {
       jjtree.closeNodeScope(jjtn000, true);
     }
   }
 }
示例#3
0
文件: Tests.java 项目: alfongj/gte
 static void doIt(String toParse, BufferedWriter fw, SimpleNode optNode) throws Exception {
   long[] testArray = new long[10];
   double d = 0;
   DoubleStack stack = new DoubleStack();
   for (int j = 0; j < 10; j++) {
     Thread.yield();
     long start = System.currentTimeMillis();
     for (int i = 0; i < 100000; i++) {
       d = optNode.getValue();
     }
     testArray[j] = System.currentTimeMillis() - start;
   }
   fw.write("100000 evaluations: ");
   for (int j = 0; j < 10; j++) {
     fw.write(testArray[j] + ", ");
   }
   fw.write("\n");
 }
示例#4
0
 public final void port() throws ParseException {
   /*@bgen(jjtree) port */
   SimpleNode jjtn000 = new SimpleNode(JJTPORT);
   boolean jjtc000 = true;
   jjtree.openNodeScope(jjtn000);
   boolean l = false;
   boolean la = false;
   boolean a = false;
   boolean al = false;
   try {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case 45:
         portLocation();
         l = true;
         la = true;
         switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
           case AT:
             portAngle();
             a = true;
             break;
           default:
             jj_la1[13] = jj_gen;
             ;
         }
         break;
       case AT:
         portAngle();
         a = true;
         al = true;
         switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
           case 45:
             portLocation();
             l = true;
             break;
           default:
             jj_la1[14] = jj_gen;
             ;
         }
         break;
       default:
         jj_la1[15] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
     }
     jjtree.closeNodeScope(jjtn000, true);
     jjtc000 = false;
     if (la) {
       if (!a) {
         jjtn000.addTerm(createNil(), 1);
       }
     } else if (al) {
       if (l) {
         Term tl = jjtn000.getSubtermAt(1);
         Term ta = jjtn000.getSubtermAt(0);
         jjtn000.setSubtermAt(0, tl);
         jjtn000.setSubtermAt(1, ta);
       } else {
         jjtn000.addTerm(createNil(), 0);
       }
     }
   } catch (Throwable jjte000) {
     if (jjtc000) {
       jjtree.clearNodeScope(jjtn000);
       jjtc000 = false;
     } else {
       jjtree.popNode();
     }
     if (jjte000 instanceof RuntimeException) {
       {
         if (true) throw (RuntimeException) jjte000;
       }
     }
     if (jjte000 instanceof ParseException) {
       {
         if (true) throw (ParseException) jjte000;
       }
     }
     {
       if (true) throw (Error) jjte000;
     }
   } finally {
     if (jjtc000) {
       jjtree.closeNodeScope(jjtn000, true);
     }
   }
 }
示例#5
0
 public final void dotAttributeAssignment() throws ParseException {
   /*@bgen(jjtree) dotAttributeAssignment */
   SimpleNode jjtn000 = new SimpleNode(JJTDOTATTRIBUTEASSIGNMENT);
   boolean jjtc000 = true;
   jjtree.openNodeScope(jjtn000);
   Token tkli = null;
   Token tklf = null;
   try {
     id();
     jj_consume_token(EQ);
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case STRING_LITERAL:
       case IDENTIFIER:
         id();
         break;
       case INTEGER_LITERAL:
         tkli = jj_consume_token(INTEGER_LITERAL);
         break;
       case FLOATING_POINT_LITERAL:
         tklf = jj_consume_token(FLOATING_POINT_LITERAL);
         break;
       case LBRACEBRACE:
         dotCompoundRecord();
         break;
       default:
         jj_la1[11] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
     }
     jjtree.closeNodeScope(jjtn000, true);
     jjtc000 = false;
     if (tkli != null) {
       jjtn000.addTerm(createIntegerOrLong(tkli.image), 1);
     } else if (tklf != null) {
       jjtn000.addTerm(createFloatOrDouble(tklf.image), 1);
     }
   } catch (Throwable jjte000) {
     if (jjtc000) {
       jjtree.clearNodeScope(jjtn000);
       jjtc000 = false;
     } else {
       jjtree.popNode();
     }
     if (jjte000 instanceof RuntimeException) {
       {
         if (true) throw (RuntimeException) jjte000;
       }
     }
     if (jjte000 instanceof ParseException) {
       {
         if (true) throw (ParseException) jjte000;
       }
     }
     {
       if (true) throw (Error) jjte000;
     }
   } finally {
     if (jjtc000) {
       jjtree.closeNodeScope(jjtn000, true);
     }
   }
 }
示例#6
0
 public final void dotAttrStmt() throws ParseException {
   /*@bgen(jjtree) dotAttrStmt */
   SimpleNode jjtn000 = new SimpleNode(JJTDOTATTRSTMT);
   boolean jjtc000 = true;
   jjtree.openNodeScope(jjtn000);
   Token tk1 = null;
   Token tk2 = null;
   Token tk3 = null;
   try {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case GRAPH:
         tk1 = jj_consume_token(GRAPH);
         break;
       case NODE:
         tk2 = jj_consume_token(NODE);
         break;
       case EDGE:
         tk3 = jj_consume_token(EDGE);
         break;
       default:
         jj_la1[7] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
     }
     attrList();
     jjtree.closeNodeScope(jjtn000, true);
     jjtc000 = false;
     String kind = null;
     if (tk1 != null) {
       kind = "graph";
     } else if (tk2 != null) {
       kind = "node";
     } else if (tk3 != null) {
       kind = "edge";
     } else {
       {
         if (true) throw new RuntimeException("impossible");
       }
     }
     jjtn000.addTerm(createAtom(kind), 0);
   } catch (Throwable jjte000) {
     if (jjtc000) {
       jjtree.clearNodeScope(jjtn000);
       jjtc000 = false;
     } else {
       jjtree.popNode();
     }
     if (jjte000 instanceof RuntimeException) {
       {
         if (true) throw (RuntimeException) jjte000;
       }
     }
     if (jjte000 instanceof ParseException) {
       {
         if (true) throw (ParseException) jjte000;
       }
     }
     {
       if (true) throw (Error) jjte000;
     }
   } finally {
     if (jjtc000) {
       jjtree.closeNodeScope(jjtn000, true);
     }
   }
 }
示例#7
0
 /*
  * Program structuring syntax follows.
  */
 public final void dotGraph() throws ParseException {
   /*@bgen(jjtree) dotGraph */
   SimpleNode jjtn000 = new SimpleNode(JJTDOTGRAPH);
   boolean jjtc000 = true;
   jjtree.openNodeScope(jjtn000);
   Token tkStrict = null;
   Token tkDigraph = null;
   Token tkGraph = null;
   try {
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case STRICT:
         tkStrict = jj_consume_token(STRICT);
         break;
       default:
         jj_la1[0] = jj_gen;
         ;
     }
     switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
       case DIGRAPH:
         tkDigraph = jj_consume_token(DIGRAPH);
         break;
       case GRAPH:
         tkGraph = jj_consume_token(GRAPH);
         break;
       default:
         jj_la1[1] = jj_gen;
         jj_consume_token(-1);
         throw new ParseException();
     }
     id();
     jj_consume_token(LBRACE);
     dotStmtList();
     jj_consume_token(RBRACE);
     jjtree.closeNodeScope(jjtn000, true);
     jjtc000 = false;
     if (tkStrict != null) {
       jjtn000.addTerm(createBoolean(true), 0);
     } else {
       jjtn000.addTerm(createBoolean(false), 0);
     }
     if (tkDigraph != null) {
       jjtn000.addTerm(createAtom("digraph"), 1);
     } else {
       jjtn000.addTerm(createAtom("graph"), 1);
     }
   } catch (Throwable jjte000) {
     if (jjtc000) {
       jjtree.clearNodeScope(jjtn000);
       jjtc000 = false;
     } else {
       jjtree.popNode();
     }
     if (jjte000 instanceof RuntimeException) {
       {
         if (true) throw (RuntimeException) jjte000;
       }
     }
     if (jjte000 instanceof ParseException) {
       {
         if (true) throw (ParseException) jjte000;
       }
     }
     {
       if (true) throw (Error) jjte000;
     }
   } finally {
     if (jjtc000) {
       jjtree.closeNodeScope(jjtn000, true);
     }
   }
 }
示例#8
0
  protected void compareDeclarations(
      ASTClassOrInterfaceDeclaration aNode, ASTClassOrInterfaceDeclaration bNode) {
    // now the children, below the modifiers in the AST.

    ASTClassOrInterfaceBodyDeclaration[] aDecls = TypeDeclarationUtil.getDeclarations(aNode);
    ASTClassOrInterfaceBodyDeclaration[] bDecls = TypeDeclarationUtil.getDeclarations(bNode);

    // compare declarations in A against B

    if (aDecls.length == 0) {
      if (bDecls.length == 0) {
        // tr.Ace.log("no change (both of zero length)");
      } else {
        addAllDeclarations(bDecls, aNode, true);
      }
    } else if (bDecls.length == 0) {
      addAllDeclarations(aDecls, bNode, false);
    } else {
      MethodUtil methodUtil = new MethodUtil();
      Map matches = TypeDeclarationUtil.matchDeclarations(aDecls, bDecls, methodUtil);
      Iterator sit = matches.keySet().iterator();
      List aSeen = new ArrayList();
      List bSeen = new ArrayList();

      // TimedEvent dte = new TimedEvent("diffs");

      Collection diffs = get();

      while (sit.hasNext()) {
        Double dScore = (Double) sit.next();
        List atScore = (List) matches.get(dScore);

        Iterator vit = atScore.iterator();
        while (vit.hasNext()) {
          Object[] values = (Object[]) vit.next();

          ASTClassOrInterfaceBodyDeclaration aDecl = (ASTClassOrInterfaceBodyDeclaration) values[0];
          ASTClassOrInterfaceBodyDeclaration bDecl = (ASTClassOrInterfaceBodyDeclaration) values[1];

          aSeen.add(aDecl);
          bSeen.add(bDecl);

          dubaj.tr.Ace.log("aDecl", aDecl);
          dubaj.tr.Ace.log("bDecl", bDecl);

          SimpleNode ad = TypeDeclarationUtil.getDeclaration(aDecl);
          SimpleNode bd = TypeDeclarationUtil.getDeclaration(bDecl);

          // TODO: Adiciona Mudanca do Metodo
          // we know that the classes of aDecl and bDecl are the same
          if (ad instanceof ASTMethodDeclaration) {
            MethodDiff differ = new MethodDiff(diffs);

            boolean achouMudanca = false;

            if (differ.compararAcessoMetodo(aDecl, bDecl, Relatorio.TipoDeclaracao.Metodo)) {
              Relatorio.getMudancaClasse().incrementarMudancasMetodo(new MudancaMetodo());
            }

            if (differ.comparar(
                (ASTMethodDeclaration) ad,
                (ASTMethodDeclaration) bd,
                Relatorio.TipoDeclaracao.Metodo)) {}

          } else if (ad instanceof ASTFieldDeclaration) {
            FieldDiff differ = new FieldDiff(diffs);

            if (differ.compararAcessoMetodo(aDecl, bDecl, Relatorio.TipoDeclaracao.Classe)) {
              Relatorio.getMudancaClasse().incrementarMudancasAtributo();
            }

            differ.compare(
                (ASTFieldDeclaration) ad,
                (ASTFieldDeclaration) bd,
                Relatorio.TipoDeclaracao.Classe);
          } else if (ad instanceof ASTConstructorDeclaration) {
            CtorDiff differ = new CtorDiff(diffs);

            boolean achouMudanca = false;

            if (differ.compararAcessoMetodo(aDecl, bDecl, Relatorio.TipoDeclaracao.Construtor)) {
              achouMudanca = true;
            }

            if (differ.comparar(
                (ASTConstructorDeclaration) ad,
                (ASTConstructorDeclaration) bd,
                Relatorio.TipoDeclaracao.Construtor)) {
              achouMudanca = true;
            }

            if (achouMudanca) {

              String nomeAntigo = CtorUtil.getFullName((ASTConstructorDeclaration) ad);
              String nomeNovo = CtorUtil.getFullName((ASTConstructorDeclaration) bd);
            }

          } else if (ad instanceof ASTClassOrInterfaceDeclaration) {
            // access comparison is done in TypeDiff; confusing.
            compare((ASTClassOrInterfaceDeclaration) ad, (ASTClassOrInterfaceDeclaration) bd);
          } else if (ad == null && bd == null) {
            // a match between semicolons.
            dubaj.tr.Ace.log("matched 'semicolon declarations'");
          } else {
            dubaj.tr.Ace.reverse("WTF? aDecl: " + ad.getClass());
          }
        }
      }

      // dte.close();

      addDeclarations(aDecls, aSeen, bNode, false);
      addDeclarations(bDecls, bSeen, aNode, true);
    }
  }