Ejemplo n.º 1
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy n_18) {
   ITermFactory termFactory = context.getFactory();
   context.push("Overlays_1_0");
   Fail56:
   {
     IStrategoTerm u_109 = null;
     IStrategoTerm t_109 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || extraction._consOverlays_1 != ((IStrategoAppl) term).getConstructor()) break Fail56;
     t_109 = term.getSubterm(0);
     IStrategoList annos32 = term.getAnnotations();
     u_109 = annos32;
     term = n_18.invoke(context, t_109);
     if (term == null) break Fail56;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(extraction._consOverlays_1, new IStrategoTerm[] {term}),
             checkListAnnos(termFactory, u_109));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 2
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy q_23) {
   ITermFactory termFactory = context.getFactory();
   context.push("OpDeclInj_1_0");
   Fail144:
   {
     IStrategoTerm s_124 = null;
     IStrategoTerm q_124 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || ext_out._consOpDeclInj_1 != ((IStrategoAppl) term).getConstructor()) break Fail144;
     q_124 = term.getSubterm(0);
     IStrategoList annos114 = term.getAnnotations();
     s_124 = annos114;
     term = q_23.invoke(context, q_124);
     if (term == null) break Fail144;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(ext_out._consOpDeclInj_1, new IStrategoTerm[] {term}),
             checkListAnnos(termFactory, s_124));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 3
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy a_15) {
   ITermFactory termFactory = context.getFactory();
   context.push("ElemValArrayInit_1_0");
   Fail20:
   {
     IStrategoTerm j_100 = null;
     IStrategoTerm i_100 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || renaming._consElemValArrayInit_1 != ((IStrategoAppl) term).getConstructor())
       break Fail20;
     i_100 = term.getSubterm(0);
     IStrategoList annos6 = term.getAnnotations();
     j_100 = annos6;
     term = a_15.invoke(context, i_100);
     if (term == null) break Fail20;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(renaming._consElemValArrayInit_1, new IStrategoTerm[] {term}),
             checkListAnnos(termFactory, j_100));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 4
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy t_27, Strategy u_27) {
   ITermFactory termFactory = context.getFactory();
   context.push("strategy_2_0");
   Fail231:
   {
     IStrategoTerm k_141 = null;
     IStrategoTerm f_141 = null;
     IStrategoTerm g_141 = null;
     IStrategoTerm l_141 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || ext_out._consstrategy_2 != ((IStrategoAppl) term).getConstructor()) break Fail231;
     f_141 = term.getSubterm(0);
     g_141 = term.getSubterm(1);
     IStrategoList annos189 = term.getAnnotations();
     k_141 = annos189;
     term = t_27.invoke(context, f_141);
     if (term == null) break Fail231;
     l_141 = term;
     term = u_27.invoke(context, g_141);
     if (term == null) break Fail231;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(ext_out._consstrategy_2, new IStrategoTerm[] {l_141, term}),
             checkListAnnos(termFactory, k_141));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy x_29) {
   ITermFactory termFactory = context.getFactory();
   context.push("ExtendsInterfaces_1_0");
   Fail76:
   {
     IStrategoTerm x_136 = null;
     IStrategoTerm w_136 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || out._consExtendsInterfaces_1 != ((IStrategoAppl) term).getConstructor()) break Fail76;
     w_136 = term.getSubterm(0);
     IStrategoList annos52 = term.getAnnotations();
     x_136 = annos52;
     term = x_29.invoke(context, w_136);
     if (term == null) break Fail76;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(out._consExtendsInterfaces_1, new IStrategoTerm[] {term}),
             checkListAnnos(termFactory, x_136));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 6
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy m_23, Strategy n_23) {
   ITermFactory termFactory = context.getFactory();
   context.push("ExtOpDeclQ_2_0");
   Fail142:
   {
     IStrategoTerm c_124 = null;
     IStrategoTerm z_123 = null;
     IStrategoTerm b_124 = null;
     IStrategoTerm d_124 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || ext_out._consExtOpDeclQ_2 != ((IStrategoAppl) term).getConstructor()) break Fail142;
     z_123 = term.getSubterm(0);
     b_124 = term.getSubterm(1);
     IStrategoList annos112 = term.getAnnotations();
     c_124 = annos112;
     term = m_23.invoke(context, z_123);
     if (term == null) break Fail142;
     d_124 = term;
     term = n_23.invoke(context, b_124);
     if (term == null) break Fail142;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(ext_out._consExtOpDeclQ_2, new IStrategoTerm[] {d_124, term}),
             checkListAnnos(termFactory, c_124));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 7
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy w_48, Strategy x_48) {
   ITermFactory termFactory = context.getFactory();
   context.push("OpQ_2_0");
   Fail375:
   {
     IStrategoTerm k_198 = null;
     IStrategoTerm i_198 = null;
     IStrategoTerm j_198 = null;
     IStrategoTerm l_198 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || out._consOpQ_2 != ((IStrategoAppl) term).getConstructor()) break Fail375;
     i_198 = term.getSubterm(0);
     j_198 = term.getSubterm(1);
     IStrategoList annos318 = term.getAnnotations();
     k_198 = annos318;
     term = w_48.invoke(context, i_198);
     if (term == null) break Fail375;
     l_198 = term;
     term = x_48.invoke(context, j_198);
     if (term == null) break Fail375;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(out._consOpQ_2, new IStrategoTerm[] {l_198, term}),
             checkListAnnos(termFactory, k_198));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 8
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy e_26, Strategy f_26) {
   ITermFactory termFactory = context.getFactory();
   context.push("range_2_0");
   Fail193:
   {
     IStrategoTerm q_134 = null;
     IStrategoTerm u_133 = null;
     IStrategoTerm x_133 = null;
     IStrategoTerm r_134 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || ext_out._consrange_2 != ((IStrategoAppl) term).getConstructor()) break Fail193;
     u_133 = term.getSubterm(0);
     x_133 = term.getSubterm(1);
     IStrategoList annos161 = term.getAnnotations();
     q_134 = annos161;
     term = e_26.invoke(context, u_133);
     if (term == null) break Fail193;
     r_134 = term;
     term = f_26.invoke(context, x_133);
     if (term == null) break Fail193;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(ext_out._consrange_2, new IStrategoTerm[] {r_134, term}),
             checkListAnnos(termFactory, q_134));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 9
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy p_17, Strategy q_17) {
   ITermFactory termFactory = context.getFactory();
   context.push("SortListTl_2_0");
   Fail121:
   {
     IStrategoTerm l_111 = null;
     IStrategoTerm j_111 = null;
     IStrategoTerm k_111 = null;
     IStrategoTerm m_111 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || out._consSortListTl_2 != ((IStrategoAppl) term).getConstructor()) break Fail121;
     j_111 = term.getSubterm(0);
     k_111 = term.getSubterm(1);
     IStrategoList annos109 = term.getAnnotations();
     l_111 = annos109;
     term = p_17.invoke(context, j_111);
     if (term == null) break Fail121;
     m_111 = term;
     term = q_17.invoke(context, k_111);
     if (term == null) break Fail121;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(out._consSortListTl_2, new IStrategoTerm[] {m_111, term}),
             checkListAnnos(termFactory, l_111));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 10
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy c_21) {
   ITermFactory termFactory = context.getFactory();
   context.push("LRule_1_0");
   Fail88:
   {
     IStrategoTerm v_116 = null;
     IStrategoTerm u_116 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || extraction._consLRule_1 != ((IStrategoAppl) term).getConstructor()) break Fail88;
     u_116 = term.getSubterm(0);
     IStrategoList annos64 = term.getAnnotations();
     v_116 = annos64;
     term = c_21.invoke(context, u_116);
     if (term == null) break Fail88;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(extraction._consLRule_1, new IStrategoTerm[] {term}),
             checkListAnnos(termFactory, v_116));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 11
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy d_28) {
   ITermFactory termFactory = context.getFactory();
   context.push("iter_1_0");
   Fail225:
   {
     IStrategoTerm z_142 = null;
     IStrategoTerm y_142 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || extraction._consiter_1 != ((IStrategoAppl) term).getConstructor()) break Fail225;
     y_142 = term.getSubterm(0);
     IStrategoList annos186 = term.getAnnotations();
     z_142 = annos186;
     term = d_28.invoke(context, y_142);
     if (term == null) break Fail225;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(extraction._consiter_1, new IStrategoTerm[] {term}),
             checkListAnnos(termFactory, z_142));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 12
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy m_18) {
   ITermFactory termFactory = context.getFactory();
   context.push("BuildDefaultPT_1_0");
   Fail139:
   {
     IStrategoTerm a_114 = null;
     IStrategoTerm z_113 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || out._consBuildDefaultPT_1 != ((IStrategoAppl) term).getConstructor()) break Fail139;
     z_113 = term.getSubterm(0);
     IStrategoList annos126 = term.getAnnotations();
     a_114 = annos126;
     term = m_18.invoke(context, z_113);
     if (term == null) break Fail139;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(out._consBuildDefaultPT_1, new IStrategoTerm[] {term}),
             checkListAnnos(termFactory, a_114));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 13
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy s_19) {
   ITermFactory termFactory = context.getFactory();
   context.push("Block_1_0");
   Fail72:
   {
     IStrategoTerm q_112 = null;
     IStrategoTerm p_112 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || renaming._consBlock_1 != ((IStrategoAppl) term).getConstructor()) break Fail72;
     p_112 = term.getSubterm(0);
     IStrategoList annos56 = term.getAnnotations();
     q_112 = annos56;
     term = s_19.invoke(context, p_112);
     if (term == null) break Fail72;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(renaming._consBlock_1, new IStrategoTerm[] {term}),
             checkListAnnos(termFactory, q_112));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 14
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term, Strategy p_18) {
   ITermFactory termFactory = context.getFactory();
   context.push("Signature_1_0");
   Fail58:
   {
     IStrategoTerm a_110 = null;
     IStrategoTerm z_109 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || extraction._consSignature_1 != ((IStrategoAppl) term).getConstructor()) break Fail58;
     z_109 = term.getSubterm(0);
     IStrategoList annos34 = term.getAnnotations();
     a_110 = annos34;
     term = p_18.invoke(context, z_109);
     if (term == null) break Fail58;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(extraction._consSignature_1, new IStrategoTerm[] {term}),
             checkListAnnos(termFactory, a_110));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
 public IStrategoTerm digest(ITermFactory factory, IStrategoTerm... terms) {
   final int prime = 31;
   int result = 1;
   for (IStrategoTerm term : terms) {
     result = result * prime + term.hashCode();
   }
   return factory.makeInt(result);
 }
Ejemplo n.º 16
0
 @Override
 public IStrategoTerm invoke(
     Context context,
     IStrategoTerm term,
     Strategy p_29,
     Strategy q_29,
     Strategy r_29,
     Strategy s_29,
     Strategy t_29) {
   ITermFactory termFactory = context.getFactory();
   context.push("ClassDecHead_5_0");
   Fail73:
   {
     IStrategoTerm f_136 = null;
     IStrategoTerm r_135 = null;
     IStrategoTerm u_135 = null;
     IStrategoTerm y_135 = null;
     IStrategoTerm b_136 = null;
     IStrategoTerm d_136 = null;
     IStrategoTerm h_136 = null;
     IStrategoTerm j_136 = null;
     IStrategoTerm k_136 = null;
     IStrategoTerm l_136 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || out._consClassDecHead_5 != ((IStrategoAppl) term).getConstructor()) break Fail73;
     r_135 = term.getSubterm(0);
     u_135 = term.getSubterm(1);
     y_135 = term.getSubterm(2);
     b_136 = term.getSubterm(3);
     d_136 = term.getSubterm(4);
     IStrategoList annos49 = term.getAnnotations();
     f_136 = annos49;
     term = p_29.invoke(context, r_135);
     if (term == null) break Fail73;
     h_136 = term;
     term = q_29.invoke(context, u_135);
     if (term == null) break Fail73;
     j_136 = term;
     term = r_29.invoke(context, y_135);
     if (term == null) break Fail73;
     k_136 = term;
     term = s_29.invoke(context, b_136);
     if (term == null) break Fail73;
     l_136 = term;
     term = t_29.invoke(context, d_136);
     if (term == null) break Fail73;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(
                 out._consClassDecHead_5, new IStrategoTerm[] {h_136, j_136, k_136, l_136, term}),
             checkListAnnos(termFactory, f_136));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
 @Override
 public L_A_Seq fromStrategoTerm(IStrategoTerm alist) {
   L_A_Seq list = new L_A_Seq(NodeSource.fromStrategoTerm(alist));
   for (int l = alist.getSubtermCount() - 1; l >= 0; l--) {
     final INodeSource source = NodeSource.fromStrategoTerm(alist.getSubterm(l));
     list =
         new L_A_Seq(
             NodeSource.fromStrategoTerm(alist),
             new Generic_A_Seq(source, alist.getSubterm(l)),
             list);
   }
   return list;
 }
Ejemplo n.º 18
0
  private boolean makeAppl(IContext env, IStrategoString nameTerm, IStrategoTerm argsTerm) {
    if (argsTerm.getTermType() != IStrategoTerm.LIST) return false;

    String name = nameTerm.stringValue();
    for (int i = 0; i < name.length(); i++) {
      char c = name.charAt(i);
      if (!(Character.isLetterOrDigit(c)
          || c == '_'
          || c == '-'
          || c == '+'
          || c == '*'
          || c == '$')) {
        name = name.substring(0, i);
        break;
      }
    }

    IStrategoList args = (IStrategoList) argsTerm;

    if (name.length() == 0) { // tuple
      env.setCurrent(env.getFactory().makeTuple(args.getAllSubterms()));
    } else {
      IStrategoConstructor cons = env.getFactory().makeConstructor(name, args.size());
      env.setCurrent(env.getFactory().makeAppl(cons, args.getAllSubterms()));
    }
    return true;
  }
Ejemplo n.º 19
0
 @Override
 public IStrategoTerm invoke(Context context, IStrategoTerm term) {
   Fail131:
   {
     if (term.getTermType() != IStrategoTerm.APPL
         || out._consEmpty_0 != ((IStrategoAppl) term).getConstructor()) break Fail131;
     if (true) return term;
   }
   context.push("Empty_0_0");
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 20
0
 @Override
 public IStrategoTerm invoke(
     Context context, IStrategoTerm term, Strategy x_19, Strategy y_19, Strategy z_19) {
   ITermFactory termFactory = context.getFactory();
   context.push("DynRuleIntersect_3_0");
   Fail85:
   {
     IStrategoTerm y_113 = null;
     IStrategoTerm v_113 = null;
     IStrategoTerm w_113 = null;
     IStrategoTerm x_113 = null;
     IStrategoTerm z_113 = null;
     IStrategoTerm a_114 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || ext_out._consDynRuleIntersect_3 != ((IStrategoAppl) term).getConstructor())
       break Fail85;
     v_113 = term.getSubterm(0);
     w_113 = term.getSubterm(1);
     x_113 = term.getSubterm(2);
     IStrategoList annos58 = term.getAnnotations();
     y_113 = annos58;
     term = x_19.invoke(context, v_113);
     if (term == null) break Fail85;
     z_113 = term;
     term = y_19.invoke(context, w_113);
     if (term == null) break Fail85;
     a_114 = term;
     term = z_19.invoke(context, x_113);
     if (term == null) break Fail85;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(
                 ext_out._consDynRuleIntersect_3, new IStrategoTerm[] {z_113, a_114, term}),
             checkListAnnos(termFactory, y_113));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 21
0
 @Override
 public IStrategoTerm invoke(
     Context context, IStrategoTerm term, Strategy j_16, Strategy k_16, Strategy l_16) {
   ITermFactory termFactory = context.getFactory();
   context.push("GuardedLChoice_3_0");
   Fail101:
   {
     IStrategoTerm z_107 = null;
     IStrategoTerm w_107 = null;
     IStrategoTerm x_107 = null;
     IStrategoTerm y_107 = null;
     IStrategoTerm a_108 = null;
     IStrategoTerm b_108 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || out._consGuardedLChoice_3 != ((IStrategoAppl) term).getConstructor()) break Fail101;
     w_107 = term.getSubterm(0);
     x_107 = term.getSubterm(1);
     y_107 = term.getSubterm(2);
     IStrategoList annos91 = term.getAnnotations();
     z_107 = annos91;
     term = j_16.invoke(context, w_107);
     if (term == null) break Fail101;
     a_108 = term;
     term = k_16.invoke(context, x_107);
     if (term == null) break Fail101;
     b_108 = term;
     term = l_16.invoke(context, y_107);
     if (term == null) break Fail101;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(
                 out._consGuardedLChoice_3, new IStrategoTerm[] {a_108, b_108, term}),
             checkListAnnos(termFactory, z_107));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 22
0
 @Override
 public IStrategoTerm invoke(
     Context context, IStrategoTerm term, Strategy z_18, Strategy a_19, Strategy b_19) {
   ITermFactory termFactory = context.getFactory();
   context.push("Param_3_0");
   Fail66:
   {
     IStrategoTerm s_110 = null;
     IStrategoTerm p_110 = null;
     IStrategoTerm q_110 = null;
     IStrategoTerm r_110 = null;
     IStrategoTerm t_110 = null;
     IStrategoTerm u_110 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || renaming._consParam_3 != ((IStrategoAppl) term).getConstructor()) break Fail66;
     p_110 = term.getSubterm(0);
     q_110 = term.getSubterm(1);
     r_110 = term.getSubterm(2);
     IStrategoList annos51 = term.getAnnotations();
     s_110 = annos51;
     term = z_18.invoke(context, p_110);
     if (term == null) break Fail66;
     t_110 = term;
     term = a_19.invoke(context, q_110);
     if (term == null) break Fail66;
     u_110 = term;
     term = b_19.invoke(context, r_110);
     if (term == null) break Fail66;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(renaming._consParam_3, new IStrategoTerm[] {t_110, u_110, term}),
             checkListAnnos(termFactory, s_110));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
 public IStrategoTerm invoke(
     Context context,
     IStrategoTerm term,
     Strategy c_17,
     Strategy d_17,
     Strategy e_17,
     Strategy f_17,
     Strategy g_17,
     Strategy h_17,
     Strategy i_17) {
   ITermFactory termFactory = context.getFactory();
   context.push("DeprAbstractMethodDec_7_0");
   Fail47:
   {
     IStrategoTerm b_106 = null;
     IStrategoTerm t_105 = null;
     IStrategoTerm u_105 = null;
     IStrategoTerm v_105 = null;
     IStrategoTerm w_105 = null;
     IStrategoTerm x_105 = null;
     IStrategoTerm y_105 = null;
     IStrategoTerm z_105 = null;
     IStrategoTerm c_106 = null;
     IStrategoTerm d_106 = null;
     IStrategoTerm e_106 = null;
     IStrategoTerm f_106 = null;
     IStrategoTerm g_106 = null;
     IStrategoTerm h_106 = null;
     if (term.getTermType() != IStrategoTerm.APPL
         || renaming._consDeprAbstractMethodDec_7 != ((IStrategoAppl) term).getConstructor())
       break Fail47;
     t_105 = term.getSubterm(0);
     u_105 = term.getSubterm(1);
     v_105 = term.getSubterm(2);
     w_105 = term.getSubterm(3);
     x_105 = term.getSubterm(4);
     y_105 = term.getSubterm(5);
     z_105 = term.getSubterm(6);
     IStrategoList annos33 = term.getAnnotations();
     b_106 = annos33;
     term = c_17.invoke(context, t_105);
     if (term == null) break Fail47;
     c_106 = term;
     term = d_17.invoke(context, u_105);
     if (term == null) break Fail47;
     d_106 = term;
     term = e_17.invoke(context, v_105);
     if (term == null) break Fail47;
     e_106 = term;
     term = f_17.invoke(context, w_105);
     if (term == null) break Fail47;
     f_106 = term;
     term = g_17.invoke(context, x_105);
     if (term == null) break Fail47;
     g_106 = term;
     term = h_17.invoke(context, y_105);
     if (term == null) break Fail47;
     h_106 = term;
     term = i_17.invoke(context, z_105);
     if (term == null) break Fail47;
     term =
         termFactory.annotateTerm(
             termFactory.makeAppl(
                 renaming._consDeprAbstractMethodDec_7,
                 new IStrategoTerm[] {c_106, d_106, e_106, f_106, g_106, h_106, term}),
             checkListAnnos(termFactory, b_106));
     context.popOnSuccess();
     if (true) return term;
   }
   context.popOnFailure();
   return null;
 }
Ejemplo n.º 24
0
  /**
   * Check if two terms are similar. Meaning they have the same constructor, and the children are
   * located in the same places.
   *
   * @param t1 - first term.
   * @param t2 - second term.
   * @param context - the context in which to compare them.
   * @return - true if the terms are similar, false otherwise.
   */
  private boolean isSimilar(IStrategoTerm t1, IStrategoTerm t2, Context context) {
    if (t1.getTermType() != t2.getTermType()) return false;

    if (t1.getTermType() == IStrategoTerm.APPL)
      if (!((IStrategoAppl) t1).getName().equals(((IStrategoAppl) t2).getName())) return false;
    if (t1.getTermType() == IStrategoTerm.STRING)
      if (!((IStrategoString) t1).stringValue().equals(((IStrategoString) t2).stringValue()))
        return false;
    if (t1.getTermType() == IStrategoTerm.INT)
      if (((IStrategoInt) t1).intValue() != ((IStrategoInt) t2).intValue()) return false;

    for (int i = 0; i < t1.getSubtermCount(); i++) {
      IStrategoTerm ch1 = t1.getSubterm(i);
      IStrategoTerm ch2 = t2.getSubterm(i);
      IStrategoTerm loc1 = ch1.getAnnotations();
      IStrategoTerm loc2 = ch2.getAnnotations();

      if (loc1 == null) context.getIOAgent().printError("Error1: " + ch1);
      if (loc2 == null) context.getIOAgent().printError("Error2: " + ch2);

      if (!loc1.toString().equals(loc2.toString())) return false;
    }
    return true;
  }
Ejemplo n.º 25
0
  /**
   * Restructure a node from: [A(x1, x2 ... xn), A(y1, y2 ... yn), A ..., B] to : [A(amb([x1, y1,
   * ...]), amb([x2, y2, ...]), ... amb([xn, yn, ...])), B]
   *
   * <p>if the children of every A are located in the same places (see isSimilar(...)).
   */
  @Override
  public IStrategoTerm invoke(Context context, IStrategoTerm currentList) {
    context.push("mergeamb_0_0");

    java.util.List<IStrategoTerm> children = new ArrayList<IStrategoTerm>();
    // IStrategoTerm currentList = amb.getSubterm(0);
    for (int i = 0; i < currentList.getSubtermCount(); i++)
      children.add((IStrategoTerm) currentList.getSubterm(i));

    java.util.List<IStrategoTerm> newchildren = new ArrayList<IStrategoTerm>();

    // while there are still children that haven't been processed
    while (!children.isEmpty()) {
      // group the similar children
      IStrategoTerm head = children.get(0);
      java.util.List<IStrategoTerm> similar = new ArrayList<IStrategoTerm>();
      similar.add(head);
      for (int i = 1; i < children.size(); i++) {
        if (isSimilar(head, children.get(i), context)) {
          similar.add(children.get(i));
        }
      }

      // remove the grouped nodes from the children list
      children.removeAll(similar);

      // context.getIOAgent().printError(similar.size() + "=" + head);

      // create a new node that combines the children in new ambiguity nodes
      if (similar.size() > 1) {
        java.util.List<IStrategoTerm> termList = new ArrayList<IStrategoTerm>();

        for (int i = 0; i < head.getSubtermCount(); i++) {
          IStrategoConstructor ambc = context.getFactory().makeConstructor("amb", 1);

          java.util.List<IStrategoTerm> list2 = new ArrayList<IStrategoTerm>();
          for (int j = 0; j < similar.size(); j++) list2.add(similar.get(j).getSubterm(i));

          IStrategoList ambl = context.getFactory().makeList(list2);
          IStrategoAppl ambappl = context.getFactory().makeAppl(ambc, ambl);
          ambappl =
              (IStrategoAppl)
                  context.getFactory().annotateTerm(ambappl, head.getSubterm(i).getAnnotations());

          termList.add(ambappl);
        }
        IStrategoConstructor newtermConstr = ((IStrategoAppl) head).getConstructor();
        IStrategoList newtermList = context.getFactory().makeList(termList);
        IStrategoAppl newtermAppl =
            context.getFactory().makeAppl(newtermConstr, newtermList.getAllSubterms(), null);
        newtermAppl =
            (IStrategoAppl) context.getFactory().annotateTerm(newtermAppl, head.getAnnotations());
        newchildren.add(newtermAppl);
      } else {
        // if there is only one child, just add it to the new list
        newchildren.add(similar.get(0));
      }
    }

    IStrategoList ambl = context.getFactory().makeList(newchildren);

    context.popOnSuccess();
    return ambl;
  }