src/jdk.management.rest/share/classes/jdk/internal/management/remote/rest/json/parser/JSONParser.java
branchjmx-rest-api
changeset 56026 bd531f08d7c7
equal deleted inserted replaced
56007:d6cbabcaf518 56026:bd531f08d7c7
       
     1 /* Generated By:JavaCC: Do not edit this line. JSONParser.java */
       
     2 package jdk.internal.management.remote.rest.json.parser;
       
     3 
       
     4 import java.io.StringReader;
       
     5 import jdk.internal.management.remote.rest.json.*;
       
     6 
       
     7 public class JSONParser implements JSONParserConstants {
       
     8 
       
     9     public JSONParser(String input) {
       
    10         this(new StringReader(input));
       
    11     }
       
    12 
       
    13     public JSONElement parse() throws ParseException {
       
    14         return jsonValue();
       
    15     }
       
    16 
       
    17   final public JSONElement jsonValue() throws ParseException {
       
    18         JSONElement x;
       
    19     switch (jj_nt.kind) {
       
    20     case 16:
       
    21       x = object();
       
    22       break;
       
    23     case 20:
       
    24       x = list();
       
    25       break;
       
    26     case QUOTED_STRING:
       
    27       x = string();
       
    28       break;
       
    29     case INTEGER_LITERAL:
       
    30     case FLOATING_POINT_LITERAL:
       
    31       x = number();
       
    32       break;
       
    33     case BOOL_LITERAL:
       
    34       x = boolVal();
       
    35       break;
       
    36     case NULL:
       
    37       x = nullVal();
       
    38       break;
       
    39     default:
       
    40       jj_la1[0] = jj_gen;
       
    41       jj_consume_token(-1);
       
    42       throw new ParseException();
       
    43     }
       
    44           {if (true) return x;}
       
    45     throw new Error("Missing return statement in function");
       
    46   }
       
    47 
       
    48   final public JSONObject object() throws ParseException {
       
    49         final JSONObject jobject = new JSONObject();
       
    50         JSONPrimitive key;
       
    51         JSONElement value;
       
    52     jj_consume_token(16);
       
    53     key = string();
       
    54     jj_consume_token(17);
       
    55     value = jsonValue();
       
    56           jobject.put((String)key.getValue(), value);
       
    57     label_1:
       
    58     while (true) {
       
    59       switch (jj_nt.kind) {
       
    60       case 18:
       
    61         ;
       
    62         break;
       
    63       default:
       
    64         jj_la1[1] = jj_gen;
       
    65         break label_1;
       
    66       }
       
    67       jj_consume_token(18);
       
    68       key = string();
       
    69       jj_consume_token(17);
       
    70       value = jsonValue();
       
    71                   jobject.put((String)key.getValue(), value);
       
    72     }
       
    73     jj_consume_token(19);
       
    74       {if (true) return jobject;}
       
    75     throw new Error("Missing return statement in function");
       
    76   }
       
    77 
       
    78   final public JSONArray list() throws ParseException {
       
    79     final JSONArray jarray = new JSONArray();
       
    80     JSONElement value;
       
    81     jj_consume_token(20);
       
    82     value = jsonValue();
       
    83           jarray.add(value);
       
    84     label_2:
       
    85     while (true) {
       
    86       switch (jj_nt.kind) {
       
    87       case 18:
       
    88         ;
       
    89         break;
       
    90       default:
       
    91         jj_la1[2] = jj_gen;
       
    92         break label_2;
       
    93       }
       
    94       jj_consume_token(18);
       
    95       value = jsonValue();
       
    96               jarray.add(value);
       
    97     }
       
    98     jj_consume_token(21);
       
    99       {if (true) return jarray;}
       
   100     throw new Error("Missing return statement in function");
       
   101   }
       
   102 
       
   103   final public JSONPrimitive nullVal() throws ParseException {
       
   104     jj_consume_token(NULL);
       
   105       {if (true) return null;}
       
   106     throw new Error("Missing return statement in function");
       
   107   }
       
   108 
       
   109   final public JSONPrimitive boolVal() throws ParseException {
       
   110     jj_consume_token(BOOL_LITERAL);
       
   111      {if (true) return new JSONPrimitive(Boolean.parseBoolean(token.image));}
       
   112     throw new Error("Missing return statement in function");
       
   113   }
       
   114 
       
   115   final public JSONPrimitive number() throws ParseException {
       
   116     Token t;
       
   117     switch (jj_nt.kind) {
       
   118     case INTEGER_LITERAL:
       
   119       t = jj_consume_token(INTEGER_LITERAL);
       
   120                              {if (true) return new JSONPrimitive(Long.parseLong(t.image));}
       
   121       break;
       
   122     case FLOATING_POINT_LITERAL:
       
   123       t = jj_consume_token(FLOATING_POINT_LITERAL);
       
   124                                       {if (true) return new JSONPrimitive(Double.parseDouble(t.image));}
       
   125       break;
       
   126     default:
       
   127       jj_la1[3] = jj_gen;
       
   128       jj_consume_token(-1);
       
   129       throw new ParseException();
       
   130     }
       
   131     throw new Error("Missing return statement in function");
       
   132   }
       
   133 
       
   134   final public JSONPrimitive string() throws ParseException {
       
   135     Token t;
       
   136     t = jj_consume_token(QUOTED_STRING);
       
   137       {if (true) return new JSONPrimitive(t.image.substring(1,t.image.length()-1));}
       
   138     throw new Error("Missing return statement in function");
       
   139   }
       
   140 
       
   141   /** Generated Token Manager. */
       
   142   public JSONParserTokenManager token_source;
       
   143   JavaCharStream jj_input_stream;
       
   144   /** Current token. */
       
   145   public Token token;
       
   146   /** Next token. */
       
   147   public Token jj_nt;
       
   148   private int jj_gen;
       
   149   final private int[] jj_la1 = new int[4];
       
   150   static private int[] jj_la1_0;
       
   151   static {
       
   152       jj_la1_init_0();
       
   153    }
       
   154    private static void jj_la1_init_0() {
       
   155       jj_la1_0 = new int[] {0x11e180,0x40000,0x40000,0x180,};
       
   156    }
       
   157 
       
   158   /** Constructor with InputStream. */
       
   159   public JSONParser(java.io.InputStream stream) {
       
   160      this(stream, null);
       
   161   }
       
   162   /** Constructor with InputStream and supplied encoding */
       
   163   public JSONParser(java.io.InputStream stream, String encoding) {
       
   164     try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
       
   165     token_source = new JSONParserTokenManager(jj_input_stream);
       
   166     token = new Token();
       
   167     token.next = jj_nt = token_source.getNextToken();
       
   168     jj_gen = 0;
       
   169     for (int i = 0; i < 4; i++) jj_la1[i] = -1;
       
   170   }
       
   171 
       
   172   /** Reinitialise. */
       
   173   public void ReInit(java.io.InputStream stream) {
       
   174      ReInit(stream, null);
       
   175   }
       
   176   /** Reinitialise. */
       
   177   public void ReInit(java.io.InputStream stream, String encoding) {
       
   178     try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
       
   179     token_source.ReInit(jj_input_stream);
       
   180     token = new Token();
       
   181     token.next = jj_nt = token_source.getNextToken();
       
   182     jj_gen = 0;
       
   183     for (int i = 0; i < 4; i++) jj_la1[i] = -1;
       
   184   }
       
   185 
       
   186   /** Constructor. */
       
   187   public JSONParser(java.io.Reader stream) {
       
   188     jj_input_stream = new JavaCharStream(stream, 1, 1);
       
   189     token_source = new JSONParserTokenManager(jj_input_stream);
       
   190     token = new Token();
       
   191     token.next = jj_nt = token_source.getNextToken();
       
   192     jj_gen = 0;
       
   193     for (int i = 0; i < 4; i++) jj_la1[i] = -1;
       
   194   }
       
   195 
       
   196   /** Reinitialise. */
       
   197   public void ReInit(java.io.Reader stream) {
       
   198     jj_input_stream.ReInit(stream, 1, 1);
       
   199     token_source.ReInit(jj_input_stream);
       
   200     token = new Token();
       
   201     token.next = jj_nt = token_source.getNextToken();
       
   202     jj_gen = 0;
       
   203     for (int i = 0; i < 4; i++) jj_la1[i] = -1;
       
   204   }
       
   205 
       
   206   /** Constructor with generated Token Manager. */
       
   207   public JSONParser(JSONParserTokenManager tm) {
       
   208     token_source = tm;
       
   209     token = new Token();
       
   210     token.next = jj_nt = token_source.getNextToken();
       
   211     jj_gen = 0;
       
   212     for (int i = 0; i < 4; i++) jj_la1[i] = -1;
       
   213   }
       
   214 
       
   215   /** Reinitialise. */
       
   216   public void ReInit(JSONParserTokenManager tm) {
       
   217     token_source = tm;
       
   218     token = new Token();
       
   219     token.next = jj_nt = token_source.getNextToken();
       
   220     jj_gen = 0;
       
   221     for (int i = 0; i < 4; i++) jj_la1[i] = -1;
       
   222   }
       
   223 
       
   224   private Token jj_consume_token(int kind) throws ParseException {
       
   225     Token oldToken = token;
       
   226     if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
       
   227     else jj_nt = jj_nt.next = token_source.getNextToken();
       
   228     if (token.kind == kind) {
       
   229       jj_gen++;
       
   230       return token;
       
   231     }
       
   232     jj_nt = token;
       
   233     token = oldToken;
       
   234     jj_kind = kind;
       
   235     throw generateParseException();
       
   236   }
       
   237 
       
   238 
       
   239 /** Get the next Token. */
       
   240   final public Token getNextToken() {
       
   241     if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
       
   242     else jj_nt = jj_nt.next = token_source.getNextToken();
       
   243     jj_gen++;
       
   244     return token;
       
   245   }
       
   246 
       
   247 /** Get the specific Token. */
       
   248   final public Token getToken(int index) {
       
   249     Token t = token;
       
   250     for (int i = 0; i < index; i++) {
       
   251       if (t.next != null) t = t.next;
       
   252       else t = t.next = token_source.getNextToken();
       
   253     }
       
   254     return t;
       
   255   }
       
   256 
       
   257   private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
       
   258   private int[] jj_expentry;
       
   259   private int jj_kind = -1;
       
   260 
       
   261   /** Generate ParseException. */
       
   262   public ParseException generateParseException() {
       
   263     jj_expentries.clear();
       
   264     boolean[] la1tokens = new boolean[22];
       
   265     if (jj_kind >= 0) {
       
   266       la1tokens[jj_kind] = true;
       
   267       jj_kind = -1;
       
   268     }
       
   269     for (int i = 0; i < 4; i++) {
       
   270       if (jj_la1[i] == jj_gen) {
       
   271         for (int j = 0; j < 32; j++) {
       
   272           if ((jj_la1_0[i] & (1<<j)) != 0) {
       
   273             la1tokens[j] = true;
       
   274           }
       
   275         }
       
   276       }
       
   277     }
       
   278     for (int i = 0; i < 22; i++) {
       
   279       if (la1tokens[i]) {
       
   280         jj_expentry = new int[1];
       
   281         jj_expentry[0] = i;
       
   282         jj_expentries.add(jj_expentry);
       
   283       }
       
   284     }
       
   285     int[][] exptokseq = new int[jj_expentries.size()][];
       
   286     for (int i = 0; i < jj_expentries.size(); i++) {
       
   287       exptokseq[i] = jj_expentries.get(i);
       
   288     }
       
   289     return new ParseException(token, exptokseq, tokenImage);
       
   290   }
       
   291 
       
   292   /** Enable tracing. */
       
   293   final public void enable_tracing() {
       
   294   }
       
   295 
       
   296   /** Disable tracing. */
       
   297   final public void disable_tracing() {
       
   298   }
       
   299 
       
   300 }