Beispiel #1
0
 private static void handleToken(ParsedToken p) {
   if (p == null) {
     System.out.println("Empty AST");
     return;
   }
   switch (p.getTokenType()) {
     case NONE:
       out("NONE token type");
       break;
     case BYTES:
       out("BYTES token type, value: " + Arrays.toString(p.getBytesValue()));
       break;
     case SINT:
       out("SINT token type, value: " + p.getSIntValue());
       break;
     case UINT:
       out("UINT token type, value: " + p.getUIntValue());
       break;
     case SEQUENCE:
       out("SEQUENCE token type");
       for (ParsedToken tok : p.getSeqValue()) {
         handleToken(tok);
       }
       break;
     case ERR:
       out("ERR token type");
       break;
     case USER:
       out("USER token type");
       break;
   }
 }
Beispiel #2
0
 private static void handle(ParseResult result) {
   if (result == null) {
     System.out.println("FAIL");
   } else {
     System.out.println("PASS");
     handleToken(result.getAst());
   }
 }