Ejemplo n.º 1
0
 Term createDoubleOrFloat(String x) {
   Term retval = null;
   if (x.endsWith("F") || x.endsWith("f")) {
     retval =
         TermWare.getInstance()
             .getTermFactory()
             .createFloat(Float.valueOf(x.substring(0, x.length() - 1)));
   } else {
     retval = TermWare.getInstance().getTermFactory().createDouble(Double.valueOf(x));
   }
   return retval;
 }
Ejemplo n.º 2
0
 Term createIntegerOrLong(String x) throws ParseException {
   try {
     Term retval = null;
     if (x.endsWith("L") || x.endsWith("l")) {
       try {
         retval =
             TermWare.getInstance()
                 .getTermFactory()
                 .createLong(Long.decode(x.substring(0, x.length() - 1)));
       } catch (NumberFormatException ex) {
         // it can be just too big, becouse literals can be unsigned, while decode does not handle
         // unsogned,
         //  bigger then MAX
         // Here we will handle one case, which exists in JDK sources. (java/lang/Long.java)
         if (x.length() > 2) {
           char last = x.charAt(x.length() - 2);
           long l = Long.decode(x.substring(0, x.length() - 2));
           char x0 = x.charAt(0);
           char x1 = x.charAt(1);
           if (x0 == '0') {
             if (x1 == 'x' || x1 == 'X') {
               // hex
               int l1 = Character.digit(last, 16);
               l = ((l << 8) + l1);
             } else {
               // oct
               int l1 = Character.digit(last, 8);
               l = ((l << 4) + l1);
             }
           }
           retval = TermWare.getInstance().getTermFactory().createLong(l);
         } else {
           throw ex;
         }
       }
     } else {
       long l = Long.decode(x);
       retval = TermWare.getInstance().getTermFactory().createInt((int) l);
     }
     return retval;
   } catch (NumberFormatException ex) {
     throw new ParseException(
         "Can't read IntegerLiteral "
             + ex.getMessage()
             + "(s="
             + x
             + ") "
             + " in file "
             + inFname);
   }
 }
Ejemplo n.º 3
0
 Term cons(Term x1, Term x2) {
   try {
     return TermWare.getInstance().getTermFactory().createTerm("cons", x1, x2);
   } catch (TermWareException ex) {
     throw new TermWareRuntimeException(ex);
   }
 }
Ejemplo n.º 4
0
 Term createInt(int x) {
   return TermWare.getInstance().getTermFactory().createInt(x);
 }
Ejemplo n.º 5
0
 Term createNil() {
   return TermWare.getInstance().getTermFactory().createNil();
 }
Ejemplo n.º 6
0
 Term createAtom(String name) {
   return TermWare.getInstance().getTermFactory().createAtom(name);
 }
Ejemplo n.º 7
0
 Term createTerm(String name, Term x1, Term x2) throws TermWareException {
   return TermWare.getInstance().getTermFactory().createTerm(name, x1, x2);
 }
Ejemplo n.º 8
0
 Term createBoolean(boolean x) {
   return TermWare.getInstance().getTermFactory().createBoolean(x);
 }
Ejemplo n.º 9
0
 Term createString(String x) {
   return TermWare.getInstance().getTermFactory().createString(x);
 }
Ejemplo n.º 10
0
 Term createChar(char x) {
   return TermWare.getInstance().getTermFactory().createChar(x);
 }