Esempio n. 1
0
 public static Term getTerm(Production prod, org.kframework.kil.loader.Context context) {
   if (prod.isSubsort()) {
     final Variable freshVar = Variable.getFreshVar(prod.getItems().get(0).toString());
     if (prod.containsAttribute("klabel")) {
       return KApp.of(KLabelConstant.of(prod.getKLabel(), context), freshVar);
     }
     return freshVar;
   }
   if (prod.isConstant()) {
     String terminal = ((Terminal) prod.getItems().get(0)).getTerminal();
     if (prod.getSort().equals(KSorts.KLABEL)) {
       return KLabelConstant.of(terminal, context);
     } else if (prod.getSort().equals(BoolBuiltin.SORT_NAME)) {
       return BoolBuiltin.kAppOf(terminal);
     } else if (prod.getSort().equals(IntBuiltin.SORT_NAME)) {
       return IntBuiltin.kAppOf(terminal);
     } else if (prod.getSort().equals(StringBuiltin.SORT_NAME)) {
       return StringBuiltin.kAppOf(terminal);
     } else {
       return GenericToken.kAppOf(prod.getSort(), terminal);
     }
   }
   if (prod.isLexical()) {
     return KApp.of(
         KLabelConstant.of("#token", context),
         StringBuiltin.kAppOf(prod.getSort()),
         Variable.getFreshVar("String"));
   }
   TermCons t = new TermCons(prod.getSort(), prod.getCons(), context);
   if (prod.isListDecl()) {
     t.getContents().add(Variable.getFreshVar(((UserList) prod.getItems().get(0)).getSort()));
     t.getContents().add(Variable.getFreshVar(prod.getSort()));
     return t;
   }
   for (ProductionItem item : prod.getItems()) {
     if (item instanceof Sort) {
       t.getContents().add(Variable.getFreshVar(((Sort) item).getName()));
     }
   }
   return t;
 }
Esempio n. 2
0
 public Term freshSymSortN(String sort, int n) {
   return KApp.of(
       KLabelConstant.of("'#freshSymSortN", context),
       StringBuiltin.kAppOf(sort),
       IntBuiltin.kAppOf(n));
 }
Esempio n. 3
0
 @Override
 public Void visit(IntBuiltin intBuiltin, Void _void) {
   counter = counter.max(intBuiltin.bigIntegerValue());
   return null;
 }