1 /* The following code was generated by JFlex 1.4.2 */
3 package org.json.simple.parser;
8 /** This character denotes the end of file */
9 public static final int YYEOF = -1;
11 /** initial size of the lookahead buffer */
12 private static final int ZZ_BUFFERSIZE = 16384;
15 public static final int YYINITIAL = 0;
17 public static final int STRING_BEGIN = 2;
20 * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
21 * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the
22 * beginning of a line l is of the form l = 2*k, k a non negative integer
24 private static final int ZZ_LEXSTATE[] = { 0, 0, 1, 1 };
27 * Translates characters to character classes
29 private static final String ZZ_CMAP_PACKED = "\11\0\1\7\1\7\2\0\1\7\22\0\1\7\1\0\1\11\10\0"
30 + "\1\6\1\31\1\2\1\4\1\12\12\3\1\32\6\0\4\1\1\5"
31 + "\1\1\24\0\1\27\1\10\1\30\3\0\1\22\1\13\2\1\1\21"
32 + "\1\14\5\0\1\23\1\0\1\15\3\0\1\16\1\24\1\17\1\20"
33 + "\5\0\1\25\1\0\1\26\uff82\0";
36 * Translates characters to character classes
38 private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
41 * Translates DFA states to action switch labels.
43 private static final int[] ZZ_ACTION = zzUnpackAction();
45 private static final String ZZ_ACTION_PACKED_0 = "\2\0\2\1\1\2\1\3\1\4\3\1\1\5\1\6"
46 + "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\5\0"
47 + "\1\14\1\16\1\17\1\20\1\21\1\22\1\23\1\24"
48 + "\1\0\1\25\1\0\1\25\4\0\1\26\1\27\2\0" + "\1\30";
50 private static int[] zzUnpackAction()
52 int[] result = new int[45];
54 offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
58 private static int zzUnpackAction(String packed, int offset, int[] result)
60 int i = 0; /* index in packed string */
61 int j = offset; /* index in unpacked array */
62 int l = packed.length();
65 int count = packed.charAt(i++);
66 int value = packed.charAt(i++);
75 * Translates a state to a row index in the transition table
77 private static final int[] ZZ_ROWMAP = zzUnpackRowMap();
79 private static final String ZZ_ROWMAP_PACKED_0 = "\0\0\0\33\0\66\0\121\0\154\0\207\0\66\0\242"
80 + "\0\275\0\330\0\66\0\66\0\66\0\66\0\66\0\66"
81 + "\0\363\0\u010e\0\66\0\u0129\0\u0144\0\u015f\0\u017a\0\u0195"
82 + "\0\66\0\66\0\66\0\66\0\66\0\66\0\66\0\66"
83 + "\0\u01b0\0\u01cb\0\u01e6\0\u01e6\0\u0201\0\u021c\0\u0237\0\u0252"
84 + "\0\66\0\66\0\u026d\0\u0288\0\66";
86 private static int[] zzUnpackRowMap()
88 int[] result = new int[45];
90 offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
94 private static int zzUnpackRowMap(String packed, int offset, int[] result)
96 int i = 0; /* index in packed string */
97 int j = offset; /* index in unpacked array */
98 int l = packed.length();
101 int high = packed.codePointAt(i++) << 16;
102 result[j++] = high | packed.codePointAt(i++);
108 * The transition table of the DFA
110 private static final int ZZ_TRANS[] = { 2, 2, 3, 4, 2, 2, 2, 5, 2, 6, 2,
111 2, 7, 8, 2, 9, 2, 2, 2, 2, 2, 10, 11, 12, 13, 14, 15, 16, 16, 16, 16,
112 16, 16, 16, 16, 17, 18, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
113 16, 16, 16, 16, 16, 16, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
114 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
115 -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
116 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 19, 20, -1, -1, -1, -1,
117 -1, -1, -1, -1, -1, -1, -1, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1,
118 -1, -1, -1, -1, -1, -1, -1, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
119 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
120 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, -1, -1, -1, -1, -1, -1,
121 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
122 -1, 22, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
123 -1, -1, -1, -1, -1, -1, -1, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1,
124 -1, -1, -1, -1, -1, 16, 16, 16, 16, 16, 16, 16, 16, -1, -1, 16, 16,
125 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, -1, -1,
126 -1, -1, -1, -1, -1, -1, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, -1,
127 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1,
128 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
129 -1, -1, -1, 34, 35, -1, -1, 34, -1, -1, -1, -1, -1, -1, -1, -1, -1,
130 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
131 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 36, -1, -1, -1,
132 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
133 -1, -1, -1, -1, -1, -1, 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
134 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 38, -1, -1, -1,
135 -1, -1, -1, -1, -1, -1, -1, -1, 39, -1, 39, -1, 39, -1, -1, -1, -1,
136 -1, 39, 39, -1, -1, -1, -1, 39, 39, -1, -1, -1, -1, -1, -1, -1, -1,
137 -1, -1, -1, 33, -1, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
138 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, -1, -1, -1,
139 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
140 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
141 -1, -1, -1, -1, -1, -1, 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
142 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 40, -1,
143 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
144 -1, -1, -1, -1, -1, -1, 41, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
145 42, -1, 42, -1, 42, -1, -1, -1, -1, -1, 42, 42, -1, -1, -1, -1, 42,
146 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, -1, 43, -1, 43, -1, -1,
147 -1, -1, -1, 43, 43, -1, -1, -1, -1, 43, 43, -1, -1, -1, -1, -1, -1,
148 -1, -1, -1, 44, -1, 44, -1, 44, -1, -1, -1, -1, -1, 44, 44, -1, -1,
149 -1, -1, 44, 44, -1, -1, -1, -1, -1, -1, -1, -1, };
152 private static final int ZZ_UNKNOWN_ERROR = 0;
154 private static final int ZZ_NO_MATCH = 1;
156 private static final int ZZ_PUSHBACK_2BIG = 2;
158 /* error messages for the codes above */
159 private static final String ZZ_ERROR_MSG[] = {
160 "Unkown internal scanner error", "Error: could not match input",
161 "Error: pushback value was too large" };
164 * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
166 private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute();
168 private static final String ZZ_ATTRIBUTE_PACKED_0 = "\2\0\1\11\3\1\1\11\3\1\6\11\2\1\1\11"
169 + "\5\0\10\11\1\0\1\1\1\0\1\1\4\0\2\11" + "\2\0\1\11";
171 private static int[] zzUnpackAttribute()
173 int[] result = new int[45];
175 offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
179 private static int zzUnpackAttribute(String packed, int offset,
182 int i = 0; /* index in packed string */
183 int j = offset; /* index in unpacked array */
184 int l = packed.length();
187 int count = packed.charAt(i++);
188 int value = packed.charAt(i++);
196 /** the input device */
197 private java.io.Reader zzReader;
199 /** the current state of the DFA */
202 /** the current lexical state */
203 private int zzLexicalState = YYINITIAL;
206 * this buffer contains the current text to be matched and is the source of
207 * the yytext() string
209 private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
211 /** the textposition at the last accepting state */
212 private int zzMarkedPos;
214 /** the current text position in the buffer */
215 private int zzCurrentPos;
217 /** startRead marks the beginning of the yytext() string in the buffer */
218 private int zzStartRead;
221 * endRead marks the last character in the buffer, that has been read from
224 private int zzEndRead;
226 /** number of newlines encountered up to the start of the matched text */
229 /** the number of characters up to the start of the matched text */
233 * the number of characters from the last newline up to the start of the
236 private int yycolumn;
239 * zzAtBOL == true <=> the scanner is currently at the beginning of a line
241 private boolean zzAtBOL = true;
243 /** zzAtEOF == true <=> the scanner is at the EOF */
244 private boolean zzAtEOF;
247 private StringBuffer sb = new StringBuffer();
255 * Creates a new scanner There is also a java.io.InputStream version of this
259 * the java.io.Reader to read input from.
261 Yylex(java.io.Reader in)
267 * Creates a new scanner. There is also java.io.Reader version of this
271 * the java.io.Inputstream to read input from.
273 Yylex(java.io.InputStream in)
275 this(new java.io.InputStreamReader(in));
279 * Unpacks the compressed character translation table.
282 * the packed character translation table
283 * @return the unpacked character translation table
285 private static char[] zzUnpackCMap(String packed)
287 char[] map = new char[0x10000];
288 int i = 0; /* index in packed string */
289 int j = 0; /* index in unpacked array */
292 int count = packed.charAt(i++);
293 char value = packed.charAt(i++);
302 * Refills the input buffer.
304 * @return <code>false</code>, iff there was new input.
306 * @exception java.io.IOException
307 * if any I/O-Error occurs
309 private boolean zzRefill() throws java.io.IOException
312 /* first: make room (if you can) */
315 System.arraycopy(zzBuffer, zzStartRead, zzBuffer, 0,
316 zzEndRead - zzStartRead);
318 /* translate stored positions */
319 zzEndRead -= zzStartRead;
320 zzCurrentPos -= zzStartRead;
321 zzMarkedPos -= zzStartRead;
325 /* is the buffer big enough? */
326 if (zzCurrentPos >= zzBuffer.length)
328 /* if not: blow it up */
329 char newBuffer[] = new char[zzCurrentPos * 2];
330 System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
331 zzBuffer = newBuffer;
334 /* finally: fill the buffer with new input */
335 int numRead = zzReader.read(zzBuffer, zzEndRead,
336 zzBuffer.length - zzEndRead);
340 zzEndRead += numRead;
343 // unlikely but not impossible: read 0 characters, but not at end of stream
346 int c = zzReader.read();
353 zzBuffer[zzEndRead++] = (char) c;
363 * Closes the input stream.
365 public final void yyclose() throws java.io.IOException
367 zzAtEOF = true; /* indicate end of file */
368 zzEndRead = zzStartRead; /* invalidate buffer */
370 if (zzReader != null)
375 * Resets the scanner to read from a new input stream. Does not close the old
378 * All internal variables are reset, the old input stream <b>cannot</b> be
379 * reused (internal buffer is discarded and lost). Lexical state is set to
380 * <tt>ZZ_INITIAL</tt>.
383 * the new input stream
385 public final void yyreset(java.io.Reader reader)
390 zzEndRead = zzStartRead = 0;
391 zzCurrentPos = zzMarkedPos = 0;
392 yyline = yychar = yycolumn = 0;
393 zzLexicalState = YYINITIAL;
397 * Returns the current lexical state.
399 public final int yystate()
401 return zzLexicalState;
405 * Enters a new lexical state
408 * the new lexical state
410 public final void yybegin(int newState)
412 zzLexicalState = newState;
416 * Returns the text matched by the current regular expression.
418 public final String yytext()
420 return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
424 * Returns the character at position <tt>pos</tt> from the matched text.
426 * It is equivalent to yytext().charAt(pos), but faster
429 * the position of the character to fetch. A value from 0 to
432 * @return the character at position pos
434 public final char yycharat(int pos)
436 return zzBuffer[zzStartRead + pos];
440 * Returns the length of the matched text region.
442 public final int yylength()
444 return zzMarkedPos - zzStartRead;
448 * Reports an error that occured while scanning.
450 * In a wellformed scanner (no or only correct usage of yypushback(int) and a
451 * match-all fallback rule) this method will only be called with things that
452 * "Can't Possibly Happen". If this method is called, something is seriously
453 * wrong (e.g. a JFlex bug producing a faulty scanner etc.).
455 * Usual syntax/scanner level error handling should be done in error fallback
459 * the code of the errormessage to display
461 private void zzScanError(int errorCode)
466 message = ZZ_ERROR_MSG[errorCode];
467 } catch (ArrayIndexOutOfBoundsException e)
469 message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
472 throw new Error(message);
476 * Pushes the specified amount of characters back into the input stream.
478 * They will be read again by then next call of the scanning method
481 * the number of characters to be read again. This number must not be
482 * greater than yylength()!
484 public void yypushback(int number)
486 if (number > yylength())
487 zzScanError(ZZ_PUSHBACK_2BIG);
489 zzMarkedPos -= number;
493 * Resumes scanning until the next regular expression is matched, the end of
494 * input is encountered or an I/O-Error occurs.
496 * @return the next token
497 * @exception java.io.IOException
498 * if any I/O-Error occurs
500 public Yytoken yylex() throws java.io.IOException, ParseException
508 int zzEndReadL = zzEndRead;
509 char[] zzBufferL = zzBuffer;
510 char[] zzCMapL = ZZ_CMAP;
512 int[] zzTransL = ZZ_TRANS;
513 int[] zzRowMapL = ZZ_ROWMAP;
514 int[] zzAttrL = ZZ_ATTRIBUTE;
518 zzMarkedPosL = zzMarkedPos;
520 yychar += zzMarkedPosL - zzStartRead;
524 zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
526 zzState = ZZ_LEXSTATE[zzLexicalState];
533 if (zzCurrentPosL < zzEndReadL)
534 zzInput = zzBufferL[zzCurrentPosL++];
542 // store back cached positions
543 zzCurrentPos = zzCurrentPosL;
544 zzMarkedPos = zzMarkedPosL;
545 boolean eof = zzRefill();
546 // get translated positions and possibly new buffer
547 zzCurrentPosL = zzCurrentPos;
548 zzMarkedPosL = zzMarkedPos;
549 zzBufferL = zzBuffer;
550 zzEndReadL = zzEndRead;
558 zzInput = zzBufferL[zzCurrentPosL++];
561 int zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]];
566 int zzAttributes = zzAttrL[zzState];
567 if ((zzAttributes & 1) == 1)
570 zzMarkedPosL = zzCurrentPosL;
571 if ((zzAttributes & 8) == 8)
578 // store back cached position
579 zzMarkedPos = zzMarkedPosL;
580 switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction])
591 sb = new StringBuffer();
592 yybegin(STRING_BEGIN);
604 return new Yytoken(Yytoken.TYPE_RIGHT_BRACE, null);
610 Boolean val = Boolean.valueOf(yytext());
611 return new Yytoken(Yytoken.TYPE_VALUE, val);
617 return new Yytoken(Yytoken.TYPE_VALUE, null);
624 return new Yytoken(Yytoken.TYPE_VALUE, sb.toString());
636 Double val = Double.valueOf(yytext());
637 return new Yytoken(Yytoken.TYPE_VALUE, val);
643 throw new ParseException(yychar,
644 ParseException.ERROR_UNEXPECTED_CHAR,
645 new Character(yycharat(0)));
651 return new Yytoken(Yytoken.TYPE_RIGHT_SQUARE, null);
669 return new Yytoken(Yytoken.TYPE_COLON, null);
681 return new Yytoken(Yytoken.TYPE_LEFT_BRACE, null);
695 int ch = Integer.parseInt(yytext().substring(2), 16);
696 sb.append((char) ch);
697 } catch (Exception e)
699 throw new ParseException(yychar,
700 ParseException.ERROR_UNEXPECTED_EXCEPTION, e);
713 return new Yytoken(Yytoken.TYPE_LEFT_SQUARE, null);
719 Long val = Long.valueOf(yytext());
720 return new Yytoken(Yytoken.TYPE_VALUE, val);
732 return new Yytoken(Yytoken.TYPE_COMMA, null);
742 if (zzInput == YYEOF && zzStartRead == zzCurrentPos)
749 zzScanError(ZZ_NO_MATCH);