Esempio n. 1
0
 public static int makestring(String a, Token b) {
   char[] temp = new char[a.length()];
   temp = a.toCharArray();
   int i = 1;
   if (temp[0] == '\'') {
     while (Character.isLetter(temp[i])
         || Character.isDigit(temp[i])
         || isoperator(temp[i])
         || ispunc(temp[i])
         || Character.isWhitespace(temp[i])) {
       i++;
       if (temp[i - 1] == '\'') {
         setToken(b, i - 2, a.substring(1, i - 1), LexToInt.string);
         return i;
       }
       if (i == a.length()) {
         break;
       }
     }
     if (temp[i - 1] == '\'') {
       setToken(b, i - 2, a.substring(1, i - 1), LexToInt.string);
       return i;
     }
   }
   return -1;
 }
Esempio n. 2
0
 public static int makeint(String a, Token b) {
   char[] temp = new char[a.length()];
   temp = a.toCharArray();
   int i = 0;
   if (Character.isDigit(temp[i])) {
     while (Character.isDigit(temp[i])) {
       i++;
       if (i == a.length()) {
         break;
       }
     }
     setToken(b, i, a.substring(0, i), LexToInt.integer);
     return i;
   }
   return -1;
 }
Esempio n. 3
0
 public static int makeIdentifier(String a, Token b) {
   final char under = '_';
   char[] temp = new char[a.length()];
   temp = a.toCharArray();
   int i = 0;
   if (Character.isLetter(temp[i])) {
     while (Character.isLetter(temp[i]) || Character.isDigit(temp[i]) || temp[i] == under) {
       i++;
       if (i == a.length()) {
         break;
       }
     }
     setToken(b, i, a.substring(0, i), LexToInt.identifier);
     detailID(b);
     return i;
   }
   return -1;
 }
Esempio n. 4
0
 public static int makespace(String a, Token b) {
   char[] temp = new char[a.length()];
   temp = a.toCharArray();
   int i = 0;
   if (a.isEmpty()) {
     setToken(b, a.length(), "\n", LexToInt.delete);
     return a.length();
   }
   if (Character.isWhitespace(temp[i])) {
     while (Character.isWhitespace(temp[i])) {
       i++;
       if (i == a.length()) {
         break;
       }
     }
     setToken(b, i, a.substring(0, i), LexToInt.delete);
     return i;
   }
   return -1;
 }