1 /* The following code was generated by JFlex 1.4.2 */
3 package org.json.simple.parser;
7 /** This character denotes the end of file */
8 public static final int YYEOF = -1;
10 /** initial size of the lookahead buffer */
11 private static final int ZZ_BUFFERSIZE = 16384;
14 public static final int YYINITIAL = 0;
15 public static final int STRING_BEGIN = 2;
18 * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
19 * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
20 * at the beginning of a line
21 * l is of the form l = 2*k, k a non negative integer
23 private static final int ZZ_LEXSTATE[] = {
28 * Translates characters to character classes
30 private static final String ZZ_CMAP_PACKED =
31 "\11\0\1\7\1\7\2\0\1\7\22\0\1\7\1\0\1\11\10\0"+
32 "\1\6\1\31\1\2\1\4\1\12\12\3\1\32\6\0\4\1\1\5"+
33 "\1\1\24\0\1\27\1\10\1\30\3\0\1\22\1\13\2\1\1\21"+
34 "\1\14\5\0\1\23\1\0\1\15\3\0\1\16\1\24\1\17\1\20"+
35 "\5\0\1\25\1\0\1\26\uff82\0";
38 * Translates characters to character classes
40 private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
43 * Translates DFA states to action switch labels.
45 private static final int [] ZZ_ACTION = zzUnpackAction();
47 private static final String ZZ_ACTION_PACKED_0 =
48 "\2\0\2\1\1\2\1\3\1\4\3\1\1\5\1\6"+
49 "\1\7\1\10\1\11\1\12\1\13\1\14\1\15\5\0"+
50 "\1\14\1\16\1\17\1\20\1\21\1\22\1\23\1\24"+
51 "\1\0\1\25\1\0\1\25\4\0\1\26\1\27\2\0"+
54 private static int [] zzUnpackAction() {
55 int [] result = new int[45];
57 offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
61 private static int zzUnpackAction(String packed, int offset, int [] result) {
62 int i = 0; /* index in packed string */
63 int j = offset; /* index in unpacked array */
64 int l = packed.length();
66 int count = packed.charAt(i++);
67 int value = packed.charAt(i++);
68 do result[j++] = value; while (--count > 0);
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 =
80 "\0\0\0\33\0\66\0\121\0\154\0\207\0\66\0\242"+
81 "\0\275\0\330\0\66\0\66\0\66\0\66\0\66\0\66"+
82 "\0\363\0\u010e\0\66\0\u0129\0\u0144\0\u015f\0\u017a\0\u0195"+
83 "\0\66\0\66\0\66\0\66\0\66\0\66\0\66\0\66"+
84 "\0\u01b0\0\u01cb\0\u01e6\0\u01e6\0\u0201\0\u021c\0\u0237\0\u0252"+
85 "\0\66\0\66\0\u026d\0\u0288\0\66";
87 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) {
95 int i = 0; /* index in packed string */
96 int j = offset; /* index in unpacked array */
97 int l = packed.length();
99 int high = packed.codePointAt(i++) << 16;
100 result[j++] = high | packed.codePointAt(i++);
106 * The transition table of the DFA
108 private static final int ZZ_TRANS [] = {
109 2, 2, 3, 4, 2, 2, 2, 5, 2, 6,
110 2, 2, 7, 8, 2, 9, 2, 2, 2, 2,
111 2, 10, 11, 12, 13, 14, 15, 16, 16, 16,
112 16, 16, 16, 16, 16, 17, 18, 16, 16, 16,
113 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
114 16, 16, 16, 16, -1, -1, -1, -1, -1, -1,
115 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
116 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
117 -1, -1, -1, -1, 4, -1, -1, -1, -1, -1,
118 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
119 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
120 -1, 4, 19, 20, -1, -1, -1, -1, -1, -1,
121 -1, -1, -1, -1, -1, 20, -1, -1, -1, -1,
122 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
123 -1, -1, 5, -1, -1, -1, -1, -1, -1, -1,
124 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
125 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
126 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
127 21, -1, -1, -1, -1, -1, -1, -1, -1, -1,
128 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
129 -1, -1, -1, -1, -1, 22, -1, -1, -1, -1,
130 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
131 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
132 23, -1, -1, -1, -1, -1, -1, -1, -1, -1,
133 -1, -1, -1, 16, 16, 16, 16, 16, 16, 16,
134 16, -1, -1, 16, 16, 16, 16, 16, 16, 16,
135 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
136 -1, -1, -1, -1, -1, -1, -1, -1, 24, 25,
137 26, 27, 28, 29, 30, 31, 32, -1, -1, -1,
138 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
139 33, -1, -1, -1, -1, -1, -1, -1, -1, -1,
140 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
141 -1, -1, -1, -1, -1, -1, 34, 35, -1, -1,
142 34, -1, -1, -1, -1, -1, -1, -1, -1, -1,
143 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
144 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
145 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
146 36, -1, -1, -1, -1, -1, -1, -1, -1, -1,
147 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
148 -1, -1, -1, -1, -1, -1, -1, 37, -1, -1,
149 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
150 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
151 -1, 38, -1, -1, -1, -1, -1, -1, -1, -1,
152 -1, -1, -1, 39, -1, 39, -1, 39, -1, -1,
153 -1, -1, -1, 39, 39, -1, -1, -1, -1, 39,
154 39, -1, -1, -1, -1, -1, -1, -1, -1, -1,
155 -1, -1, 33, -1, 20, -1, -1, -1, -1, -1,
156 -1, -1, -1, -1, -1, -1, 20, -1, -1, -1,
157 -1, -1, -1, -1, -1, -1, -1, -1, -1, 35,
158 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
159 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
160 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
161 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
162 -1, -1, -1, 38, -1, -1, -1, -1, -1, -1,
163 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
164 -1, -1, -1, -1, -1, -1, -1, -1, -1, 40,
165 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
166 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
167 -1, -1, -1, -1, 41, -1, -1, -1, -1, -1,
168 -1, -1, -1, -1, -1, 42, -1, 42, -1, 42,
169 -1, -1, -1, -1, -1, 42, 42, -1, -1, -1,
170 -1, 42, 42, -1, -1, -1, -1, -1, -1, -1,
171 -1, -1, 43, -1, 43, -1, 43, -1, -1, -1,
172 -1, -1, 43, 43, -1, -1, -1, -1, 43, 43,
173 -1, -1, -1, -1, -1, -1, -1, -1, -1, 44,
174 -1, 44, -1, 44, -1, -1, -1, -1, -1, 44,
175 44, -1, -1, -1, -1, 44, 44, -1, -1, -1,
180 private static final int ZZ_UNKNOWN_ERROR = 0;
181 private static final int ZZ_NO_MATCH = 1;
182 private static final int ZZ_PUSHBACK_2BIG = 2;
184 /* error messages for the codes above */
185 private static final String ZZ_ERROR_MSG[] = {
186 "Unkown internal scanner error",
187 "Error: could not match input",
188 "Error: pushback value was too large"
192 * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
194 private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
196 private static final String ZZ_ATTRIBUTE_PACKED_0 =
197 "\2\0\1\11\3\1\1\11\3\1\6\11\2\1\1\11"+
198 "\5\0\10\11\1\0\1\1\1\0\1\1\4\0\2\11"+
201 private static int [] zzUnpackAttribute() {
202 int [] result = new int[45];
204 offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
208 private static int zzUnpackAttribute(String packed, int offset, int [] result) {
209 int i = 0; /* index in packed string */
210 int j = offset; /* index in unpacked array */
211 int l = packed.length();
213 int count = packed.charAt(i++);
214 int value = packed.charAt(i++);
215 do result[j++] = value; while (--count > 0);
220 /** the input device */
221 private java.io.Reader zzReader;
223 /** the current state of the DFA */
226 /** the current lexical state */
227 private int zzLexicalState = YYINITIAL;
229 /** this buffer contains the current text to be matched and is
230 the source of the yytext() string */
231 private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
233 /** the textposition at the last accepting state */
234 private int zzMarkedPos;
236 /** the current text position in the buffer */
237 private int zzCurrentPos;
239 /** startRead marks the beginning of the yytext() string in the buffer */
240 private int zzStartRead;
242 /** endRead marks the last character in the buffer, that has been read
244 private int zzEndRead;
246 /** number of newlines encountered up to the start of the matched text */
249 /** the number of characters up to the start of the matched text */
253 * the number of characters from the last newline up to the start of the
256 private int yycolumn;
259 * zzAtBOL == true <=> the scanner is currently at the beginning of a line
261 private boolean zzAtBOL = true;
263 /** zzAtEOF == true <=> the scanner is at the EOF */
264 private boolean zzAtEOF;
267 private StringBuffer sb=new StringBuffer();
276 * Creates a new scanner
277 * There is also a java.io.InputStream version of this constructor.
279 * @param in the java.io.Reader to read input from.
281 Yylex(java.io.Reader in) {
286 * Creates a new scanner.
287 * There is also java.io.Reader version of this constructor.
289 * @param in the java.io.Inputstream to read input from.
291 Yylex(java.io.InputStream in) {
292 this(new java.io.InputStreamReader(in));
296 * Unpacks the compressed character translation table.
298 * @param packed the packed character translation table
299 * @return the unpacked character translation table
301 private static char [] zzUnpackCMap(String packed) {
302 char [] map = new char[0x10000];
303 int i = 0; /* index in packed string */
304 int j = 0; /* index in unpacked array */
306 int count = packed.charAt(i++);
307 char value = packed.charAt(i++);
308 do map[j++] = value; while (--count > 0);
315 * Refills the input buffer.
317 * @return <code>false</code>, iff there was new input.
319 * @exception java.io.IOException if any I/O-Error occurs
321 private boolean zzRefill() throws java.io.IOException {
323 /* first: make room (if you can) */
324 if (zzStartRead > 0) {
325 System.arraycopy(zzBuffer, zzStartRead,
327 zzEndRead-zzStartRead);
329 /* translate stored positions */
330 zzEndRead-= zzStartRead;
331 zzCurrentPos-= zzStartRead;
332 zzMarkedPos-= zzStartRead;
336 /* is the buffer big enough? */
337 if (zzCurrentPos >= zzBuffer.length) {
338 /* if not: blow it up */
339 char newBuffer[] = new char[zzCurrentPos*2];
340 System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
341 zzBuffer = newBuffer;
344 /* finally: fill the buffer with new input */
345 int numRead = zzReader.read(zzBuffer, zzEndRead,
346 zzBuffer.length-zzEndRead);
352 // unlikely but not impossible: read 0 characters, but not at end of stream
354 int c = zzReader.read();
358 zzBuffer[zzEndRead++] = (char) c;
369 * Closes the input stream.
371 public final void yyclose() throws java.io.IOException {
372 zzAtEOF = true; /* indicate end of file */
373 zzEndRead = zzStartRead; /* invalidate buffer */
375 if (zzReader != null)
381 * Resets the scanner to read from a new input stream.
382 * Does not close the old reader.
384 * All internal variables are reset, the old input stream
385 * <b>cannot</b> be reused (internal buffer is discarded and lost).
386 * Lexical state is set to <tt>ZZ_INITIAL</tt>.
388 * @param reader the new input stream
390 public final void yyreset(java.io.Reader reader) {
394 zzEndRead = zzStartRead = 0;
395 zzCurrentPos = zzMarkedPos = 0;
396 yyline = yychar = yycolumn = 0;
397 zzLexicalState = YYINITIAL;
402 * Returns the current lexical state.
404 public final int yystate() {
405 return zzLexicalState;
410 * Enters a new lexical state
412 * @param newState the new lexical state
414 public final void yybegin(int newState) {
415 zzLexicalState = newState;
420 * Returns the text matched by the current regular expression.
422 public final String yytext() {
423 return new String( zzBuffer, zzStartRead, zzMarkedPos-zzStartRead );
428 * Returns the character at position <tt>pos</tt> from the
431 * It is equivalent to yytext().charAt(pos), but faster
433 * @param pos the position of the character to fetch.
434 * A value from 0 to yylength()-1.
436 * @return the character at position pos
438 public final char yycharat(int pos) {
439 return zzBuffer[zzStartRead+pos];
444 * Returns the length of the matched text region.
446 public final int yylength() {
447 return zzMarkedPos-zzStartRead;
452 * Reports an error that occured while scanning.
454 * In a wellformed scanner (no or only correct usage of
455 * yypushback(int) and a match-all fallback rule) this method
456 * will only be called with things that "Can't Possibly Happen".
457 * If this method is called, something is seriously wrong
458 * (e.g. a JFlex bug producing a faulty scanner etc.).
460 * Usual syntax/scanner level error handling should be done
461 * in error fallback rules.
463 * @param errorCode the code of the errormessage to display
465 private void zzScanError(int errorCode) {
468 message = ZZ_ERROR_MSG[errorCode];
470 catch (ArrayIndexOutOfBoundsException e) {
471 message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
474 throw new Error(message);
479 * Pushes the specified amount of characters back into the input stream.
481 * They will be read again by then next call of the scanning method
483 * @param number the number of characters to be read again.
484 * This number must not be greater than yylength()!
486 public void yypushback(int number) {
487 if ( number > yylength() )
488 zzScanError(ZZ_PUSHBACK_2BIG);
490 zzMarkedPos -= number;
495 * Resumes scanning until the next regular expression is matched, the end of
496 * input is encountered or an I/O-Error occurs.
498 * @return the next token
499 * @exception java.io.IOException
500 * if any I/O-Error occurs
502 public Yytoken yylex() throws java.io.IOException, ParseException
510 int zzEndReadL = zzEndRead;
511 char[] zzBufferL = zzBuffer;
512 char[] zzCMapL = ZZ_CMAP;
514 int[] zzTransL = ZZ_TRANS;
515 int[] zzRowMapL = ZZ_ROWMAP;
516 int[] zzAttrL = ZZ_ATTRIBUTE;
520 zzMarkedPosL = zzMarkedPos;
522 yychar += zzMarkedPosL - zzStartRead;
526 zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
528 zzState = ZZ_LEXSTATE[zzLexicalState];
535 if (zzCurrentPosL < zzEndReadL)
536 zzInput = zzBufferL[zzCurrentPosL++];
544 // store back cached positions
545 zzCurrentPos = zzCurrentPosL;
546 zzMarkedPos = zzMarkedPosL;
547 boolean eof = zzRefill();
548 // get translated positions and possibly new buffer
549 zzCurrentPosL = zzCurrentPos;
550 zzMarkedPosL = zzMarkedPos;
551 zzBufferL = zzBuffer;
552 zzEndReadL = zzEndRead;
560 zzInput = zzBufferL[zzCurrentPosL++];
563 int zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]];
568 int zzAttributes = zzAttrL[zzState];
569 if ((zzAttributes & 1) == 1)
572 zzMarkedPosL = zzCurrentPosL;
573 if ((zzAttributes & 8) == 8)
580 // store back cached position
581 zzMarkedPos = zzMarkedPosL;
582 switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction])
593 sb = new StringBuffer();
594 yybegin(STRING_BEGIN);
606 return new Yytoken(Yytoken.TYPE_RIGHT_BRACE, null);
612 Boolean val = Boolean.valueOf(yytext());
613 return new Yytoken(Yytoken.TYPE_VALUE, val);
619 return new Yytoken(Yytoken.TYPE_VALUE, null);
626 return new Yytoken(Yytoken.TYPE_VALUE, sb.toString());
638 Double val = Double.valueOf(yytext());
639 return new Yytoken(Yytoken.TYPE_VALUE, val);
645 throw new ParseException(yychar,
646 ParseException.ERROR_UNEXPECTED_CHAR,
647 new Character(yycharat(0)));
653 return new Yytoken(Yytoken.TYPE_RIGHT_SQUARE, null);
671 return new Yytoken(Yytoken.TYPE_COLON, null);
683 return new Yytoken(Yytoken.TYPE_LEFT_BRACE, null);
697 int ch = Integer.parseInt(yytext().substring(2), 16);
698 sb.append((char) ch);
699 } catch (Exception e)
701 throw new ParseException(yychar,
702 ParseException.ERROR_UNEXPECTED_EXCEPTION, e);
715 return new Yytoken(Yytoken.TYPE_LEFT_SQUARE, null);
721 Long val = Long.valueOf(yytext());
722 return new Yytoken(Yytoken.TYPE_VALUE, val);
734 return new Yytoken(Yytoken.TYPE_COMMA, null);
744 if (zzInput == YYEOF && zzStartRead == zzCurrentPos)
751 zzScanError(ZZ_NO_MATCH);