1 #line 4 "json-lex.l"
2 #ifdef HAVE_CONFIG_H
3 # include <config.h>
4 #endif
5 
6 
7 
8 #line 9 "json-lex.c"
9 
10 #define  YY_INT_ALIGNED short int
11 
12 /* A lexical scanner generated by flex */
13 
14 /* %not-for-header */
15 
16 /* %if-c-only */
17 /* %if-not-reentrant */
18 
19 /* %endif */
20 /* %endif */
21 /* %ok-for-header */
22 
23 #define FLEX_SCANNER
24 #define YY_FLEX_MAJOR_VERSION 2
25 #define YY_FLEX_MINOR_VERSION 6
26 #define YY_FLEX_SUBMINOR_VERSION 0
27 #if YY_FLEX_SUBMINOR_VERSION > 0
28 #define FLEX_BETA
29 #endif
30 
31 /* %if-c++-only */
32 /* %endif */
33 
34 /* %if-c-only */
35 
36 /* %endif */
37 
38 /* %if-c-only */
39 
40 /* %endif */
41 
42 /* First, we deal with  platform-specific or compiler-specific issues. */
43 
44 /* begin standard C headers. */
45 /* %if-c-only */
46 #include <stdio.h>
47 #include <string.h>
48 #include <errno.h>
49 #include <stdlib.h>
50 /* %endif */
51 
52 /* %if-tables-serialization */
53 /* %endif */
54 /* end standard C headers. */
55 
56 /* %if-c-or-c++ */
57 /* flex integer type definitions */
58 
59 #ifndef FLEXINT_H
60 #define FLEXINT_H
61 
62 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
63 
64 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
65 
66 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
67  * if you want the limit (max/min) macros for int types.
68  */
69 #ifndef __STDC_LIMIT_MACROS
70 #define __STDC_LIMIT_MACROS 1
71 #endif
72 
73 #include <inttypes.h>
74 typedef int8_t flex_int8_t;
75 typedef uint8_t flex_uint8_t;
76 typedef int16_t flex_int16_t;
77 typedef uint16_t flex_uint16_t;
78 typedef int32_t flex_int32_t;
79 typedef uint32_t flex_uint32_t;
80 #else
81 typedef signed char flex_int8_t;
82 typedef short int flex_int16_t;
83 typedef int flex_int32_t;
84 typedef unsigned char flex_uint8_t;
85 typedef unsigned short int flex_uint16_t;
86 typedef unsigned int flex_uint32_t;
87 
88 /* Limits of integral types. */
89 #ifndef INT8_MIN
90 #define INT8_MIN               (-128)
91 #endif
92 #ifndef INT16_MIN
93 #define INT16_MIN              (-32767-1)
94 #endif
95 #ifndef INT32_MIN
96 #define INT32_MIN              (-2147483647-1)
97 #endif
98 #ifndef INT8_MAX
99 #define INT8_MAX               (127)
100 #endif
101 #ifndef INT16_MAX
102 #define INT16_MAX              (32767)
103 #endif
104 #ifndef INT32_MAX
105 #define INT32_MAX              (2147483647)
106 #endif
107 #ifndef UINT8_MAX
108 #define UINT8_MAX              (255U)
109 #endif
110 #ifndef UINT16_MAX
111 #define UINT16_MAX             (65535U)
112 #endif
113 #ifndef UINT32_MAX
114 #define UINT32_MAX             (4294967295U)
115 #endif
116 
117 #endif /* ! C99 */
118 
119 #endif /* ! FLEXINT_H */
120 
121 /* %endif */
122 
123 /* %if-c++-only */
124 /* %endif */
125 
126 #ifdef __cplusplus
127 
128 /* The "const" storage-class-modifier is valid. */
129 #define YY_USE_CONST
130 
131 #else	/* ! __cplusplus */
132 
133 /* C99 requires __STDC__ to be defined as 1. */
134 #if defined (__STDC__)
135 
136 #define YY_USE_CONST
137 
138 #endif	/* defined (__STDC__) */
139 #endif	/* ! __cplusplus */
140 
141 #ifdef YY_USE_CONST
142 #define grecs_json_const const
143 #else
144 #define grecs_json_const
145 #endif
146 
147 /* %not-for-header */
148 
149 /* Returned upon end-of-file. */
150 #define YY_NULL 0
151 /* %ok-for-header */
152 
153 /* %not-for-header */
154 
155 /* Promotes a possibly negative, possibly signed char to an unsigned
156  * integer for use as an array index.  If the signed char is negative,
157  * we want to instead treat it as an 8-bit unsigned char, hence the
158  * double cast.
159  */
160 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
161 /* %ok-for-header */
162 
163 /* %if-reentrant */
164 /* %endif */
165 
166 /* %if-not-reentrant */
167 
168 /* %endif */
169 
170 /* Enter a start condition.  This macro really ought to take a parameter,
171  * but we do it the disgusting crufty way forced on us by the ()-less
172  * definition of BEGIN.
173  */
174 #define BEGIN (grecs_json__start) = 1 + 2 *
175 
176 /* Translate the current start state into a value that can be later handed
177  * to BEGIN to return to the state.  The YYSTATE alias is for lex
178  * compatibility.
179  */
180 #define YY_START (((grecs_json__start) - 1) / 2)
181 #define YYSTATE YY_START
182 
183 /* Action number for EOF rule of a given start state. */
184 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
185 
186 /* Special action meaning "start processing a new file". */
187 #define YY_NEW_FILE grecs_json_restart(grecs_json_in  )
188 
189 #define YY_END_OF_BUFFER_CHAR 0
190 
191 /* Size of default input buffer. */
192 #ifndef YY_BUF_SIZE
193 #ifdef __ia64__
194 /* On IA-64, the buffer size is 16k, not 8k.
195  * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
196  * Ditto for the __ia64__ case accordingly.
197  */
198 #define YY_BUF_SIZE 32768
199 #else
200 #define YY_BUF_SIZE 16384
201 #endif /* __ia64__ */
202 #endif
203 
204 /* The state buf must be large enough to hold one state per character in the main buffer.
205  */
206 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(grecs_json__state_type))
207 
208 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
209 #define YY_TYPEDEF_YY_BUFFER_STATE
210 typedef struct grecs_json__buffer_state *YY_BUFFER_STATE;
211 #endif
212 
213 #ifndef YY_TYPEDEF_YY_SIZE_T
214 #define YY_TYPEDEF_YY_SIZE_T
215 typedef size_t grecs_json__size_t;
216 #endif
217 
218 /* %if-not-reentrant */
219 extern grecs_json__size_t grecs_json_leng;
220 /* %endif */
221 
222 /* %if-c-only */
223 /* %if-not-reentrant */
224 extern FILE *grecs_json_in, *grecs_json_out;
225 /* %endif */
226 /* %endif */
227 
228 #define EOB_ACT_CONTINUE_SCAN 0
229 #define EOB_ACT_END_OF_FILE 1
230 #define EOB_ACT_LAST_MATCH 2
231 
232     #define YY_LESS_LINENO(n)
233     #define YY_LINENO_REWIND_TO(ptr)
234 
235 /* Return all but the first "n" matched characters back to the input stream. */
236 #define grecs_json_less(n) \
237 	do \
238 		{ \
239 		/* Undo effects of setting up grecs_json_text. */ \
240         int grecs_json_less_macro_arg = (n); \
241         YY_LESS_LINENO(grecs_json_less_macro_arg);\
242 		*grecs_json__cp = (grecs_json__hold_char); \
243 		YY_RESTORE_YY_MORE_OFFSET \
244 		(grecs_json__c_buf_p) = grecs_json__cp = grecs_json__bp + grecs_json_less_macro_arg - YY_MORE_ADJ; \
245 		YY_DO_BEFORE_ACTION; /* set up grecs_json_text again */ \
246 		} \
247 	while ( 0 )
248 
249 #define unput(c) grecs_json_unput( c, (grecs_json_text_ptr)  )
250 
251 #ifndef YY_STRUCT_YY_BUFFER_STATE
252 #define YY_STRUCT_YY_BUFFER_STATE
253 struct grecs_json__buffer_state
254 	{
255 /* %if-c-only */
256 	FILE *grecs_json__input_file;
257 /* %endif */
258 
259 /* %if-c++-only */
260 /* %endif */
261 
262 	char *grecs_json__ch_buf;		/* input buffer */
263 	char *grecs_json__buf_pos;		/* current position in input buffer */
264 
265 	/* Size of input buffer in bytes, not including room for EOB
266 	 * characters.
267 	 */
268 	grecs_json__size_t grecs_json__buf_size;
269 
270 	/* Number of characters read into grecs_json__ch_buf, not including EOB
271 	 * characters.
272 	 */
273 	grecs_json__size_t grecs_json__n_chars;
274 
275 	/* Whether we "own" the buffer - i.e., we know we created it,
276 	 * and can realloc() it to grow it, and should free() it to
277 	 * delete it.
278 	 */
279 	int grecs_json__is_our_buffer;
280 
281 	/* Whether this is an "interactive" input source; if so, and
282 	 * if we're using stdio for input, then we want to use getc()
283 	 * instead of fread(), to make sure we stop fetching input after
284 	 * each newline.
285 	 */
286 	int grecs_json__is_interactive;
287 
288 	/* Whether we're considered to be at the beginning of a line.
289 	 * If so, '^' rules will be active on the next match, otherwise
290 	 * not.
291 	 */
292 	int grecs_json__at_bol;
293 
294     int grecs_json__bs_lineno; /**< The line count. */
295     int grecs_json__bs_column; /**< The column count. */
296 
297 	/* Whether to try to fill the input buffer when we reach the
298 	 * end of it.
299 	 */
300 	int grecs_json__fill_buffer;
301 
302 	int grecs_json__buffer_status;
303 
304 #define YY_BUFFER_NEW 0
305 #define YY_BUFFER_NORMAL 1
306 	/* When an EOF's been seen but there's still some text to process
307 	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
308 	 * shouldn't try reading from the input source any more.  We might
309 	 * still have a bunch of tokens to match, though, because of
310 	 * possible backing-up.
311 	 *
312 	 * When we actually see the EOF, we change the status to "new"
313 	 * (via grecs_json_restart()), so that the user can continue scanning by
314 	 * just pointing grecs_json_in at a new input file.
315 	 */
316 #define YY_BUFFER_EOF_PENDING 2
317 
318 	};
319 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
320 
321 /* %if-c-only Standard (non-C++) definition */
322 /* %not-for-header */
323 
324 /* %if-not-reentrant */
325 
326 /* Stack of input buffers. */
327 static size_t grecs_json__buffer_stack_top = 0; /**< index of top of stack. */
328 static size_t grecs_json__buffer_stack_max = 0; /**< capacity of stack. */
329 static YY_BUFFER_STATE * grecs_json__buffer_stack = 0; /**< Stack as an array. */
330 /* %endif */
331 /* %ok-for-header */
332 
333 /* %endif */
334 
335 /* We provide macros for accessing buffer states in case in the
336  * future we want to put the buffer states in a more general
337  * "scanner state".
338  *
339  * Returns the top of the stack, or NULL.
340  */
341 #define YY_CURRENT_BUFFER ( (grecs_json__buffer_stack) \
342                           ? (grecs_json__buffer_stack)[(grecs_json__buffer_stack_top)] \
343                           : NULL)
344 
345 /* Same as previous macro, but useful when we know that the buffer stack is not
346  * NULL or when we need an lvalue. For internal use only.
347  */
348 #define YY_CURRENT_BUFFER_LVALUE (grecs_json__buffer_stack)[(grecs_json__buffer_stack_top)]
349 
350 /* %if-c-only Standard (non-C++) definition */
351 
352 /* %if-not-reentrant */
353 /* %not-for-header */
354 
355 /* grecs_json__hold_char holds the character lost when grecs_json_text is formed. */
356 static char grecs_json__hold_char;
357 static grecs_json__size_t grecs_json__n_chars;		/* number of characters read into grecs_json__ch_buf */
358 grecs_json__size_t grecs_json_leng;
359 
360 /* Points to current character in buffer. */
361 static char *grecs_json__c_buf_p = (char *) 0;
362 static int grecs_json__init = 0;		/* whether we need to initialize */
363 static int grecs_json__start = 0;	/* start state number */
364 
365 /* Flag which is used to allow grecs_json_wrap()'s to do buffer switches
366  * instead of setting up a fresh grecs_json_in.  A bit of a hack ...
367  */
368 static int grecs_json__did_buffer_switch_on_eof;
369 /* %ok-for-header */
370 
371 /* %endif */
372 
373 void grecs_json_restart (FILE *input_file  );
374 void grecs_json__switch_to_buffer (YY_BUFFER_STATE new_buffer  );
375 YY_BUFFER_STATE grecs_json__create_buffer (FILE *file,int size  );
376 void grecs_json__delete_buffer (YY_BUFFER_STATE b  );
377 void grecs_json__flush_buffer (YY_BUFFER_STATE b  );
378 void grecs_json_push_buffer_state (YY_BUFFER_STATE new_buffer  );
379 void grecs_json_pop_buffer_state (void );
380 
381 static void grecs_json_ensure_buffer_stack (void );
382 static void grecs_json__load_buffer_state (void );
383 static void grecs_json__init_buffer (YY_BUFFER_STATE b,FILE *file  );
384 
385 #define YY_FLUSH_BUFFER grecs_json__flush_buffer(YY_CURRENT_BUFFER )
386 
387 YY_BUFFER_STATE grecs_json__scan_buffer (char *base,grecs_json__size_t size  );
388 YY_BUFFER_STATE grecs_json__scan_string (grecs_json_const char *grecs_json__str  );
389 YY_BUFFER_STATE grecs_json__scan_bytes (grecs_json_const char *bytes,grecs_json__size_t len  );
390 
391 /* %endif */
392 
393 void *grecs_json_alloc (grecs_json__size_t  );
394 void *grecs_json_realloc (void *,grecs_json__size_t  );
395 void grecs_json_free (void *  );
396 
397 #define grecs_json__new_buffer grecs_json__create_buffer
398 
399 #define grecs_json__set_interactive(is_interactive) \
400 	{ \
401 	if ( ! YY_CURRENT_BUFFER ){ \
402         grecs_json_ensure_buffer_stack (); \
403 		YY_CURRENT_BUFFER_LVALUE =    \
404             grecs_json__create_buffer(grecs_json_in,YY_BUF_SIZE ); \
405 	} \
406 	YY_CURRENT_BUFFER_LVALUE->grecs_json__is_interactive = is_interactive; \
407 	}
408 
409 #define grecs_json__set_bol(at_bol) \
410 	{ \
411 	if ( ! YY_CURRENT_BUFFER ){\
412         grecs_json_ensure_buffer_stack (); \
413 		YY_CURRENT_BUFFER_LVALUE =    \
414             grecs_json__create_buffer(grecs_json_in,YY_BUF_SIZE ); \
415 	} \
416 	YY_CURRENT_BUFFER_LVALUE->grecs_json__at_bol = at_bol; \
417 	}
418 
419 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->grecs_json__at_bol)
420 
421 /* %% [1.0] grecs_json_text/grecs_json_in/grecs_json_out/grecs_json__state_type/grecs_json_lineno etc. def's & init go here */
422 /* Begin user sect3 */
423 
424 #define FLEX_DEBUG
425 
426 typedef unsigned char YY_CHAR;
427 
428 FILE *grecs_json_in = (FILE *) 0, *grecs_json_out = (FILE *) 0;
429 
430 typedef int grecs_json__state_type;
431 
432 extern int grecs_json_lineno;
433 
434 int grecs_json_lineno = 1;
435 
436 extern char *grecs_json_text;
437 #ifdef grecs_json_text_ptr
438 #undef grecs_json_text_ptr
439 #endif
440 #define grecs_json_text_ptr grecs_json_text
441 
442 /* %% [1.5] DFA */
443 
444 /* %if-c-only Standard (non-C++) definition */
445 
446 static grecs_json__state_type grecs_json__get_previous_state (void );
447 static grecs_json__state_type grecs_json__try_NUL_trans (grecs_json__state_type current_state  );
448 static int grecs_json__get_next_buffer (void );
449 #if defined(__GNUC__) && __GNUC__ >= 3
450 __attribute__((__noreturn__))
451 #endif
452 static void grecs_json__fatal_error (grecs_json_const char msg[]  );
453 
454 /* %endif */
455 
456 /* Done after the current pattern has been matched and before the
457  * corresponding action - sets up grecs_json_text.
458  */
459 #define YY_DO_BEFORE_ACTION \
460 	(grecs_json_text_ptr) = grecs_json__bp; \
461 /* %% [2.0] code to fiddle grecs_json_text and grecs_json_leng for grecs_json_more() goes here \ */\
462 	grecs_json_leng = (size_t) (grecs_json__cp - grecs_json__bp); \
463 	(grecs_json__hold_char) = *grecs_json__cp; \
464 	*grecs_json__cp = '\0'; \
465 /* %% [3.0] code to copy grecs_json_text_ptr to grecs_json_text[] goes here, if %array \ */\
466 	(grecs_json__c_buf_p) = grecs_json__cp;
467 
468 /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
469 #define YY_NUM_RULES 15
470 #define YY_END_OF_BUFFER 16
471 /* This struct is not used in this scanner,
472    but its presence is necessary. */
473 struct grecs_json__trans_info
474 	{
475 	flex_int32_t grecs_json__verify;
476 	flex_int32_t grecs_json__nxt;
477 	};
478 static grecs_json_const flex_int16_t grecs_json__accept[61] =
479     {   0,
480        12,   12,    0,    0,   16,   14,   12,   13,   14,   11,
481        14,    1,   14,   14,   14,   15,    5,   15,   12,    0,
482         2,    0,    1,    0,    1,    0,    0,    0,    0,    0,
483         5,    0,    7,    7,    4,    4,    1,    1,    0,    1,
484         0,    0,    0,    0,    0,    1,    0,    1,    1,    1,
485         0,    8,    9,    0,    0,    1,   10,    6,    3,    0
486     } ;
487 
488 static grecs_json_const YY_CHAR grecs_json__ec[256] =
489     {   0,
490         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
491         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
492         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
493         1,    2,    1,    4,    1,    1,    1,    1,    1,    1,
494         1,    1,    5,    6,    7,    1,    1,    8,    8,    8,
495         8,    8,    8,    8,    8,    8,    8,    9,    1,    1,
496         1,    1,    1,    1,   10,   10,   10,   10,   11,   10,
497         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
498         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
499        12,   13,   14,    1,    1,    1,   15,   10,   10,   10,
500 
501        16,   17,    1,    1,    1,    1,    1,   18,    1,   19,
502         1,    1,    1,   20,   21,   22,   23,    1,    1,    1,
503         1,    1,   24,    1,   25,    1,    1,    1,    1,    1,
504         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
505         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
506         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
507         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
508         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
509         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
510         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
511 
512         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
513         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
514         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
515         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
516         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
517         1,    1,    1,    1,    1
518     } ;
519 
520 static grecs_json_const YY_CHAR grecs_json__meta[26] =
521     {   0,
522         1,    1,    2,    1,    1,    1,    1,    3,    1,    3,
523         3,    1,    1,    1,    3,    3,    3,    1,    1,    1,
524         1,    1,    1,    1,    1
525     } ;
526 
527 static grecs_json_const flex_uint16_t grecs_json__base[73] =
528     {   0,
529         0,    0,   22,   23,  110,  131,  107,  131,   24,  131,
530       100,   22,   83,   70,   72,   27,  131,   33,   80,   38,
531       131,   44,   54,   73,   55,   67,   62,   59,   50,   43,
532       131,   68,  131,    0,  131,    0,   78,   79,   61,   80,
533        47,   49,   48,    0,    0,   89,   94,   95,   50,   96,
534        41,  131,  131,    0,    0,   45,  131,  131,  131,  131,
535       112,  115,  118,  121,  124,  127,   43,   42,   36,   31,
536        29,   26
537     } ;
538 
539 static grecs_json_const flex_int16_t grecs_json__def[73] =
540     {   0,
541        60,    1,   61,   61,   60,   60,   60,   60,   62,   60,
542        60,   63,   60,   60,   60,   64,   60,   65,   60,   62,
543        60,   66,   63,   60,   63,   60,   60,   60,   60,   64,
544        60,   65,   60,   67,   60,   68,   60,   63,   60,   60,
545        60,   60,   60,   69,   70,   60,   60,   63,   60,   60,
546        60,   60,   60,   71,   72,   60,   60,   60,   60,    0,
547        60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
548        60,   60
549     } ;
550 
551 static grecs_json_const flex_uint16_t grecs_json__nxt[157] =
552     {   0,
553         6,    7,    8,    9,    6,   10,   11,   12,   10,    6,
554         6,   10,    6,   10,    6,    6,   13,    6,   14,    6,
555         6,   15,    6,   10,   10,   17,   17,   21,   59,   25,
556        31,   58,   26,   55,   18,   18,   22,   26,   54,   32,
557        34,   21,   34,   34,   45,   44,   31,   34,   34,   34,
558        22,   36,   56,   36,   36,   32,   57,   56,   36,   36,
559        36,   25,   38,   53,   26,   26,   52,   51,   49,   26,
560        26,   39,   43,   39,   40,   34,   42,   34,   34,   41,
561        37,   19,   34,   34,   34,   46,   48,   50,   47,   26,
562        47,   29,   28,   47,   26,   47,   46,   27,   39,   47,
563 
564        39,   49,   48,   50,   47,   26,   47,   23,   19,   60,
565        26,   47,   16,   16,   16,   20,   20,   20,   24,   60,
566        24,   30,   30,   30,   33,   60,   33,   35,   60,   35,
567         5,   60,   60,   60,   60,   60,   60,   60,   60,   60,
568        60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
569        60,   60,   60,   60,   60,   60
570     } ;
571 
572 static grecs_json_const flex_int16_t grecs_json__chk[157] =
573     {   0,
574         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
575         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
576         1,    1,    1,    1,    1,    3,    4,    9,   72,   12,
577        16,   71,   12,   70,    3,    4,    9,   12,   69,   16,
578        18,   20,   18,   18,   68,   67,   30,   18,   18,   18,
579        20,   22,   56,   22,   22,   30,   51,   49,   22,   22,
580        22,   23,   25,   43,   23,   25,   42,   41,   39,   23,
581        25,   26,   29,   26,   26,   32,   28,   32,   32,   27,
582        24,   19,   32,   32,   32,   37,   38,   40,   37,   38,
583        40,   15,   14,   37,   38,   40,   46,   13,   47,   46,
584 
585        47,   47,   48,   50,   46,   48,   50,   11,    7,    5,
586        48,   50,   61,   61,   61,   62,   62,   62,   63,    0,
587        63,   64,   64,   64,   65,    0,   65,   66,    0,   66,
588        60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
589        60,   60,   60,   60,   60,   60,   60,   60,   60,   60,
590        60,   60,   60,   60,   60,   60
591     } ;
592 
593 static grecs_json__state_type grecs_json__last_accepting_state;
594 static char *grecs_json__last_accepting_cpos;
595 
596 extern int grecs_json__flex_debug;
597 int grecs_json__flex_debug = 1;
598 
599 static grecs_json_const flex_int16_t grecs_json__rule_linenum[15] =
600     {   0,
601       169,  173,  177,  182,  192,  197,  201,  210,  211,  212,
602       213,  214,  215,  216
603     } ;
604 
605 /* The intent behind this definition is that it'll catch
606  * any uses of REJECT which flex missed.
607  */
608 #define REJECT reject_used_but_not_detected
609 #define grecs_json_more() grecs_json_more_used_but_not_detected
610 #define YY_MORE_ADJ 0
611 #define YY_RESTORE_YY_MORE_OFFSET
612 char *grecs_json_text;
613 #line 1 "json-lex.l"
614 #define YY_NO_INPUT 1
615 
616 #line 9 "json-lex.l"
617 /* This file is part of Grecs.
618    Copyright (C) 2012-2016 Sergey Poznyakoff.
619 
620    Grecs is free software; you can redistribute it and/or modify
621    it under the terms of the GNU General Public License as published by
622    the Free Software Foundation; either version 3, or (at your option)
623    any later version.
624 
625    Grecs is distributed in the hope that it will be useful,
626    but WITHOUT ANY WARRANTY; without even the implied warranty of
627    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
628    GNU General Public License for more details.
629 
630    You should have received a copy of the GNU General Public License
631    along with Grecs.  If not, see <http://www.gnu.org/licenses/>. */
632 
633 #include "grecs.h"
634 #include "json-gram.h"
635 #include "grecs/json.h"
636 
637 static char const *input_ptr;
638 static size_t input_size;
639 struct grecs_locus_point json_current_locus_point;   /* Input location */
640 
641 char const *json_err_diag;
642 struct grecs_locus json_err_locus;
643 
644 #undef YY_INPUT
645 #define YY_INPUT(buf,result,max_size)					\
646 	do {								\
647 		size_t n = (max_size > input_size) ? input_size : max_size; \
648 		if (n) {						\
649 			memcpy(buf, input_ptr, n);			\
650 			input_ptr += n;					\
651 			input_size -= n;				\
652 		}							\
653 		result = n;						\
654 	} while(0)
655 
656 #define YY_USER_ACTION do {						\
657 		if (YYSTATE == 0) {					\
658 			grecs_json_lloc.beg = json_current_locus_point;		\
659 			grecs_json_lloc.beg.col++;				\
660 		}							\
661   		json_current_locus_point.col += grecs_json_leng;			\
662  		grecs_json_lloc.end = json_current_locus_point;			\
663    	} while (0);
664 
665 void
jsonlex_diag(const char * s)666 jsonlex_diag(const char *s)
667 {
668 	if (!json_err_diag) {
669 		json_err_diag = s;
670 		json_err_locus = grecs_json_lloc;
671 	}
672 }
673 
674 static int
utf8_wctomb(char * u)675 utf8_wctomb(char *u)
676 {
677 	unsigned int wc = strtoul(u, NULL, 16);
678 	int count;
679 	char r[6];
680 
681 	if (wc < 0x80)
682 		count = 1;
683 	else if (wc < 0x800)
684 		count = 2;
685 	else if (wc < 0x10000)
686 		count = 3;
687 	else if (wc < 0x200000)
688 		count = 4;
689 	else if (wc < 0x4000000)
690 		count = 5;
691 	else if (wc <= 0x7fffffff)
692 		count = 6;
693 	else
694 		return -1;
695 
696 	switch (count) {
697 		/* Note: code falls through cases! */
698 	case 6:
699 		r[5] = 0x80 | (wc & 0x3f);
700 		wc = wc >> 6;
701 		wc |= 0x4000000;
702 	case 5:
703 		r[4] = 0x80 | (wc & 0x3f);
704 		wc = wc >> 6;
705 		wc |= 0x200000;
706 	case 4:
707 		r[3] = 0x80 | (wc & 0x3f);
708 		wc = wc >> 6;
709 		wc |= 0x10000;
710 	case 3:
711 		r[2] = 0x80 | (wc & 0x3f);
712 		wc = wc >> 6;
713 		wc |= 0x800;
714 	case 2:
715 		r[1] = 0x80 | (wc & 0x3f);
716 		wc = wc >> 6;
717 		wc |= 0xc0;
718 	case 1:
719 		r[0] = wc;
720 	}
721 	grecs_line_acc_grow(r, count);
722 	return count;
723 }
724 
725 int
json_unescape(char c,char * o)726 json_unescape(char c, char *o)
727 {
728 	static char transtab[] = "\\\\\"\"b\bf\fn\nr\rt\t";
729 	char *p;
730 
731 	for (p = transtab; *p; p += 2) {
732 		if (p[0] == c) {
733 			*o = p[1];
734 			return 0;
735 		}
736 	}
737 	return -1;
738 }
739 
740 #define YY_SKIP_YYWRAP 1
741 static int
grecs_json_wrap()742 grecs_json_wrap()
743 {
744 	return 1;
745 }
746 
747 static struct grecs_txtacc *json_line_acc;
748 
749 static void
json_line_begin()750 json_line_begin()
751 {
752 	if (!json_line_acc)
753 		json_line_acc = grecs_txtacc_create();
754 }
755 
756 static char *
json_line_finish()757 json_line_finish()
758 {
759 	if (json_line_acc) {
760 		char nil = 0;
761 		grecs_txtacc_grow(json_line_acc, &nil, 1);
762 		return grecs_txtacc_finish(json_line_acc, 1);
763 	}
764 	return NULL;
765 }
766 
767 static void
json_line_grow(char const * text,size_t len)768 json_line_grow(char const *text, size_t len)
769 {
770 	grecs_txtacc_grow(json_line_acc, text, len);
771 }
772 
773 #line 774 "json-lex.c"
774 
775 #define INITIAL 0
776 #define STR 1
777 
778 #ifndef YY_NO_UNISTD_H
779 /* Special case for "unistd.h", since it is non-ANSI. We include it way
780  * down here because we want the user's section 1 to have been scanned first.
781  * The user has a chance to override it with an option.
782  */
783 /* %if-c-only */
784 #include <unistd.h>
785 /* %endif */
786 /* %if-c++-only */
787 /* %endif */
788 #endif
789 
790 #ifndef YY_EXTRA_TYPE
791 #define YY_EXTRA_TYPE void *
792 #endif
793 
794 /* %if-c-only Reentrant structure and macros (non-C++). */
795 /* %if-reentrant */
796 /* %if-c-only */
797 
798 static int grecs_json__init_globals (void );
799 
800 /* %endif */
801 /* %if-reentrant */
802 /* %endif */
803 /* %endif End reentrant structures and macros. */
804 
805 /* Accessor methods to globals.
806    These are made visible to non-reentrant scanners for convenience. */
807 
808 int grecs_json_lex_destroy (void );
809 
810 int grecs_json_get_debug (void );
811 
812 void grecs_json_set_debug (int debug_flag  );
813 
814 YY_EXTRA_TYPE grecs_json_get_extra (void );
815 
816 void grecs_json_set_extra (YY_EXTRA_TYPE user_defined  );
817 
818 FILE *grecs_json_get_in (void );
819 
820 void grecs_json_set_in  (FILE * _in_str  );
821 
822 FILE *grecs_json_get_out (void );
823 
824 void grecs_json_set_out  (FILE * _out_str  );
825 
826 grecs_json__size_t grecs_json_get_leng (void );
827 
828 char *grecs_json_get_text (void );
829 
830 int grecs_json_get_lineno (void );
831 
832 void grecs_json_set_lineno (int _line_number  );
833 
834 /* %if-bison-bridge */
835 /* %endif */
836 
837 /* Macros after this point can all be overridden by user definitions in
838  * section 1.
839  */
840 
841 #ifndef YY_SKIP_YYWRAP
842 #ifdef __cplusplus
843 extern "C" int grecs_json_wrap (void );
844 #else
845 extern int grecs_json_wrap (void );
846 #endif
847 #endif
848 
849 /* %not-for-header */
850 
851 #ifndef YY_NO_UNPUT
852 
853 #endif
854 /* %ok-for-header */
855 
856 /* %endif */
857 
858 #ifndef grecs_json_text_ptr
859 static void grecs_json__flex_strncpy (char *,grecs_json_const char *,int );
860 #endif
861 
862 #ifdef YY_NEED_STRLEN
863 static int grecs_json__flex_strlen (grecs_json_const char * );
864 #endif
865 
866 #ifndef YY_NO_INPUT
867 /* %if-c-only Standard (non-C++) definition */
868 /* %not-for-header */
869 
870 #ifdef __cplusplus
871 static int grecs_json_input (void );
872 #else
873 static int input (void );
874 #endif
875 /* %ok-for-header */
876 
877 /* %endif */
878 #endif
879 
880 /* %if-c-only */
881 
882 /* %endif */
883 
884 /* Amount of stuff to slurp up with each read. */
885 #ifndef YY_READ_BUF_SIZE
886 #ifdef __ia64__
887 /* On IA-64, the buffer size is 16k, not 8k */
888 #define YY_READ_BUF_SIZE 16384
889 #else
890 #define YY_READ_BUF_SIZE 8192
891 #endif /* __ia64__ */
892 #endif
893 
894 /* Copy whatever the last rule matched to the standard output. */
895 #ifndef ECHO
896 /* %if-c-only Standard (non-C++) definition */
897 /* This used to be an fputs(), but since the string might contain NUL's,
898  * we now use fwrite().
899  */
900 #define ECHO do { if (fwrite( grecs_json_text, grecs_json_leng, 1, grecs_json_out )) {} } while (0)
901 /* %endif */
902 /* %if-c++-only C++ definition */
903 /* %endif */
904 #endif
905 
906 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
907  * is returned in "result".
908  */
909 #ifndef YY_INPUT
910 #define YY_INPUT(buf,result,max_size) \
911 /* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
912 	if ( YY_CURRENT_BUFFER_LVALUE->grecs_json__is_interactive ) \
913 		{ \
914 		int c = '*'; \
915 		size_t n; \
916 		for ( n = 0; n < max_size && \
917 			     (c = getc( grecs_json_in )) != EOF && c != '\n'; ++n ) \
918 			buf[n] = (char) c; \
919 		if ( c == '\n' ) \
920 			buf[n++] = (char) c; \
921 		if ( c == EOF && ferror( grecs_json_in ) ) \
922 			YY_FATAL_ERROR( "input in flex scanner failed" ); \
923 		result = n; \
924 		} \
925 	else \
926 		{ \
927 		errno=0; \
928 		while ( (result = fread(buf, 1, max_size, grecs_json_in))==0 && ferror(grecs_json_in)) \
929 			{ \
930 			if( errno != EINTR) \
931 				{ \
932 				YY_FATAL_ERROR( "input in flex scanner failed" ); \
933 				break; \
934 				} \
935 			errno=0; \
936 			clearerr(grecs_json_in); \
937 			} \
938 		}\
939 \
940 /* %if-c++-only C++ definition \ */\
941 /* %endif */
942 
943 #endif
944 
945 /* No semi-colon after return; correct usage is to write "grecs_json_terminate();" -
946  * we don't want an extra ';' after the "return" because that will cause
947  * some compilers to complain about unreachable statements.
948  */
949 #ifndef grecs_json_terminate
950 #define grecs_json_terminate() return YY_NULL
951 #endif
952 
953 /* Number of entries by which start-condition stack grows. */
954 #ifndef YY_START_STACK_INCR
955 #define YY_START_STACK_INCR 25
956 #endif
957 
958 /* Report a fatal error. */
959 #ifndef YY_FATAL_ERROR
960 /* %if-c-only */
961 #define YY_FATAL_ERROR(msg) grecs_json__fatal_error( msg )
962 /* %endif */
963 /* %if-c++-only */
964 /* %endif */
965 #endif
966 
967 /* %if-tables-serialization structures and prototypes */
968 /* %not-for-header */
969 
970 /* %ok-for-header */
971 
972 /* %not-for-header */
973 
974 /* %tables-grecs_json_dmap generated elements */
975 /* %endif */
976 /* end tables serialization structures and prototypes */
977 
978 /* %ok-for-header */
979 
980 /* Default declaration of generated scanner - a define so the user can
981  * easily add parameters.
982  */
983 #ifndef YY_DECL
984 #define YY_DECL_IS_OURS 1
985 /* %if-c-only Standard (non-C++) definition */
986 
987 extern int grecs_json_lex (void);
988 
989 #define YY_DECL int grecs_json_lex (void)
990 /* %endif */
991 /* %if-c++-only C++ definition */
992 /* %endif */
993 #endif /* !YY_DECL */
994 
995 /* Code executed at the beginning of each rule, after grecs_json_text and grecs_json_leng
996  * have been set up.
997  */
998 #ifndef YY_USER_ACTION
999 #define YY_USER_ACTION
1000 #endif
1001 
1002 /* Code executed at the end of each rule. */
1003 #ifndef YY_BREAK
1004 #define YY_BREAK /*LINTED*/break;
1005 #endif
1006 
1007 /* %% [6.0] YY_RULE_SETUP definition goes here */
1008 #define YY_RULE_SETUP \
1009 	YY_USER_ACTION
1010 
1011 /* %not-for-header */
1012 
1013 /** The main scanner function which does all the work.
1014  */
1015 YY_DECL
1016 {
1017 	grecs_json__state_type grecs_json__current_state;
1018 	char *grecs_json__cp, *grecs_json__bp;
1019 	int grecs_json__act;
1020 
1021 	if ( !(grecs_json__init) )
1022 		{
1023 		(grecs_json__init) = 1;
1024 
1025 #ifdef YY_USER_INIT
1026 		YY_USER_INIT;
1027 #endif
1028 
1029 		if ( ! (grecs_json__start) )
1030 			(grecs_json__start) = 1;	/* first start state */
1031 
1032 		if ( ! grecs_json_in )
1033 /* %if-c-only */
1034 			grecs_json_in = stdin;
1035 /* %endif */
1036 /* %if-c++-only */
1037 /* %endif */
1038 
1039 		if ( ! grecs_json_out )
1040 /* %if-c-only */
1041 			grecs_json_out = stdout;
1042 /* %endif */
1043 /* %if-c++-only */
1044 /* %endif */
1045 
1046 		if ( ! YY_CURRENT_BUFFER ) {
1047 			grecs_json_ensure_buffer_stack ();
1048 			YY_CURRENT_BUFFER_LVALUE =
1049 				grecs_json__create_buffer(grecs_json_in,YY_BUF_SIZE );
1050 		}
1051 
1052 		grecs_json__load_buffer_state( );
1053 		}
1054 
1055 	{
1056 /* %% [7.0] user's declarations go here */
1057 #line 168 "json-lex.l"
1058 
1059 #line 1060 "json-lex.c"
1060 
1061 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
1062 		{
1063 /* %% [8.0] grecs_json_more()-related code goes here */
1064 		grecs_json__cp = (grecs_json__c_buf_p);
1065 
1066 		/* Support of grecs_json_text. */
1067 		*grecs_json__cp = (grecs_json__hold_char);
1068 
1069 		/* grecs_json__bp points to the position in grecs_json__ch_buf of the start of
1070 		 * the current run.
1071 		 */
1072 		grecs_json__bp = grecs_json__cp;
1073 
1074 /* %% [9.0] code to set up and find next match goes here */
1075 		grecs_json__current_state = (grecs_json__start);
1076 grecs_json__match:
1077 		do
1078 			{
1079 			YY_CHAR grecs_json__c = grecs_json__ec[YY_SC_TO_UI(*grecs_json__cp)] ;
1080 			if ( grecs_json__accept[grecs_json__current_state] )
1081 				{
1082 				(grecs_json__last_accepting_state) = grecs_json__current_state;
1083 				(grecs_json__last_accepting_cpos) = grecs_json__cp;
1084 				}
1085 			while ( grecs_json__chk[grecs_json__base[grecs_json__current_state] + grecs_json__c] != grecs_json__current_state )
1086 				{
1087 				grecs_json__current_state = (int) grecs_json__def[grecs_json__current_state];
1088 				if ( grecs_json__current_state >= 61 )
1089 					grecs_json__c = grecs_json__meta[(unsigned int) grecs_json__c];
1090 				}
1091 			grecs_json__current_state = grecs_json__nxt[grecs_json__base[grecs_json__current_state] + (unsigned int) grecs_json__c];
1092 			++grecs_json__cp;
1093 			}
1094 		while ( grecs_json__base[grecs_json__current_state] != 131 );
1095 
1096 grecs_json__find_action:
1097 /* %% [10.0] code to find the action number goes here */
1098 		grecs_json__act = grecs_json__accept[grecs_json__current_state];
1099 		if ( grecs_json__act == 0 )
1100 			{ /* have to back up */
1101 			grecs_json__cp = (grecs_json__last_accepting_cpos);
1102 			grecs_json__current_state = (grecs_json__last_accepting_state);
1103 			grecs_json__act = grecs_json__accept[grecs_json__current_state];
1104 			}
1105 
1106 		YY_DO_BEFORE_ACTION;
1107 
1108 /* %% [11.0] code for grecs_json_lineno update goes here */
1109 
1110 do_action:	/* This label is used only to access EOF actions. */
1111 
1112 /* %% [12.0] debug code goes here */
1113 		if ( grecs_json__flex_debug )
1114 			{
1115 			if ( grecs_json__act == 0 )
1116 				fprintf( stderr, "--scanner backing up\n" );
1117 			else if ( grecs_json__act < 15 )
1118 				fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
1119 				         (long)grecs_json__rule_linenum[grecs_json__act], grecs_json_text );
1120 			else if ( grecs_json__act == 15 )
1121 				fprintf( stderr, "--accepting default rule (\"%s\")\n",
1122 				         grecs_json_text );
1123 			else if ( grecs_json__act == 16 )
1124 				fprintf( stderr, "--(end of buffer or a NUL)\n" );
1125 			else
1126 				fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
1127 			}
1128 
1129 		switch ( grecs_json__act )
1130 	{ /* beginning of action switch */
1131 /* %% [13.0] actions go here */
1132 			case 0: /* must back up */
1133 			/* undo the effects of YY_DO_BEFORE_ACTION */
1134 			*grecs_json__cp = (grecs_json__hold_char);
1135 			grecs_json__cp = (grecs_json__last_accepting_cpos);
1136 			grecs_json__current_state = (grecs_json__last_accepting_state);
1137 			goto grecs_json__find_action;
1138 
1139 case 1:
1140 YY_RULE_SETUP
1141 #line 169 "json-lex.l"
1142 {
1143 	grecs_json_lval.n = strtod(grecs_json_text, NULL);
1144 	return T_NUMBER;
1145       }
1146 	YY_BREAK
1147 case 2:
1148 /* rule 2 can match eol */
1149 YY_RULE_SETUP
1150 #line 173 "json-lex.l"
1151 { json_line_begin();
1152                      json_line_grow(grecs_json_text + 1, grecs_json_leng - 2);
1153                      grecs_json_lval.s = json_line_finish();
1154                      return T_STRING; }
1155 	YY_BREAK
1156 case 3:
1157 /* rule 3 can match eol */
1158 YY_RULE_SETUP
1159 #line 177 "json-lex.l"
1160 { BEGIN(STR);
1161                      json_line_begin();
1162                      json_line_grow(grecs_json_text + 1, grecs_json_leng - 5);
1163                      utf8_wctomb(grecs_json_text + grecs_json_leng - 4);
1164                    }
1165 	YY_BREAK
1166 case 4:
1167 /* rule 4 can match eol */
1168 YY_RULE_SETUP
1169 #line 182 "json-lex.l"
1170 { char c;
1171                      BEGIN(STR);
1172                      json_line_begin();
1173                      json_line_grow(grecs_json_text + 1, grecs_json_leng - 3);
1174                      if (json_unescape(grecs_json_text[grecs_json_leng - 1], &c)) {
1175                              jsonlex_diag("invalid UTF-8 codepoint");
1176                              return T_ERR;
1177                      }
1178 		     json_line_grow(&c, 1);
1179                    }
1180 	YY_BREAK
1181 case 5:
1182 /* rule 5 can match eol */
1183 YY_RULE_SETUP
1184 #line 192 "json-lex.l"
1185 { BEGIN(INITIAL);
1186                         if (grecs_json_leng > 1)
1187 				json_line_grow(grecs_json_text, grecs_json_leng - 1);
1188                         grecs_json_lval.s = json_line_finish();
1189 	                return T_STRING; }
1190 	YY_BREAK
1191 case 6:
1192 /* rule 6 can match eol */
1193 YY_RULE_SETUP
1194 #line 197 "json-lex.l"
1195 {
1196                      json_line_grow(grecs_json_text, grecs_json_leng - 5);
1197                      utf8_wctomb(grecs_json_text + grecs_json_leng - 4);
1198 }
1199 	YY_BREAK
1200 case 7:
1201 /* rule 7 can match eol */
1202 YY_RULE_SETUP
1203 #line 201 "json-lex.l"
1204 {
1205                      char c;
1206                      json_line_grow(grecs_json_text, grecs_json_leng - 2);
1207                      if (json_unescape(grecs_json_text[grecs_json_leng - 1], &c)) {
1208                              jsonlex_diag("invalid UTF-8 codepoint");
1209                              return T_ERR;
1210                      }
1211                      json_line_grow(&c, 1); }
1212 	YY_BREAK
1213 case 8:
1214 YY_RULE_SETUP
1215 #line 210 "json-lex.l"
1216 { return T_NULL; }
1217 	YY_BREAK
1218 case 9:
1219 YY_RULE_SETUP
1220 #line 211 "json-lex.l"
1221 { grecs_json_lval.b = 1; return T_BOOL; }
1222 	YY_BREAK
1223 case 10:
1224 YY_RULE_SETUP
1225 #line 212 "json-lex.l"
1226 { grecs_json_lval.b = 0; return T_BOOL; }
1227 	YY_BREAK
1228 case 11:
1229 YY_RULE_SETUP
1230 #line 213 "json-lex.l"
1231 return grecs_json_text[0];
1232 	YY_BREAK
1233 case 12:
1234 YY_RULE_SETUP
1235 #line 214 "json-lex.l"
1236 ;
1237 	YY_BREAK
1238 case 13:
1239 /* rule 13 can match eol */
1240 YY_RULE_SETUP
1241 #line 215 "json-lex.l"
1242 grecs_locus_point_advance_line(json_current_locus_point);
1243 	YY_BREAK
1244 case 14:
1245 YY_RULE_SETUP
1246 #line 216 "json-lex.l"
1247 { jsonlex_diag("bogus character");
1248             return T_ERR; }
1249 	YY_BREAK
1250 case 15:
1251 YY_RULE_SETUP
1252 #line 218 "json-lex.l"
1253 ECHO;
1254 	YY_BREAK
1255 #line 1256 "json-lex.c"
1256 case YY_STATE_EOF(INITIAL):
1257 case YY_STATE_EOF(STR):
1258 	grecs_json_terminate();
1259 
1260 	case YY_END_OF_BUFFER:
1261 		{
1262 		/* Amount of text matched not including the EOB char. */
1263 		int grecs_json__amount_of_matched_text = (int) (grecs_json__cp - (grecs_json_text_ptr)) - 1;
1264 
1265 		/* Undo the effects of YY_DO_BEFORE_ACTION. */
1266 		*grecs_json__cp = (grecs_json__hold_char);
1267 		YY_RESTORE_YY_MORE_OFFSET
1268 
1269 		if ( YY_CURRENT_BUFFER_LVALUE->grecs_json__buffer_status == YY_BUFFER_NEW )
1270 			{
1271 			/* We're scanning a new file or input source.  It's
1272 			 * possible that this happened because the user
1273 			 * just pointed grecs_json_in at a new source and called
1274 			 * grecs_json_lex().  If so, then we have to assure
1275 			 * consistency between YY_CURRENT_BUFFER and our
1276 			 * globals.  Here is the right place to do so, because
1277 			 * this is the first action (other than possibly a
1278 			 * back-up) that will match for the new input source.
1279 			 */
1280 			(grecs_json__n_chars) = YY_CURRENT_BUFFER_LVALUE->grecs_json__n_chars;
1281 /* %if-c-only */
1282 			YY_CURRENT_BUFFER_LVALUE->grecs_json__input_file = grecs_json_in;
1283 /* %endif */
1284 /* %if-c++-only */
1285 /* %endif */
1286 			YY_CURRENT_BUFFER_LVALUE->grecs_json__buffer_status = YY_BUFFER_NORMAL;
1287 			}
1288 
1289 		/* Note that here we test for grecs_json__c_buf_p "<=" to the position
1290 		 * of the first EOB in the buffer, since grecs_json__c_buf_p will
1291 		 * already have been incremented past the NUL character
1292 		 * (since all states make transitions on EOB to the
1293 		 * end-of-buffer state).  Contrast this with the test
1294 		 * in input().
1295 		 */
1296 		if ( (grecs_json__c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf[(grecs_json__n_chars)] )
1297 			{ /* This was really a NUL. */
1298 			grecs_json__state_type grecs_json__next_state;
1299 
1300 			(grecs_json__c_buf_p) = (grecs_json_text_ptr) + grecs_json__amount_of_matched_text;
1301 
1302 			grecs_json__current_state = grecs_json__get_previous_state(  );
1303 
1304 			/* Okay, we're now positioned to make the NUL
1305 			 * transition.  We couldn't have
1306 			 * grecs_json__get_previous_state() go ahead and do it
1307 			 * for us because it doesn't know how to deal
1308 			 * with the possibility of jamming (and we don't
1309 			 * want to build jamming into it because then it
1310 			 * will run more slowly).
1311 			 */
1312 
1313 			grecs_json__next_state = grecs_json__try_NUL_trans( grecs_json__current_state );
1314 
1315 			grecs_json__bp = (grecs_json_text_ptr) + YY_MORE_ADJ;
1316 
1317 			if ( grecs_json__next_state )
1318 				{
1319 				/* Consume the NUL. */
1320 				grecs_json__cp = ++(grecs_json__c_buf_p);
1321 				grecs_json__current_state = grecs_json__next_state;
1322 				goto grecs_json__match;
1323 				}
1324 
1325 			else
1326 				{
1327 /* %% [14.0] code to do back-up for compressed tables and set up grecs_json__cp goes here */
1328 				grecs_json__cp = (grecs_json__c_buf_p);
1329 				goto grecs_json__find_action;
1330 				}
1331 			}
1332 
1333 		else switch ( grecs_json__get_next_buffer(  ) )
1334 			{
1335 			case EOB_ACT_END_OF_FILE:
1336 				{
1337 				(grecs_json__did_buffer_switch_on_eof) = 0;
1338 
1339 				if ( grecs_json_wrap( ) )
1340 					{
1341 					/* Note: because we've taken care in
1342 					 * grecs_json__get_next_buffer() to have set up
1343 					 * grecs_json_text, we can now set up
1344 					 * grecs_json__c_buf_p so that if some total
1345 					 * hoser (like flex itself) wants to
1346 					 * call the scanner after we return the
1347 					 * YY_NULL, it'll still work - another
1348 					 * YY_NULL will get returned.
1349 					 */
1350 					(grecs_json__c_buf_p) = (grecs_json_text_ptr) + YY_MORE_ADJ;
1351 
1352 					grecs_json__act = YY_STATE_EOF(YY_START);
1353 					goto do_action;
1354 					}
1355 
1356 				else
1357 					{
1358 					if ( ! (grecs_json__did_buffer_switch_on_eof) )
1359 						YY_NEW_FILE;
1360 					}
1361 				break;
1362 				}
1363 
1364 			case EOB_ACT_CONTINUE_SCAN:
1365 				(grecs_json__c_buf_p) =
1366 					(grecs_json_text_ptr) + grecs_json__amount_of_matched_text;
1367 
1368 				grecs_json__current_state = grecs_json__get_previous_state(  );
1369 
1370 				grecs_json__cp = (grecs_json__c_buf_p);
1371 				grecs_json__bp = (grecs_json_text_ptr) + YY_MORE_ADJ;
1372 				goto grecs_json__match;
1373 
1374 			case EOB_ACT_LAST_MATCH:
1375 				(grecs_json__c_buf_p) =
1376 				&YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf[(grecs_json__n_chars)];
1377 
1378 				grecs_json__current_state = grecs_json__get_previous_state(  );
1379 
1380 				grecs_json__cp = (grecs_json__c_buf_p);
1381 				grecs_json__bp = (grecs_json_text_ptr) + YY_MORE_ADJ;
1382 				goto grecs_json__find_action;
1383 			}
1384 		break;
1385 		}
1386 
1387 	default:
1388 		YY_FATAL_ERROR(
1389 			"fatal flex scanner internal error--no action found" );
1390 	} /* end of action switch */
1391 		} /* end of scanning one token */
1392 	} /* end of user's declarations */
1393 } /* end of grecs_json_lex */
1394 /* %ok-for-header */
1395 
1396 /* %if-c++-only */
1397 /* %not-for-header */
1398 
1399 /* %ok-for-header */
1400 
1401 /* %endif */
1402 
1403 /* grecs_json__get_next_buffer - try to read in a new buffer
1404  *
1405  * Returns a code representing an action:
1406  *	EOB_ACT_LAST_MATCH -
1407  *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1408  *	EOB_ACT_END_OF_FILE - end of file
1409  */
1410 /* %if-c-only */
grecs_json__get_next_buffer(void)1411 static int grecs_json__get_next_buffer (void)
1412 /* %endif */
1413 /* %if-c++-only */
1414 /* %endif */
1415 {
1416     	char *dest = YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf;
1417 	char *source = (grecs_json_text_ptr);
1418 	grecs_json__size_t number_to_move, i;
1419 	int ret_val;
1420 
1421 	if ( (grecs_json__c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf[(grecs_json__n_chars) + 1] )
1422 		YY_FATAL_ERROR(
1423 		"fatal flex scanner internal error--end of buffer missed" );
1424 
1425 	if ( YY_CURRENT_BUFFER_LVALUE->grecs_json__fill_buffer == 0 )
1426 		{ /* Don't try to fill the buffer, so this is an EOF. */
1427 		if ( (grecs_json__c_buf_p) - (grecs_json_text_ptr) - YY_MORE_ADJ == 1 )
1428 			{
1429 			/* We matched a single character, the EOB, so
1430 			 * treat this as a final EOF.
1431 			 */
1432 			return EOB_ACT_END_OF_FILE;
1433 			}
1434 
1435 		else
1436 			{
1437 			/* We matched some text prior to the EOB, first
1438 			 * process it.
1439 			 */
1440 			return EOB_ACT_LAST_MATCH;
1441 			}
1442 		}
1443 
1444 	/* Try to read more data. */
1445 
1446 	/* First move last chars to start of buffer. */
1447 	number_to_move = (grecs_json__size_t) ((grecs_json__c_buf_p) - (grecs_json_text_ptr)) - 1;
1448 
1449 	for ( i = 0; i < number_to_move; ++i )
1450 		*(dest++) = *(source++);
1451 
1452 	if ( YY_CURRENT_BUFFER_LVALUE->grecs_json__buffer_status == YY_BUFFER_EOF_PENDING )
1453 		/* don't do the read, it's not guaranteed to return an EOF,
1454 		 * just force an EOF
1455 		 */
1456 		YY_CURRENT_BUFFER_LVALUE->grecs_json__n_chars = (grecs_json__n_chars) = 0;
1457 
1458 	else
1459 		{
1460 			grecs_json__size_t num_to_read =
1461 			YY_CURRENT_BUFFER_LVALUE->grecs_json__buf_size - number_to_move - 1;
1462 
1463 		while ( num_to_read <= 0 )
1464 			{ /* Not enough room in the buffer - grow it. */
1465 
1466 			/* just a shorter name for the current buffer */
1467 			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1468 
1469 			int grecs_json__c_buf_p_offset =
1470 				(int) ((grecs_json__c_buf_p) - b->grecs_json__ch_buf);
1471 
1472 			if ( b->grecs_json__is_our_buffer )
1473 				{
1474 				grecs_json__size_t new_size = b->grecs_json__buf_size * 2;
1475 
1476 				if ( new_size <= 0 )
1477 					b->grecs_json__buf_size += b->grecs_json__buf_size / 8;
1478 				else
1479 					b->grecs_json__buf_size *= 2;
1480 
1481 				b->grecs_json__ch_buf = (char *)
1482 					/* Include room in for 2 EOB chars. */
1483 					grecs_json_realloc((void *) b->grecs_json__ch_buf,b->grecs_json__buf_size + 2  );
1484 				}
1485 			else
1486 				/* Can't grow it, we don't own it. */
1487 				b->grecs_json__ch_buf = 0;
1488 
1489 			if ( ! b->grecs_json__ch_buf )
1490 				YY_FATAL_ERROR(
1491 				"fatal error - scanner input buffer overflow" );
1492 
1493 			(grecs_json__c_buf_p) = &b->grecs_json__ch_buf[grecs_json__c_buf_p_offset];
1494 
1495 			num_to_read = YY_CURRENT_BUFFER_LVALUE->grecs_json__buf_size -
1496 						number_to_move - 1;
1497 
1498 			}
1499 
1500 		if ( num_to_read > YY_READ_BUF_SIZE )
1501 			num_to_read = YY_READ_BUF_SIZE;
1502 
1503 		/* Read in more data. */
1504 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf[number_to_move]),
1505 			(grecs_json__n_chars), num_to_read );
1506 
1507 		YY_CURRENT_BUFFER_LVALUE->grecs_json__n_chars = (grecs_json__n_chars);
1508 		}
1509 
1510 	if ( (grecs_json__n_chars) == 0 )
1511 		{
1512 		if ( number_to_move == YY_MORE_ADJ )
1513 			{
1514 			ret_val = EOB_ACT_END_OF_FILE;
1515 			grecs_json_restart(grecs_json_in  );
1516 			}
1517 
1518 		else
1519 			{
1520 			ret_val = EOB_ACT_LAST_MATCH;
1521 			YY_CURRENT_BUFFER_LVALUE->grecs_json__buffer_status =
1522 				YY_BUFFER_EOF_PENDING;
1523 			}
1524 		}
1525 
1526 	else
1527 		ret_val = EOB_ACT_CONTINUE_SCAN;
1528 
1529 	if ((grecs_json__size_t) ((grecs_json__n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->grecs_json__buf_size) {
1530 		/* Extend the array by 50%, plus the number we really need. */
1531 		grecs_json__size_t new_size = (grecs_json__n_chars) + number_to_move + ((grecs_json__n_chars) >> 1);
1532 		YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf = (char *) grecs_json_realloc((void *) YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf,new_size  );
1533 		if ( ! YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf )
1534 			YY_FATAL_ERROR( "out of dynamic memory in grecs_json__get_next_buffer()" );
1535 	}
1536 
1537 	(grecs_json__n_chars) += number_to_move;
1538 	YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf[(grecs_json__n_chars)] = YY_END_OF_BUFFER_CHAR;
1539 	YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf[(grecs_json__n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1540 
1541 	(grecs_json_text_ptr) = &YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf[0];
1542 
1543 	return ret_val;
1544 }
1545 
1546 /* grecs_json__get_previous_state - get the state just before the EOB char was reached */
1547 
1548 /* %if-c-only */
1549 /* %not-for-header */
1550 
grecs_json__get_previous_state(void)1551     static grecs_json__state_type grecs_json__get_previous_state (void)
1552 /* %endif */
1553 /* %if-c++-only */
1554 /* %endif */
1555 {
1556 	grecs_json__state_type grecs_json__current_state;
1557 	char *grecs_json__cp;
1558 
1559 /* %% [15.0] code to get the start state into grecs_json__current_state goes here */
1560 	grecs_json__current_state = (grecs_json__start);
1561 
1562 	for ( grecs_json__cp = (grecs_json_text_ptr) + YY_MORE_ADJ; grecs_json__cp < (grecs_json__c_buf_p); ++grecs_json__cp )
1563 		{
1564 /* %% [16.0] code to find the next state goes here */
1565 		YY_CHAR grecs_json__c = (*grecs_json__cp ? grecs_json__ec[YY_SC_TO_UI(*grecs_json__cp)] : 1);
1566 		if ( grecs_json__accept[grecs_json__current_state] )
1567 			{
1568 			(grecs_json__last_accepting_state) = grecs_json__current_state;
1569 			(grecs_json__last_accepting_cpos) = grecs_json__cp;
1570 			}
1571 		while ( grecs_json__chk[grecs_json__base[grecs_json__current_state] + grecs_json__c] != grecs_json__current_state )
1572 			{
1573 			grecs_json__current_state = (int) grecs_json__def[grecs_json__current_state];
1574 			if ( grecs_json__current_state >= 61 )
1575 				grecs_json__c = grecs_json__meta[(unsigned int) grecs_json__c];
1576 			}
1577 		grecs_json__current_state = grecs_json__nxt[grecs_json__base[grecs_json__current_state] + (unsigned int) grecs_json__c];
1578 		}
1579 
1580 	return grecs_json__current_state;
1581 }
1582 
1583 /* grecs_json__try_NUL_trans - try to make a transition on the NUL character
1584  *
1585  * synopsis
1586  *	next_state = grecs_json__try_NUL_trans( current_state );
1587  */
1588 /* %if-c-only */
grecs_json__try_NUL_trans(grecs_json__state_type grecs_json__current_state)1589     static grecs_json__state_type grecs_json__try_NUL_trans  (grecs_json__state_type grecs_json__current_state )
1590 /* %endif */
1591 /* %if-c++-only */
1592 /* %endif */
1593 {
1594 	int grecs_json__is_jam;
1595     /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
1596 	char *grecs_json__cp = (grecs_json__c_buf_p);
1597 
1598 	YY_CHAR grecs_json__c = 1;
1599 	if ( grecs_json__accept[grecs_json__current_state] )
1600 		{
1601 		(grecs_json__last_accepting_state) = grecs_json__current_state;
1602 		(grecs_json__last_accepting_cpos) = grecs_json__cp;
1603 		}
1604 	while ( grecs_json__chk[grecs_json__base[grecs_json__current_state] + grecs_json__c] != grecs_json__current_state )
1605 		{
1606 		grecs_json__current_state = (int) grecs_json__def[grecs_json__current_state];
1607 		if ( grecs_json__current_state >= 61 )
1608 			grecs_json__c = grecs_json__meta[(unsigned int) grecs_json__c];
1609 		}
1610 	grecs_json__current_state = grecs_json__nxt[grecs_json__base[grecs_json__current_state] + (unsigned int) grecs_json__c];
1611 	grecs_json__is_jam = (grecs_json__current_state == 60);
1612 
1613 		return grecs_json__is_jam ? 0 : grecs_json__current_state;
1614 }
1615 
1616 #ifndef YY_NO_UNPUT
1617 /* %if-c-only */
1618 
1619 /* %endif */
1620 #endif
1621 
1622 /* %if-c-only */
1623 #ifndef YY_NO_INPUT
1624 #ifdef __cplusplus
grecs_json_input(void)1625     static int grecs_json_input (void)
1626 #else
1627     static int input  (void)
1628 #endif
1629 
1630 /* %endif */
1631 /* %if-c++-only */
1632 /* %endif */
1633 {
1634 	int c;
1635 
1636 	*(grecs_json__c_buf_p) = (grecs_json__hold_char);
1637 
1638 	if ( *(grecs_json__c_buf_p) == YY_END_OF_BUFFER_CHAR )
1639 		{
1640 		/* grecs_json__c_buf_p now points to the character we want to return.
1641 		 * If this occurs *before* the EOB characters, then it's a
1642 		 * valid NUL; if not, then we've hit the end of the buffer.
1643 		 */
1644 		if ( (grecs_json__c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->grecs_json__ch_buf[(grecs_json__n_chars)] )
1645 			/* This was really a NUL. */
1646 			*(grecs_json__c_buf_p) = '\0';
1647 
1648 		else
1649 			{ /* need more input */
1650 			grecs_json__size_t offset = (grecs_json__c_buf_p) - (grecs_json_text_ptr);
1651 			++(grecs_json__c_buf_p);
1652 
1653 			switch ( grecs_json__get_next_buffer(  ) )
1654 				{
1655 				case EOB_ACT_LAST_MATCH:
1656 					/* This happens because grecs_json__g_n_b()
1657 					 * sees that we've accumulated a
1658 					 * token and flags that we need to
1659 					 * try matching the token before
1660 					 * proceeding.  But for input(),
1661 					 * there's no matching to consider.
1662 					 * So convert the EOB_ACT_LAST_MATCH
1663 					 * to EOB_ACT_END_OF_FILE.
1664 					 */
1665 
1666 					/* Reset buffer status. */
1667 					grecs_json_restart(grecs_json_in );
1668 
1669 					/*FALLTHROUGH*/
1670 
1671 				case EOB_ACT_END_OF_FILE:
1672 					{
1673 					if ( grecs_json_wrap( ) )
1674 						return EOF;
1675 
1676 					if ( ! (grecs_json__did_buffer_switch_on_eof) )
1677 						YY_NEW_FILE;
1678 #ifdef __cplusplus
1679 					return grecs_json_input();
1680 #else
1681 					return input();
1682 #endif
1683 					}
1684 
1685 				case EOB_ACT_CONTINUE_SCAN:
1686 					(grecs_json__c_buf_p) = (grecs_json_text_ptr) + offset;
1687 					break;
1688 				}
1689 			}
1690 		}
1691 
1692 	c = *(unsigned char *) (grecs_json__c_buf_p);	/* cast for 8-bit char's */
1693 	*(grecs_json__c_buf_p) = '\0';	/* preserve grecs_json_text */
1694 	(grecs_json__hold_char) = *++(grecs_json__c_buf_p);
1695 
1696 /* %% [19.0] update BOL and grecs_json_lineno */
1697 
1698 	return c;
1699 }
1700 /* %if-c-only */
1701 #endif	/* ifndef YY_NO_INPUT */
1702 /* %endif */
1703 
1704 /** Immediately switch to a different input stream.
1705  * @param input_file A readable stream.
1706  *
1707  * @note This function does not reset the start condition to @c INITIAL .
1708  */
1709 /* %if-c-only */
grecs_json_restart(FILE * input_file)1710     void grecs_json_restart  (FILE * input_file )
1711 /* %endif */
1712 /* %if-c++-only */
1713 /* %endif */
1714 {
1715 
1716 	if ( ! YY_CURRENT_BUFFER ){
1717         grecs_json_ensure_buffer_stack ();
1718 		YY_CURRENT_BUFFER_LVALUE =
1719             grecs_json__create_buffer(grecs_json_in,YY_BUF_SIZE );
1720 	}
1721 
1722 	grecs_json__init_buffer(YY_CURRENT_BUFFER,input_file );
1723 	grecs_json__load_buffer_state( );
1724 }
1725 
1726 /* %if-c++-only */
1727 /* %endif */
1728 
1729 /** Switch to a different input buffer.
1730  * @param new_buffer The new input buffer.
1731  *
1732  */
1733 /* %if-c-only */
grecs_json__switch_to_buffer(YY_BUFFER_STATE new_buffer)1734     void grecs_json__switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
1735 /* %endif */
1736 /* %if-c++-only */
1737 /* %endif */
1738 {
1739 
1740 	/* TODO. We should be able to replace this entire function body
1741 	 * with
1742 	 *		grecs_json_pop_buffer_state();
1743 	 *		grecs_json_push_buffer_state(new_buffer);
1744      */
1745 	grecs_json_ensure_buffer_stack ();
1746 	if ( YY_CURRENT_BUFFER == new_buffer )
1747 		return;
1748 
1749 	if ( YY_CURRENT_BUFFER )
1750 		{
1751 		/* Flush out information for old buffer. */
1752 		*(grecs_json__c_buf_p) = (grecs_json__hold_char);
1753 		YY_CURRENT_BUFFER_LVALUE->grecs_json__buf_pos = (grecs_json__c_buf_p);
1754 		YY_CURRENT_BUFFER_LVALUE->grecs_json__n_chars = (grecs_json__n_chars);
1755 		}
1756 
1757 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1758 	grecs_json__load_buffer_state( );
1759 
1760 	/* We don't actually know whether we did this switch during
1761 	 * EOF (grecs_json_wrap()) processing, but the only time this flag
1762 	 * is looked at is after grecs_json_wrap() is called, so it's safe
1763 	 * to go ahead and always set it.
1764 	 */
1765 	(grecs_json__did_buffer_switch_on_eof) = 1;
1766 }
1767 
1768 /* %if-c-only */
grecs_json__load_buffer_state(void)1769 static void grecs_json__load_buffer_state  (void)
1770 /* %endif */
1771 /* %if-c++-only */
1772 /* %endif */
1773 {
1774     	(grecs_json__n_chars) = YY_CURRENT_BUFFER_LVALUE->grecs_json__n_chars;
1775 	(grecs_json_text_ptr) = (grecs_json__c_buf_p) = YY_CURRENT_BUFFER_LVALUE->grecs_json__buf_pos;
1776 /* %if-c-only */
1777 	grecs_json_in = YY_CURRENT_BUFFER_LVALUE->grecs_json__input_file;
1778 /* %endif */
1779 /* %if-c++-only */
1780 /* %endif */
1781 	(grecs_json__hold_char) = *(grecs_json__c_buf_p);
1782 }
1783 
1784 /** Allocate and initialize an input buffer state.
1785  * @param file A readable stream.
1786  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1787  *
1788  * @return the allocated buffer state.
1789  */
1790 /* %if-c-only */
grecs_json__create_buffer(FILE * file,int size)1791     YY_BUFFER_STATE grecs_json__create_buffer  (FILE * file, int  size )
1792 /* %endif */
1793 /* %if-c++-only */
1794 /* %endif */
1795 {
1796 	YY_BUFFER_STATE b;
1797 
1798 	b = (YY_BUFFER_STATE) grecs_json_alloc(sizeof( struct grecs_json__buffer_state )  );
1799 	if ( ! b )
1800 		YY_FATAL_ERROR( "out of dynamic memory in grecs_json__create_buffer()" );
1801 
1802 	b->grecs_json__buf_size = (grecs_json__size_t)size;
1803 
1804 	/* grecs_json__ch_buf has to be 2 characters longer than the size given because
1805 	 * we need to put in 2 end-of-buffer characters.
1806 	 */
1807 	b->grecs_json__ch_buf = (char *) grecs_json_alloc(b->grecs_json__buf_size + 2  );
1808 	if ( ! b->grecs_json__ch_buf )
1809 		YY_FATAL_ERROR( "out of dynamic memory in grecs_json__create_buffer()" );
1810 
1811 	b->grecs_json__is_our_buffer = 1;
1812 
1813 	grecs_json__init_buffer(b,file );
1814 
1815 	return b;
1816 }
1817 
1818 /* %if-c++-only */
1819 /* %endif */
1820 
1821 /** Destroy the buffer.
1822  * @param b a buffer created with grecs_json__create_buffer()
1823  *
1824  */
1825 /* %if-c-only */
grecs_json__delete_buffer(YY_BUFFER_STATE b)1826     void grecs_json__delete_buffer (YY_BUFFER_STATE  b )
1827 /* %endif */
1828 /* %if-c++-only */
1829 /* %endif */
1830 {
1831 
1832 	if ( ! b )
1833 		return;
1834 
1835 	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1836 		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1837 
1838 	if ( b->grecs_json__is_our_buffer )
1839 		grecs_json_free((void *) b->grecs_json__ch_buf  );
1840 
1841 	grecs_json_free((void *) b  );
1842 }
1843 
1844 /* Initializes or reinitializes a buffer.
1845  * This function is sometimes called more than once on the same buffer,
1846  * such as during a grecs_json_restart() or at EOF.
1847  */
1848 /* %if-c-only */
grecs_json__init_buffer(YY_BUFFER_STATE b,FILE * file)1849     static void grecs_json__init_buffer  (YY_BUFFER_STATE  b, FILE * file )
1850 /* %endif */
1851 /* %if-c++-only */
1852 /* %endif */
1853 
1854 {
1855 	int oerrno = errno;
1856 
1857 	grecs_json__flush_buffer(b );
1858 
1859 /* %if-c-only */
1860 	b->grecs_json__input_file = file;
1861 /* %endif */
1862 /* %if-c++-only */
1863 /* %endif */
1864 	b->grecs_json__fill_buffer = 1;
1865 
1866     /* If b is the current buffer, then grecs_json__init_buffer was _probably_
1867      * called from grecs_json_restart() or through grecs_json__get_next_buffer.
1868      * In that case, we don't want to reset the lineno or column.
1869      */
1870     if (b != YY_CURRENT_BUFFER){
1871         b->grecs_json__bs_lineno = 1;
1872         b->grecs_json__bs_column = 0;
1873     }
1874 
1875 /* %if-c-only */
1876 
1877         b->grecs_json__is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1878 
1879 /* %endif */
1880 /* %if-c++-only */
1881 /* %endif */
1882 	errno = oerrno;
1883 }
1884 
1885 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1886  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1887  *
1888  */
1889 /* %if-c-only */
grecs_json__flush_buffer(YY_BUFFER_STATE b)1890     void grecs_json__flush_buffer (YY_BUFFER_STATE  b )
1891 /* %endif */
1892 /* %if-c++-only */
1893 /* %endif */
1894 {
1895     	if ( ! b )
1896 		return;
1897 
1898 	b->grecs_json__n_chars = 0;
1899 
1900 	/* We always need two end-of-buffer characters.  The first causes
1901 	 * a transition to the end-of-buffer state.  The second causes
1902 	 * a jam in that state.
1903 	 */
1904 	b->grecs_json__ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1905 	b->grecs_json__ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1906 
1907 	b->grecs_json__buf_pos = &b->grecs_json__ch_buf[0];
1908 
1909 	b->grecs_json__at_bol = 1;
1910 	b->grecs_json__buffer_status = YY_BUFFER_NEW;
1911 
1912 	if ( b == YY_CURRENT_BUFFER )
1913 		grecs_json__load_buffer_state( );
1914 }
1915 
1916 /* %if-c-or-c++ */
1917 /** Pushes the new state onto the stack. The new state becomes
1918  *  the current state. This function will allocate the stack
1919  *  if necessary.
1920  *  @param new_buffer The new state.
1921  *
1922  */
1923 /* %if-c-only */
grecs_json_push_buffer_state(YY_BUFFER_STATE new_buffer)1924 void grecs_json_push_buffer_state (YY_BUFFER_STATE new_buffer )
1925 /* %endif */
1926 /* %if-c++-only */
1927 /* %endif */
1928 {
1929     	if (new_buffer == NULL)
1930 		return;
1931 
1932 	grecs_json_ensure_buffer_stack();
1933 
1934 	/* This block is copied from grecs_json__switch_to_buffer. */
1935 	if ( YY_CURRENT_BUFFER )
1936 		{
1937 		/* Flush out information for old buffer. */
1938 		*(grecs_json__c_buf_p) = (grecs_json__hold_char);
1939 		YY_CURRENT_BUFFER_LVALUE->grecs_json__buf_pos = (grecs_json__c_buf_p);
1940 		YY_CURRENT_BUFFER_LVALUE->grecs_json__n_chars = (grecs_json__n_chars);
1941 		}
1942 
1943 	/* Only push if top exists. Otherwise, replace top. */
1944 	if (YY_CURRENT_BUFFER)
1945 		(grecs_json__buffer_stack_top)++;
1946 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1947 
1948 	/* copied from grecs_json__switch_to_buffer. */
1949 	grecs_json__load_buffer_state( );
1950 	(grecs_json__did_buffer_switch_on_eof) = 1;
1951 }
1952 /* %endif */
1953 
1954 /* %if-c-or-c++ */
1955 /** Removes and deletes the top of the stack, if present.
1956  *  The next element becomes the new top.
1957  *
1958  */
1959 /* %if-c-only */
grecs_json_pop_buffer_state(void)1960 void grecs_json_pop_buffer_state (void)
1961 /* %endif */
1962 /* %if-c++-only */
1963 /* %endif */
1964 {
1965     	if (!YY_CURRENT_BUFFER)
1966 		return;
1967 
1968 	grecs_json__delete_buffer(YY_CURRENT_BUFFER );
1969 	YY_CURRENT_BUFFER_LVALUE = NULL;
1970 	if ((grecs_json__buffer_stack_top) > 0)
1971 		--(grecs_json__buffer_stack_top);
1972 
1973 	if (YY_CURRENT_BUFFER) {
1974 		grecs_json__load_buffer_state( );
1975 		(grecs_json__did_buffer_switch_on_eof) = 1;
1976 	}
1977 }
1978 /* %endif */
1979 
1980 /* %if-c-or-c++ */
1981 /* Allocates the stack if it does not exist.
1982  *  Guarantees space for at least one push.
1983  */
1984 /* %if-c-only */
grecs_json_ensure_buffer_stack(void)1985 static void grecs_json_ensure_buffer_stack (void)
1986 /* %endif */
1987 /* %if-c++-only */
1988 /* %endif */
1989 {
1990 	grecs_json__size_t num_to_alloc;
1991 
1992 	if (!(grecs_json__buffer_stack)) {
1993 
1994 		/* First allocation is just for 2 elements, since we don't know if this
1995 		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1996 		 * immediate realloc on the next call.
1997          */
1998 		num_to_alloc = 1; // After all that talk, this was set to 1 anyways...
1999 		(grecs_json__buffer_stack) = (struct grecs_json__buffer_state**)grecs_json_alloc
2000 								(num_to_alloc * sizeof(struct grecs_json__buffer_state*)
2001 								);
2002 		if ( ! (grecs_json__buffer_stack) )
2003 			YY_FATAL_ERROR( "out of dynamic memory in grecs_json_ensure_buffer_stack()" );
2004 
2005 		memset((grecs_json__buffer_stack), 0, num_to_alloc * sizeof(struct grecs_json__buffer_state*));
2006 
2007 		(grecs_json__buffer_stack_max) = num_to_alloc;
2008 		(grecs_json__buffer_stack_top) = 0;
2009 		return;
2010 	}
2011 
2012 	if ((grecs_json__buffer_stack_top) >= ((grecs_json__buffer_stack_max)) - 1){
2013 
2014 		/* Increase the buffer to prepare for a possible push. */
2015 		grecs_json__size_t grow_size = 8 /* arbitrary grow size */;
2016 
2017 		num_to_alloc = (grecs_json__buffer_stack_max) + grow_size;
2018 		(grecs_json__buffer_stack) = (struct grecs_json__buffer_state**)grecs_json_realloc
2019 								((grecs_json__buffer_stack),
2020 								num_to_alloc * sizeof(struct grecs_json__buffer_state*)
2021 								);
2022 		if ( ! (grecs_json__buffer_stack) )
2023 			YY_FATAL_ERROR( "out of dynamic memory in grecs_json_ensure_buffer_stack()" );
2024 
2025 		/* zero only the new slots.*/
2026 		memset((grecs_json__buffer_stack) + (grecs_json__buffer_stack_max), 0, grow_size * sizeof(struct grecs_json__buffer_state*));
2027 		(grecs_json__buffer_stack_max) = num_to_alloc;
2028 	}
2029 }
2030 /* %endif */
2031 
2032 /* %if-c-only */
2033 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2034  * @param base the character buffer
2035  * @param size the size in bytes of the character buffer
2036  *
2037  * @return the newly allocated buffer state object.
2038  */
grecs_json__scan_buffer(char * base,grecs_json__size_t size)2039 YY_BUFFER_STATE grecs_json__scan_buffer  (char * base, grecs_json__size_t  size )
2040 {
2041 	YY_BUFFER_STATE b;
2042 
2043 	if ( size < 2 ||
2044 	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
2045 	     base[size-1] != YY_END_OF_BUFFER_CHAR )
2046 		/* They forgot to leave room for the EOB's. */
2047 		return 0;
2048 
2049 	b = (YY_BUFFER_STATE) grecs_json_alloc(sizeof( struct grecs_json__buffer_state )  );
2050 	if ( ! b )
2051 		YY_FATAL_ERROR( "out of dynamic memory in grecs_json__scan_buffer()" );
2052 
2053 	b->grecs_json__buf_size = size - 2;	/* "- 2" to take care of EOB's */
2054 	b->grecs_json__buf_pos = b->grecs_json__ch_buf = base;
2055 	b->grecs_json__is_our_buffer = 0;
2056 	b->grecs_json__input_file = 0;
2057 	b->grecs_json__n_chars = b->grecs_json__buf_size;
2058 	b->grecs_json__is_interactive = 0;
2059 	b->grecs_json__at_bol = 1;
2060 	b->grecs_json__fill_buffer = 0;
2061 	b->grecs_json__buffer_status = YY_BUFFER_NEW;
2062 
2063 	grecs_json__switch_to_buffer(b  );
2064 
2065 	return b;
2066 }
2067 /* %endif */
2068 
2069 /* %if-c-only */
2070 /** Setup the input buffer state to scan a string. The next call to grecs_json_lex() will
2071  * scan from a @e copy of @a str.
2072  * @param grecs_json_str a NUL-terminated string to scan
2073  *
2074  * @return the newly allocated buffer state object.
2075  * @note If you want to scan bytes that may contain NUL values, then use
2076  *       grecs_json__scan_bytes() instead.
2077  */
grecs_json__scan_string(grecs_json_const char * grecs_json_str)2078 YY_BUFFER_STATE grecs_json__scan_string (grecs_json_const char * grecs_json_str )
2079 {
2080 
2081 	return grecs_json__scan_bytes(grecs_json_str,strlen(grecs_json_str) );
2082 }
2083 /* %endif */
2084 
2085 /* %if-c-only */
2086 /** Setup the input buffer state to scan the given bytes. The next call to grecs_json_lex() will
2087  * scan from a @e copy of @a bytes.
2088  * @param grecs_json_bytes the byte buffer to scan
2089  * @param _grecs_json_bytes_len the number of bytes in the buffer pointed to by @a bytes.
2090  *
2091  * @return the newly allocated buffer state object.
2092  */
grecs_json__scan_bytes(grecs_json_const char * grecs_json_bytes,grecs_json__size_t _grecs_json_bytes_len)2093 YY_BUFFER_STATE grecs_json__scan_bytes  (grecs_json_const char * grecs_json_bytes, grecs_json__size_t  _grecs_json_bytes_len )
2094 {
2095 	YY_BUFFER_STATE b;
2096 	char *buf;
2097 	grecs_json__size_t n;
2098 	grecs_json__size_t i;
2099 
2100 	/* Get memory for full buffer, including space for trailing EOB's. */
2101 	n = _grecs_json_bytes_len + 2;
2102 	buf = (char *) grecs_json_alloc(n  );
2103 	if ( ! buf )
2104 		YY_FATAL_ERROR( "out of dynamic memory in grecs_json__scan_bytes()" );
2105 
2106 	for ( i = 0; i < _grecs_json_bytes_len; ++i )
2107 		buf[i] = grecs_json_bytes[i];
2108 
2109 	buf[_grecs_json_bytes_len] = buf[_grecs_json_bytes_len+1] = YY_END_OF_BUFFER_CHAR;
2110 
2111 	b = grecs_json__scan_buffer(buf,n );
2112 	if ( ! b )
2113 		YY_FATAL_ERROR( "bad buffer in grecs_json__scan_bytes()" );
2114 
2115 	/* It's okay to grow etc. this buffer, and we should throw it
2116 	 * away when we're done.
2117 	 */
2118 	b->grecs_json__is_our_buffer = 1;
2119 
2120 	return b;
2121 }
2122 /* %endif */
2123 
2124 #ifndef YY_EXIT_FAILURE
2125 #define YY_EXIT_FAILURE 2
2126 #endif
2127 
2128 /* %if-c-only */
grecs_json__fatal_error(grecs_json_const char * msg)2129 static void grecs_json__fatal_error (grecs_json_const char* msg )
2130 {
2131 			(void) fprintf( stderr, "%s\n", msg );
2132 	exit( YY_EXIT_FAILURE );
2133 }
2134 /* %endif */
2135 /* %if-c++-only */
2136 /* %endif */
2137 
2138 /* Redefine grecs_json_less() so it works in section 3 code. */
2139 
2140 #undef grecs_json_less
2141 #define grecs_json_less(n) \
2142 	do \
2143 		{ \
2144 		/* Undo effects of setting up grecs_json_text. */ \
2145         int grecs_json_less_macro_arg = (n); \
2146         YY_LESS_LINENO(grecs_json_less_macro_arg);\
2147 		grecs_json_text[grecs_json_leng] = (grecs_json__hold_char); \
2148 		(grecs_json__c_buf_p) = grecs_json_text + grecs_json_less_macro_arg; \
2149 		(grecs_json__hold_char) = *(grecs_json__c_buf_p); \
2150 		*(grecs_json__c_buf_p) = '\0'; \
2151 		grecs_json_leng = grecs_json_less_macro_arg; \
2152 		} \
2153 	while ( 0 )
2154 
2155 /* Accessor  methods (get/set functions) to struct members. */
2156 
2157 /* %if-c-only */
2158 /* %if-reentrant */
2159 /* %endif */
2160 
2161 /** Get the current line number.
2162  *
2163  */
grecs_json_get_lineno(void)2164 int grecs_json_get_lineno  (void)
2165 {
2166 
2167     return grecs_json_lineno;
2168 }
2169 
2170 /** Get the input stream.
2171  *
2172  */
grecs_json_get_in(void)2173 FILE *grecs_json_get_in  (void)
2174 {
2175         return grecs_json_in;
2176 }
2177 
2178 /** Get the output stream.
2179  *
2180  */
grecs_json_get_out(void)2181 FILE *grecs_json_get_out  (void)
2182 {
2183         return grecs_json_out;
2184 }
2185 
2186 /** Get the length of the current token.
2187  *
2188  */
grecs_json_get_leng(void)2189 grecs_json__size_t grecs_json_get_leng  (void)
2190 {
2191         return grecs_json_leng;
2192 }
2193 
2194 /** Get the current token.
2195  *
2196  */
2197 
grecs_json_get_text(void)2198 char *grecs_json_get_text  (void)
2199 {
2200         return grecs_json_text;
2201 }
2202 
2203 /* %if-reentrant */
2204 /* %endif */
2205 
2206 /** Set the current line number.
2207  * @param _line_number line number
2208  *
2209  */
grecs_json_set_lineno(int _line_number)2210 void grecs_json_set_lineno (int  _line_number )
2211 {
2212 
2213     grecs_json_lineno = _line_number;
2214 }
2215 
2216 /** Set the input stream. This does not discard the current
2217  * input buffer.
2218  * @param _in_str A readable stream.
2219  *
2220  * @see grecs_json__switch_to_buffer
2221  */
grecs_json_set_in(FILE * _in_str)2222 void grecs_json_set_in (FILE *  _in_str )
2223 {
2224         grecs_json_in = _in_str ;
2225 }
2226 
grecs_json_set_out(FILE * _out_str)2227 void grecs_json_set_out (FILE *  _out_str )
2228 {
2229         grecs_json_out = _out_str ;
2230 }
2231 
grecs_json_get_debug(void)2232 int grecs_json_get_debug  (void)
2233 {
2234         return grecs_json__flex_debug;
2235 }
2236 
grecs_json_set_debug(int _bdebug)2237 void grecs_json_set_debug (int  _bdebug )
2238 {
2239         grecs_json__flex_debug = _bdebug ;
2240 }
2241 
2242 /* %endif */
2243 
2244 /* %if-reentrant */
2245 /* %if-bison-bridge */
2246 /* %endif */
2247 /* %endif if-c-only */
2248 
2249 /* %if-c-only */
grecs_json__init_globals(void)2250 static int grecs_json__init_globals (void)
2251 {
2252         /* Initialization is the same as for the non-reentrant scanner.
2253      * This function is called from grecs_json_lex_destroy(), so don't allocate here.
2254      */
2255 
2256     (grecs_json__buffer_stack) = 0;
2257     (grecs_json__buffer_stack_top) = 0;
2258     (grecs_json__buffer_stack_max) = 0;
2259     (grecs_json__c_buf_p) = (char *) 0;
2260     (grecs_json__init) = 0;
2261     (grecs_json__start) = 0;
2262 
2263 /* Defined in main.c */
2264 #ifdef YY_STDINIT
2265     grecs_json_in = stdin;
2266     grecs_json_out = stdout;
2267 #else
2268     grecs_json_in = (FILE *) 0;
2269     grecs_json_out = (FILE *) 0;
2270 #endif
2271 
2272     /* For future reference: Set errno on error, since we are called by
2273      * grecs_json_lex_init()
2274      */
2275     return 0;
2276 }
2277 /* %endif */
2278 
2279 /* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
2280 /* grecs_json_lex_destroy is for both reentrant and non-reentrant scanners. */
grecs_json_lex_destroy(void)2281 int grecs_json_lex_destroy  (void)
2282 {
2283 
2284     /* Pop the buffer stack, destroying each element. */
2285 	while(YY_CURRENT_BUFFER){
2286 		grecs_json__delete_buffer(YY_CURRENT_BUFFER  );
2287 		YY_CURRENT_BUFFER_LVALUE = NULL;
2288 		grecs_json_pop_buffer_state();
2289 	}
2290 
2291 	/* Destroy the stack itself. */
2292 	grecs_json_free((grecs_json__buffer_stack) );
2293 	(grecs_json__buffer_stack) = NULL;
2294 
2295     /* Reset the globals. This is important in a non-reentrant scanner so the next time
2296      * grecs_json_lex() is called, initialization will occur. */
2297     grecs_json__init_globals( );
2298 
2299 /* %if-reentrant */
2300 /* %endif */
2301     return 0;
2302 }
2303 /* %endif */
2304 
2305 /*
2306  * Internal utility routines.
2307  */
2308 
2309 #ifndef grecs_json_text_ptr
grecs_json__flex_strncpy(char * s1,grecs_json_const char * s2,int n)2310 static void grecs_json__flex_strncpy (char* s1, grecs_json_const char * s2, int n )
2311 {
2312 
2313 	int i;
2314 	for ( i = 0; i < n; ++i )
2315 		s1[i] = s2[i];
2316 }
2317 #endif
2318 
2319 #ifdef YY_NEED_STRLEN
grecs_json__flex_strlen(grecs_json_const char * s)2320 static int grecs_json__flex_strlen (grecs_json_const char * s )
2321 {
2322 	int n;
2323 	for ( n = 0; s[n]; ++n )
2324 		;
2325 
2326 	return n;
2327 }
2328 #endif
2329 
grecs_json_alloc(grecs_json__size_t size)2330 void *grecs_json_alloc (grecs_json__size_t  size )
2331 {
2332 			return (void *) malloc( size );
2333 }
2334 
grecs_json_realloc(void * ptr,grecs_json__size_t size)2335 void *grecs_json_realloc  (void * ptr, grecs_json__size_t  size )
2336 {
2337 
2338 	/* The cast to (char *) in the following accommodates both
2339 	 * implementations that use char* generic pointers, and those
2340 	 * that use void* generic pointers.  It works with the latter
2341 	 * because both ANSI C and C++ allow castless assignment from
2342 	 * any pointer type to void*, and deal with argument conversions
2343 	 * as though doing an assignment.
2344 	 */
2345 	return (void *) realloc( (char *) ptr, size );
2346 }
2347 
grecs_json_free(void * ptr)2348 void grecs_json_free (void * ptr )
2349 {
2350 			free( (char *) ptr );	/* see grecs_json_realloc() for (char *) cast */
2351 }
2352 
2353 /* %if-tables-serialization definitions */
2354 /* %define-grecs_json_tables   The name for this specific scanner's tables. */
2355 #define YYTABLES_NAME "grecs_json_tables"
2356 /* %endif */
2357 
2358 /* %ok-for-header */
2359 
2360 #line 218 "json-lex.l"
2361 
2362 
2363 void
jsonlex_setup(char const * s,size_t l)2364 jsonlex_setup(char const *s, size_t l)
2365 {
2366 	input_ptr = s;
2367 	input_size = l;
2368 	json_current_locus_point.file = "input";
2369 	json_current_locus_point.line = 1;
2370 	json_current_locus_point.col = 0;
2371 	json_err_diag = NULL;
2372         grecs_json__flex_debug = 0;
2373         BEGIN(INITIAL);
2374         grecs_json_restart(NULL);
2375 }
2376 
2377 void
jsonlex_cleanup(void)2378 jsonlex_cleanup(void)
2379 {
2380         if (json_line_acc) {
2381 	        grecs_txtacc_free(json_line_acc);
2382                 json_line_acc = NULL;
2383 	}
2384 }
2385 
2386