Exemplo n.º 1
0
 public Predicate exec(Prolog engine) {
   // '$dcg_connect'(A,(B->C),D,((B->C),D)):-!
   Term a1, a2, a3, a4, a5, a6, a7;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   a3 = engine.aregs[3];
   a4 = engine.aregs[4];
   cont = engine.cont;
   // '$dcg_connect'(A,(B->C),D,((B->C),D)):-['$neck_cut']
   a2 = a2.dereference();
   if (a2.isStructure()) {
     if (!s1.equals(((StructureTerm) a2).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a2).args();
     a5 = args[0];
     a6 = args[1];
   } else if (a2.isVariable()) {
     a5 = new VariableTerm(engine);
     a6 = new VariableTerm(engine);
     Term[] args = {a5, a6};
     ((VariableTerm) a2).bind(new StructureTerm(s1, args), engine.trail);
   } else {
     return engine.fail();
   }
   a4 = a4.dereference();
   if (a4.isStructure()) {
     if (!s2.equals(((StructureTerm) a4).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a4).args();
     a7 = args[0];
     if (!a3.unify(args[1], engine.trail)) return engine.fail();
   } else if (a4.isVariable()) {
     a7 = new VariableTerm(engine);
     Term[] args = {a7, a3};
     ((VariableTerm) a4).bind(new StructureTerm(s2, args), engine.trail);
   } else {
     return engine.fail();
   }
   a7 = a7.dereference();
   if (a7.isStructure()) {
     if (!s1.equals(((StructureTerm) a7).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a7).args();
     if (!a5.unify(args[0], engine.trail)) return engine.fail();
     if (!a6.unify(args[1], engine.trail)) return engine.fail();
   } else if (a7.isVariable()) {
     Term[] args = {a5, a6};
     ((VariableTerm) a7).bind(new StructureTerm(s1, args), engine.trail);
   } else {
     return engine.fail();
   }
   // START inline expansion of $neck_cut
   engine.neckCut();
   // END inline expansion
   return cont;
 }
Exemplo n.º 2
0
 public Predicate exec(Prolog engine) {
   // '$dcg_connect'((A->B),(C->D),E,(C->F)):-!,'$dcg_and'(D,E,F)
   Term a1, a2, a3, a4, a5, a6, a7;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   a3 = engine.aregs[3];
   a4 = engine.aregs[4];
   cont = engine.cont;
   // '$dcg_connect'((A->B),(C->D),E,(C->F)):-['$neck_cut','$dcg_and'(D,E,F)]
   a1 = a1.dereference();
   if (a1.isStructure()) {
     if (!s1.equals(((StructureTerm) a1).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a1).args();
   } else if (a1.isVariable()) {
     Term[] args = {new VariableTerm(engine), new VariableTerm(engine)};
     ((VariableTerm) a1).bind(new StructureTerm(s1, args), engine.trail);
   } else {
     return engine.fail();
   }
   a2 = a2.dereference();
   if (a2.isStructure()) {
     if (!s1.equals(((StructureTerm) a2).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a2).args();
     a5 = args[0];
     a6 = args[1];
   } else if (a2.isVariable()) {
     a5 = new VariableTerm(engine);
     a6 = new VariableTerm(engine);
     Term[] args = {a5, a6};
     ((VariableTerm) a2).bind(new StructureTerm(s1, args), engine.trail);
   } else {
     return engine.fail();
   }
   a4 = a4.dereference();
   if (a4.isStructure()) {
     if (!s1.equals(((StructureTerm) a4).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a4).args();
     if (!a5.unify(args[0], engine.trail)) return engine.fail();
     a7 = args[1];
   } else if (a4.isVariable()) {
     a7 = new VariableTerm(engine);
     Term[] args = {a5, a7};
     ((VariableTerm) a4).bind(new StructureTerm(s1, args), engine.trail);
   } else {
     return engine.fail();
   }
   // START inline expansion of $neck_cut
   engine.neckCut();
   // END inline expansion
   return new PRED_$dcg_and_3(a6, a3, a7, cont);
 }
Exemplo n.º 3
0
 public Predicate exec(Prolog engine) {
   // '$variants_subset'([],A,[],[],[]):-!
   Term a1, a2, a3, a4, a5;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   a3 = engine.aregs[3];
   a4 = engine.aregs[4];
   a5 = engine.aregs[5];
   cont = engine.cont;
   // '$variants_subset'([],A,[],[],[]):-['$neck_cut']
   a1 = a1.dereference();
   if (a1.isSymbol()) {
     if (!a1.equals(s1)) return engine.fail();
   } else if (a1.isVariable()) {
     ((VariableTerm) a1).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   a3 = a3.dereference();
   if (a3.isSymbol()) {
     if (!a3.equals(s1)) return engine.fail();
   } else if (a3.isVariable()) {
     ((VariableTerm) a3).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   a4 = a4.dereference();
   if (a4.isSymbol()) {
     if (!a4.equals(s1)) return engine.fail();
   } else if (a4.isVariable()) {
     ((VariableTerm) a4).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   a5 = a5.dereference();
   if (a5.isSymbol()) {
     if (!a5.equals(s1)) return engine.fail();
   } else if (a5.isVariable()) {
     ((VariableTerm) a5).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   // START inline expansion of $neck_cut
   engine.neckCut();
   // END inline expansion
   return cont;
 }
Exemplo n.º 4
0
 public Predicate exec(Prolog engine) {
   // '$set_prolog_flag0'(no,A,B,C):-!,illarg(permission(modify,flag,A,D),set_prolog_flag(A,B),E)
   Term a1, a2, a3, a4, a5, a6;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   a3 = engine.aregs[3];
   a4 = engine.aregs[4];
   cont = engine.cont;
   // '$set_prolog_flag0'(no,A,B,C):-['$neck_cut',illarg(permission(modify,flag,A,D),set_prolog_flag(A,B),E)]
   a1 = a1.dereference();
   if (a1.isSymbol()) {
     if (!a1.equals(s1)) return engine.fail();
   } else if (a1.isVariable()) {
     ((VariableTerm) a1).bind(s1, engine.trail);
   } else {
     return engine.fail();
   }
   // START inline expansion of $neck_cut
   engine.neckCut();
   // END inline expansion
   Term[] y1 = {s3, s4, a2, new VariableTerm(engine)};
   a5 = new StructureTerm(s2, y1);
   Term[] y2 = {a2, a3};
   a6 = new StructureTerm(s5, y2);
   return new PRED_illarg_3(a5, a6, new VariableTerm(engine), cont);
 }
Exemplo n.º 5
0
 public Predicate exec(Prolog engine) {
   // '$variants_subset'([A|B],C,D,E,[A|F]):-'$variants_subset'(B,C,D,E,F)
   Term a1, a2, a3, a4, a5, a6, a7, a8;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   a3 = engine.aregs[3];
   a4 = engine.aregs[4];
   a5 = engine.aregs[5];
   cont = engine.cont;
   // '$variants_subset'([A|B],C,D,E,[A|F]):-['$variants_subset'(B,C,D,E,F)]
   a1 = a1.dereference();
   if (a1.isList()) {
     Term[] args = {((ListTerm) a1).car(), ((ListTerm) a1).cdr()};
     a6 = args[0];
     a7 = args[1];
   } else if (a1.isVariable()) {
     a6 = new VariableTerm(engine);
     a7 = new VariableTerm(engine);
     ((VariableTerm) a1).bind(new ListTerm(a6, a7), engine.trail);
   } else {
     return engine.fail();
   }
   a5 = a5.dereference();
   if (a5.isList()) {
     Term[] args = {((ListTerm) a5).car(), ((ListTerm) a5).cdr()};
     if (!a6.unify(args[0], engine.trail)) return engine.fail();
     a8 = args[1];
   } else if (a5.isVariable()) {
     a8 = new VariableTerm(engine);
     ((VariableTerm) a5).bind(new ListTerm(a6, a8), engine.trail);
   } else {
     return engine.fail();
   }
   engine.aregs[1] = a7;
   engine.aregs[2] = a2;
   engine.aregs[3] = a3;
   engine.aregs[4] = a4;
   engine.aregs[5] = a8;
   engine.cont = cont;
   return _$variants_subset_5_top;
 }
Exemplo n.º 6
0
 public Predicate exec(Prolog engine) {
   // '$mem_pair'(A,[B|C]):-'$mem_pair'(A,C)
   Term a1, a2, a3;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   cont = engine.cont;
   // '$mem_pair'(A,[B|C]):-['$mem_pair'(A,C)]
   a2 = a2.dereference();
   if (a2.isList()) {
     Term[] args = {((ListTerm) a2).car(), ((ListTerm) a2).cdr()};
     a3 = args[1];
   } else if (a2.isVariable()) {
     a3 = new VariableTerm(engine);
     ((VariableTerm) a2).bind(new ListTerm(new VariableTerm(engine), a3), engine.trail);
   } else {
     return engine.fail();
   }
   engine.aregs[1] = a1;
   engine.aregs[2] = a3;
   engine.cont = cont;
   return _$mem_pair_2_top;
 }
Exemplo n.º 7
0
 public Predicate exec(Prolog engine) {
   // '$mem_pair'(A=B,[C=D|E]):-A==C,!,B=D
   Term a1, a2, a3, a4, a5, a6, a7, a8;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   cont = engine.cont;
   // '$mem_pair'(A=B,[C=D|E]):-['$get_level'(F),'$equality_of_term'(A,C),'$cut'(F),'$unify'(B,D)]
   a1 = a1.dereference();
   if (a1.isStructure()) {
     if (!s1.equals(((StructureTerm) a1).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a1).args();
     a3 = args[0];
     a4 = args[1];
   } else if (a1.isVariable()) {
     a3 = new VariableTerm(engine);
     a4 = new VariableTerm(engine);
     Term[] args = {a3, a4};
     ((VariableTerm) a1).bind(new StructureTerm(s1, args), engine.trail);
   } else {
     return engine.fail();
   }
   a2 = a2.dereference();
   if (a2.isList()) {
     Term[] args = {((ListTerm) a2).car(), ((ListTerm) a2).cdr()};
     a5 = args[0];
   } else if (a2.isVariable()) {
     a5 = new VariableTerm(engine);
     ((VariableTerm) a2).bind(new ListTerm(a5, new VariableTerm(engine)), engine.trail);
   } else {
     return engine.fail();
   }
   a5 = a5.dereference();
   if (a5.isStructure()) {
     if (!s1.equals(((StructureTerm) a5).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a5).args();
     a6 = args[0];
     a7 = args[1];
   } else if (a5.isVariable()) {
     a6 = new VariableTerm(engine);
     a7 = new VariableTerm(engine);
     Term[] args = {a6, a7};
     ((VariableTerm) a5).bind(new StructureTerm(s1, args), engine.trail);
   } else {
     return engine.fail();
   }
   a8 = new VariableTerm(engine);
   // START inline expansion of $get_level(a(8))
   if (!a8.unify(new IntegerTerm(engine.B0), engine.trail)) {
     return engine.fail();
   }
   // END inline expansion
   // START inline expansion of $equality_of_term(a(3),a(6))
   a3 = a3.dereference();
   a6 = a6.dereference();
   if (!a3.equals(a6)) {
     return engine.fail();
   }
   // END inline expansion
   // START inline expansion of $cut(a(8))
   a8 = a8.dereference();
   if (!a8.isInteger()) {
     throw new IllegalTypeException("integer", a8);
   } else {
     engine.cut(((IntegerTerm) a8).intValue());
   }
   // END inline expansion
   // START inline expansion of $unify(a(4),a(7))
   if (!a4.unify(a7, engine.trail)) {
     return engine.fail();
   }
   // END inline expansion
   return cont;
 }
Exemplo n.º 8
0
 public Predicate exec(Prolog engine) {
   // '$variants_subset'([A+B|C],D,[A+B|E],[B|F],G):-'$term_variant'(D,A),!,'$variants_subset'(C,D,E,F,G)
   Term a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13;
   Predicate p1, p2;
   Predicate cont;
   a1 = engine.aregs[1];
   a2 = engine.aregs[2];
   a3 = engine.aregs[3];
   a4 = engine.aregs[4];
   a5 = engine.aregs[5];
   cont = engine.cont;
   // '$variants_subset'([A+B|C],D,[A+B|E],[B|F],G):-['$get_level'(H),'$term_variant'(D,A),'$cut'(H),'$variants_subset'(C,D,E,F,G)]
   a1 = a1.dereference();
   if (a1.isList()) {
     Term[] args = {((ListTerm) a1).car(), ((ListTerm) a1).cdr()};
     a6 = args[0];
     a7 = args[1];
   } else if (a1.isVariable()) {
     a6 = new VariableTerm(engine);
     a7 = new VariableTerm(engine);
     ((VariableTerm) a1).bind(new ListTerm(a6, a7), engine.trail);
   } else {
     return engine.fail();
   }
   a6 = a6.dereference();
   if (a6.isStructure()) {
     if (!s2.equals(((StructureTerm) a6).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a6).args();
     a8 = args[0];
     a9 = args[1];
   } else if (a6.isVariable()) {
     a8 = new VariableTerm(engine);
     a9 = new VariableTerm(engine);
     Term[] args = {a8, a9};
     ((VariableTerm) a6).bind(new StructureTerm(s2, args), engine.trail);
   } else {
     return engine.fail();
   }
   a3 = a3.dereference();
   if (a3.isList()) {
     Term[] args = {((ListTerm) a3).car(), ((ListTerm) a3).cdr()};
     a10 = args[0];
     a11 = args[1];
   } else if (a3.isVariable()) {
     a10 = new VariableTerm(engine);
     a11 = new VariableTerm(engine);
     ((VariableTerm) a3).bind(new ListTerm(a10, a11), engine.trail);
   } else {
     return engine.fail();
   }
   a10 = a10.dereference();
   if (a10.isStructure()) {
     if (!s2.equals(((StructureTerm) a10).functor())) return engine.fail();
     Term[] args = ((StructureTerm) a10).args();
     if (!a8.unify(args[0], engine.trail)) return engine.fail();
     if (!a9.unify(args[1], engine.trail)) return engine.fail();
   } else if (a10.isVariable()) {
     Term[] args = {a8, a9};
     ((VariableTerm) a10).bind(new StructureTerm(s2, args), engine.trail);
   } else {
     return engine.fail();
   }
   a4 = a4.dereference();
   if (a4.isList()) {
     Term[] args = {((ListTerm) a4).car(), ((ListTerm) a4).cdr()};
     if (!a9.unify(args[0], engine.trail)) return engine.fail();
     a12 = args[1];
   } else if (a4.isVariable()) {
     a12 = new VariableTerm(engine);
     ((VariableTerm) a4).bind(new ListTerm(a9, a12), engine.trail);
   } else {
     return engine.fail();
   }
   a13 = new VariableTerm(engine);
   // START inline expansion of $get_level(a(13))
   if (!a13.unify(new IntegerTerm(engine.B0), engine.trail)) {
     return engine.fail();
   }
   // END inline expansion
   p1 = new PRED_$variants_subset_5(a7, a2, a11, a12, a5, cont);
   p2 = new PRED_$cut_1(a13, p1);
   return new PRED_$term_variant_2(a2, a8, p2);
 }