1 #include <IceUtil/ScannerConfig.h>
2 #line 2 "src/Slice/Scanner.cpp"
3 
4 #line 4 "src/Slice/Scanner.cpp"
5 
6 #define  YY_INT_ALIGNED short int
7 
8 /* A lexical scanner generated by flex */
9 
10 #define yy_create_buffer slice__create_buffer
11 #define yy_delete_buffer slice__delete_buffer
12 #define yy_flex_debug slice__flex_debug
13 #define yy_init_buffer slice__init_buffer
14 #define yy_flush_buffer slice__flush_buffer
15 #define yy_load_buffer_state slice__load_buffer_state
16 #define yy_switch_to_buffer slice__switch_to_buffer
17 #define yyin slice_in
18 #define yyleng slice_leng
19 #define yylex slice_lex
20 #define yylineno slice_lineno
21 #define yyout slice_out
22 #define yyrestart slice_restart
23 #define yytext slice_text
24 #define yywrap slice_wrap
25 #define yyalloc slice_alloc
26 #define yyrealloc slice_realloc
27 #define yyfree slice_free
28 
29 #define FLEX_SCANNER
30 #define YY_FLEX_MAJOR_VERSION 2
31 #define YY_FLEX_MINOR_VERSION 5
32 #define YY_FLEX_SUBMINOR_VERSION 37
33 #if YY_FLEX_SUBMINOR_VERSION > 0
34 #define FLEX_BETA
35 #endif
36 
37 /* First, we deal with  platform-specific or compiler-specific issues. */
38 
39 /* begin standard C headers. */
40 #include <stdio.h>
41 #include <string.h>
42 #include <errno.h>
43 #include <stdlib.h>
44 
45 /* end standard C headers. */
46 
47 /* flex integer type definitions */
48 
49 #ifndef FLEXINT_H
50 #define FLEXINT_H
51 
52 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
53 
54 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
55 
56 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
57  * if you want the limit (max/min) macros for int types.
58  */
59 #ifndef __STDC_LIMIT_MACROS
60 #define __STDC_LIMIT_MACROS 1
61 #endif
62 
63 #include <inttypes.h>
64 typedef int8_t flex_int8_t;
65 typedef uint8_t flex_uint8_t;
66 typedef int16_t flex_int16_t;
67 typedef uint16_t flex_uint16_t;
68 typedef int32_t flex_int32_t;
69 typedef uint32_t flex_uint32_t;
70 #else
71 typedef signed char flex_int8_t;
72 typedef short int flex_int16_t;
73 typedef int flex_int32_t;
74 typedef unsigned char flex_uint8_t;
75 typedef unsigned short int flex_uint16_t;
76 typedef unsigned int flex_uint32_t;
77 
78 /* Limits of integral types. */
79 #ifndef INT8_MIN
80 #define INT8_MIN               (-128)
81 #endif
82 #ifndef INT16_MIN
83 #define INT16_MIN              (-32767-1)
84 #endif
85 #ifndef INT32_MIN
86 #define INT32_MIN              (-2147483647-1)
87 #endif
88 #ifndef INT8_MAX
89 #define INT8_MAX               (127)
90 #endif
91 #ifndef INT16_MAX
92 #define INT16_MAX              (32767)
93 #endif
94 #ifndef INT32_MAX
95 #define INT32_MAX              (2147483647)
96 #endif
97 #ifndef UINT8_MAX
98 #define UINT8_MAX              (255U)
99 #endif
100 #ifndef UINT16_MAX
101 #define UINT16_MAX             (65535U)
102 #endif
103 #ifndef UINT32_MAX
104 #define UINT32_MAX             (4294967295U)
105 #endif
106 
107 #endif /* ! C99 */
108 
109 #endif /* ! FLEXINT_H */
110 
111 #ifdef __cplusplus
112 
113 /* The "const" storage-class-modifier is valid. */
114 #define YY_USE_CONST
115 
116 #else	/* ! __cplusplus */
117 
118 /* C99 requires __STDC__ to be defined as 1. */
119 #if defined (__STDC__)
120 
121 #define YY_USE_CONST
122 
123 #endif	/* defined (__STDC__) */
124 #endif	/* ! __cplusplus */
125 
126 #ifdef YY_USE_CONST
127 #define yyconst const
128 #else
129 #define yyconst
130 #endif
131 
132 /* Returned upon end-of-file. */
133 #define YY_NULL 0
134 
135 /* Promotes a possibly negative, possibly signed char to an unsigned
136  * integer for use as an array index.  If the signed char is negative,
137  * we want to instead treat it as an 8-bit unsigned char, hence the
138  * double cast.
139  */
140 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
141 
142 /* Enter a start condition.  This macro really ought to take a parameter,
143  * but we do it the disgusting crufty way forced on us by the ()-less
144  * definition of BEGIN.
145  */
146 #define BEGIN (yy_start) = 1 + 2 *
147 
148 /* Translate the current start state into a value that can be later handed
149  * to BEGIN to return to the state.  The YYSTATE alias is for lex
150  * compatibility.
151  */
152 #define YY_START (((yy_start) - 1) / 2)
153 #define YYSTATE YY_START
154 
155 /* Action number for EOF rule of a given start state. */
156 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
157 
158 /* Special action meaning "start processing a new file". */
159 #define YY_NEW_FILE slice_restart(slice_in  )
160 
161 #define YY_END_OF_BUFFER_CHAR 0
162 
163 /* Size of default input buffer. */
164 #ifndef YY_BUF_SIZE
165 #define YY_BUF_SIZE 16384
166 #endif
167 
168 /* The state buf must be large enough to hold one state per character in the main buffer.
169  */
170 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
171 
172 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
173 #define YY_TYPEDEF_YY_BUFFER_STATE
174 typedef struct yy_buffer_state *YY_BUFFER_STATE;
175 #endif
176 
177 #ifndef YY_TYPEDEF_YY_SIZE_T
178 #define YY_TYPEDEF_YY_SIZE_T
179 typedef size_t yy_size_t;
180 #endif
181 
182 extern yy_size_t slice_leng;
183 
184 extern FILE *slice_in, *slice_out;
185 
186 #define EOB_ACT_CONTINUE_SCAN 0
187 #define EOB_ACT_END_OF_FILE 1
188 #define EOB_ACT_LAST_MATCH 2
189 
190     #define YY_LESS_LINENO(n)
191 
192 /* Return all but the first "n" matched characters back to the input stream. */
193 #define yyless(n) \
194 	do \
195 		{ \
196 		/* Undo effects of setting up slice_text. */ \
197         int yyless_macro_arg = (n); \
198         YY_LESS_LINENO(yyless_macro_arg);\
199 		*yy_cp = (yy_hold_char); \
200 		YY_RESTORE_YY_MORE_OFFSET \
201 		(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
202 		YY_DO_BEFORE_ACTION; /* set up slice_text again */ \
203 		} \
204 	while ( 0 )
205 
206 #define unput(c) yyunput( c, (yytext_ptr)  )
207 
208 #ifndef YY_STRUCT_YY_BUFFER_STATE
209 #define YY_STRUCT_YY_BUFFER_STATE
210 struct yy_buffer_state
211 	{
212 	FILE *yy_input_file;
213 
214 	char *yy_ch_buf;		/* input buffer */
215 	char *yy_buf_pos;		/* current position in input buffer */
216 
217 	/* Size of input buffer in bytes, not including room for EOB
218 	 * characters.
219 	 */
220 	yy_size_t yy_buf_size;
221 
222 	/* Number of characters read into yy_ch_buf, not including EOB
223 	 * characters.
224 	 */
225 	yy_size_t yy_n_chars;
226 
227 	/* Whether we "own" the buffer - i.e., we know we created it,
228 	 * and can realloc() it to grow it, and should free() it to
229 	 * delete it.
230 	 */
231 	int yy_is_our_buffer;
232 
233 	/* Whether this is an "interactive" input source; if so, and
234 	 * if we're using stdio for input, then we want to use getc()
235 	 * instead of fread(), to make sure we stop fetching input after
236 	 * each newline.
237 	 */
238 	int yy_is_interactive;
239 
240 	/* Whether we're considered to be at the beginning of a line.
241 	 * If so, '^' rules will be active on the next match, otherwise
242 	 * not.
243 	 */
244 	int yy_at_bol;
245 
246     int yy_bs_lineno; /**< The line count. */
247     int yy_bs_column; /**< The column count. */
248 
249 	/* Whether to try to fill the input buffer when we reach the
250 	 * end of it.
251 	 */
252 	int yy_fill_buffer;
253 
254 	int yy_buffer_status;
255 
256 #define YY_BUFFER_NEW 0
257 #define YY_BUFFER_NORMAL 1
258 	/* When an EOF's been seen but there's still some text to process
259 	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
260 	 * shouldn't try reading from the input source any more.  We might
261 	 * still have a bunch of tokens to match, though, because of
262 	 * possible backing-up.
263 	 *
264 	 * When we actually see the EOF, we change the status to "new"
265 	 * (via slice_restart()), so that the user can continue scanning by
266 	 * just pointing slice_in at a new input file.
267 	 */
268 #define YY_BUFFER_EOF_PENDING 2
269 
270 	};
271 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
272 
273 /* Stack of input buffers. */
274 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
275 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
276 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
277 
278 /* We provide macros for accessing buffer states in case in the
279  * future we want to put the buffer states in a more general
280  * "scanner state".
281  *
282  * Returns the top of the stack, or NULL.
283  */
284 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
285                           ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
286                           : NULL)
287 
288 /* Same as previous macro, but useful when we know that the buffer stack is not
289  * NULL or when we need an lvalue. For internal use only.
290  */
291 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
292 
293 /* yy_hold_char holds the character lost when slice_text is formed. */
294 static char yy_hold_char;
295 static yy_size_t yy_n_chars;		/* number of characters read into yy_ch_buf */
296 yy_size_t slice_leng;
297 
298 /* Points to current character in buffer. */
299 static char *yy_c_buf_p = (char *) 0;
300 static int yy_init = 0;		/* whether we need to initialize */
301 static int yy_start = 0;	/* start state number */
302 
303 /* Flag which is used to allow slice_wrap()'s to do buffer switches
304  * instead of setting up a fresh slice_in.  A bit of a hack ...
305  */
306 static int yy_did_buffer_switch_on_eof;
307 
308 void slice_restart (FILE *input_file  );
309 void slice__switch_to_buffer (YY_BUFFER_STATE new_buffer  );
310 YY_BUFFER_STATE slice__create_buffer (FILE *file,int size  );
311 void slice__delete_buffer (YY_BUFFER_STATE b  );
312 void slice__flush_buffer (YY_BUFFER_STATE b  );
313 void slice_push_buffer_state (YY_BUFFER_STATE new_buffer  );
314 void slice_pop_buffer_state (void );
315 
316 static void slice_ensure_buffer_stack (void );
317 static void slice__load_buffer_state (void );
318 static void slice__init_buffer (YY_BUFFER_STATE b,FILE *file  );
319 
320 #define YY_FLUSH_BUFFER slice__flush_buffer(YY_CURRENT_BUFFER )
321 
322 YY_BUFFER_STATE slice__scan_buffer (char *base,yy_size_t size  );
323 YY_BUFFER_STATE slice__scan_string (yyconst char *yy_str  );
324 YY_BUFFER_STATE slice__scan_bytes (yyconst char *bytes,yy_size_t len  );
325 
326 void *slice_alloc (yy_size_t  );
327 void *slice_realloc (void *,yy_size_t  );
328 void slice_free (void *  );
329 
330 #define yy_new_buffer slice__create_buffer
331 
332 #define yy_set_interactive(is_interactive) \
333 	{ \
334 	if ( ! YY_CURRENT_BUFFER ){ \
335         slice_ensure_buffer_stack (); \
336 		YY_CURRENT_BUFFER_LVALUE =    \
337             slice__create_buffer(slice_in,YY_BUF_SIZE ); \
338 	} \
339 	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
340 	}
341 
342 #define yy_set_bol(at_bol) \
343 	{ \
344 	if ( ! YY_CURRENT_BUFFER ){\
345         slice_ensure_buffer_stack (); \
346 		YY_CURRENT_BUFFER_LVALUE =    \
347             slice__create_buffer(slice_in,YY_BUF_SIZE ); \
348 	} \
349 	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
350 	}
351 
352 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
353 
354 /* Begin user sect3 */
355 
356 #define slice_wrap() 1
357 #define YY_SKIP_YYWRAP
358 
359 typedef unsigned char YY_CHAR;
360 
361 FILE *slice_in = (FILE *) 0, *slice_out = (FILE *) 0;
362 
363 typedef int yy_state_type;
364 
365 extern int slice_lineno;
366 
367 int slice_lineno = 1;
368 
369 extern char *slice_text;
370 #define yytext_ptr slice_text
371 
372 static yy_state_type yy_get_previous_state (void );
373 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
374 static int yy_get_next_buffer (void );
375 static void yy_fatal_error (yyconst char msg[]  );
376 
377 /* Done after the current pattern has been matched and before the
378  * corresponding action - sets up slice_text.
379  */
380 #define YY_DO_BEFORE_ACTION \
381 	(yytext_ptr) = yy_bp; \
382 	slice_leng = (size_t) (yy_cp - yy_bp); \
383 	(yy_hold_char) = *yy_cp; \
384 	*yy_cp = '\0'; \
385 	(yy_c_buf_p) = yy_cp;
386 
387 #define YY_NUM_RULES 19
388 #define YY_END_OF_BUFFER 20
389 /* This struct is not used in this scanner,
390    but its presence is necessary. */
391 struct yy_trans_info
392 	{
393 	flex_int32_t yy_verify;
394 	flex_int32_t yy_nxt;
395 	};
396 static yyconst flex_int16_t yy_accept[76] =
397     {   0,
398         0,    0,    0,    0,    0,    0,   20,   18,   16,   16,
399        13,   18,   18,   18,   14,   14,   18,   12,    7,   18,
400         8,   18,   18,    0,   14,   14,   15,    6,    5,   15,
401        14,    0,    0,    0,    0,   11,   12,    0,   12,    0,
402         9,   12,   10,    0,    0,    0,    0,    0,   15,    0,
403        15,   14,    0,    1,    0,   17,    0,   15,    0,    0,
404         0,    0,    0,    0,    2,    0,    0,    0,    3,    0,
405         0,    0,    0,    4,    0
406     } ;
407 
408 static yyconst flex_int32_t yy_ec[256] =
409     {   0,
410         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
411         4,    4,    4,    1,    1,    1,    1,    1,    1,    1,
412         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
413         1,    2,    1,    5,    6,    1,    1,    1,    1,    7,
414         1,    8,    9,    1,   10,   11,   12,   13,   14,   14,
415        14,   14,   14,   14,   14,   15,   15,   16,    1,    1,
416         1,    1,    1,    1,   17,   17,   17,   17,   18,   19,
417        20,   20,   20,   20,   20,   20,   20,   20,   20,   20,
418        20,   20,   20,   20,   20,   20,   20,   20,   20,   20,
419        21,   22,   23,    1,   20,    1,   17,   17,   17,   17,
420 
421        24,   19,   20,   20,   25,   20,   20,   26,   20,   27,
422        20,   20,   20,   20,   20,   20,   20,   20,   20,   28,
423        20,   20,    1,    1,    1,    1,    1,    1,    1,    1,
424         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
425         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
426         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
427         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
428         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
429         1,    1,    1,    1,    1,    1,   29,    1,    1,    1,
430        30,    1,    1,    1,    1,    1,    1,    1,    1,    1,
431 
432         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
433         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
434         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
435         1,    1,    1,    1,    1,    1,    1,    1,   31,    1,
436         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
437         1,    1,    1,    1,    1
438     } ;
439 
440 static yyconst flex_int32_t yy_meta[32] =
441     {   0,
442         1,    2,    3,    1,    1,    1,    1,    1,    4,    4,
443         1,    1,    5,    5,    5,    1,    6,    6,    6,    7,
444         1,    1,    1,    6,    7,    8,    7,    7,    1,    1,
445         1
446     } ;
447 
448 static yyconst flex_int16_t yy_base[87] =
449     {   0,
450         0,  140,    0,   26,    0,  139,  137,  197,  197,  197,
451       197,   22,   25,   33,   47,   35,  120,   74,  114,    0,
452       111,   40,  104,   37,    0,    0,   90,  197,  197,    0,
453       104,   34,    0,   97,   52,  197,    0,   99,    0,    0,
454       197,    0,  197,   44,   65,   88,   77,   63,  197,   69,
455        97,    0,  115,  197,   79,  197,  108,  111,   92,   71,
456        81,   82,   72,   66,  197,  125,   77,  126,  197,   59,
457        48,   44,   31,  197,  197,  135,  142,  147,  148,  153,
458       155,  160,  168,  175,  180,  188
459     } ;
460 
461 static yyconst flex_int16_t yy_def[87] =
462     {   0,
463        75,    1,    1,    1,    1,    1,   75,   75,   75,   75,
464        75,   75,   75,   75,   75,   15,   75,   75,   75,   76,
465        75,   77,   75,   75,   15,   16,   75,   75,   75,   27,
466        15,   78,   79,   76,   75,   75,   18,   75,   18,   76,
467        75,   18,   75,   77,   80,   75,   75,   81,   75,   75,
468        75,   79,   75,   75,   75,   75,   75,   75,   82,   75,
469        82,   83,   75,   83,   75,   75,   84,   75,   75,   85,
470        85,   86,   86,   75,    0,   75,   75,   75,   75,   75,
471        75,   75,   75,   75,   75,   75
472     } ;
473 
474 static yyconst flex_int16_t yy_nxt[229] =
475     {   0,
476         8,    9,   10,    9,   11,    8,    8,    8,   12,   12,
477        13,   14,   15,   16,   16,   17,   18,   18,   18,   18,
478        19,   20,   21,   18,   18,   18,   18,   18,    8,    8,
479         8,   22,   24,   74,   25,   26,   26,   27,   27,   27,
480        28,   44,   50,   50,   29,   44,   74,   26,   26,   27,
481        27,   27,   72,   35,   35,   35,   23,   30,   36,   31,
482        31,   26,   75,   72,   32,   46,   53,   54,   65,   46,
483        32,   57,   57,   66,   33,   35,   35,   35,   68,   69,
484        36,   51,   51,   51,   65,   62,   37,   37,   37,   38,
485        39,   39,   39,   39,   63,   40,   62,   39,   39,   39,
486 
487        39,   39,   27,   27,   27,   60,   56,   48,   49,   51,
488        51,   51,   55,   48,   34,   49,   53,   54,   40,   59,
489        58,   58,   58,   58,   58,   58,   66,   68,   69,   49,
490        70,   75,   47,   43,   41,   34,   75,   67,   67,   67,
491        42,   42,   42,   45,   22,   22,   45,   75,   75,   45,
492        51,   51,   52,   52,   45,   45,   75,   45,   58,   58,
493        61,   61,   61,   61,   61,   61,   61,   61,   64,   64,
494        64,   64,   64,   64,   64,   64,   67,   67,   75,   67,
495        71,   71,   71,   71,   71,   71,   71,   71,   73,   73,
496        73,   73,   73,   73,   73,   73,    7,   75,   75,   75,
497 
498        75,   75,   75,   75,   75,   75,   75,   75,   75,   75,
499        75,   75,   75,   75,   75,   75,   75,   75,   75,   75,
500        75,   75,   75,   75,   75,   75,   75,   75
501     } ;
502 
503 static yyconst flex_int16_t yy_chk[229] =
504     {   0,
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,    4,   12,   73,   12,   12,   12,   13,   13,   13,
509        14,   22,   32,   32,   14,   44,   72,   16,   16,   24,
510        24,   24,   71,   35,   35,   35,    4,   15,   35,   15,
511        15,   15,   16,   70,   15,   22,   45,   45,   64,   44,
512        15,   48,   48,   63,   15,   18,   18,   18,   67,   67,
513        18,   50,   50,   50,   62,   61,   18,   18,   18,   18,
514        18,   18,   18,   18,   60,   18,   59,   18,   18,   18,
515 
516        18,   18,   27,   27,   27,   55,   47,   27,   27,   51,
517        51,   51,   46,   27,   38,   51,   53,   53,   34,   53,
518        57,   57,   57,   58,   58,   58,   66,   68,   68,   58,
519        68,   31,   23,   21,   19,   17,    7,   66,   66,   66,
520        76,   76,   76,   77,    6,    2,   77,    0,    0,   77,
521        78,   78,   79,   79,   80,   80,    0,   80,   81,   81,
522        82,   82,   82,   82,   82,   82,   82,   82,   83,   83,
523        83,   83,   83,   83,   83,   83,   84,   84,    0,   84,
524        85,   85,   85,   85,   85,   85,   85,   85,   86,   86,
525        86,   86,   86,   86,   86,   86,   75,   75,   75,   75,
526 
527        75,   75,   75,   75,   75,   75,   75,   75,   75,   75,
528        75,   75,   75,   75,   75,   75,   75,   75,   75,   75,
529        75,   75,   75,   75,   75,   75,   75,   75
530     } ;
531 
532 static yy_state_type yy_last_accepting_state;
533 static char *yy_last_accepting_cpos;
534 
535 extern int slice__flex_debug;
536 int slice__flex_debug = 0;
537 
538 /* The intent behind this definition is that it'll catch
539  * any uses of REJECT which flex missed.
540  */
541 #define REJECT reject_used_but_not_detected
542 #define yymore() yymore_used_but_not_detected
543 #define YY_MORE_ADJ 0
544 #define YY_RESTORE_YY_MORE_OFFSET
545 char *slice_text;
546 #line 1 "src/Slice/Scanner.l"
547 #line 2 "src/Slice/Scanner.l"
548 
549 //
550 // Copyright (c) ZeroC, Inc. All rights reserved.
551 //
552 
553 #include <Slice/GrammarUtil.h>  // Before Grammer.h, so that YYSTYPE is defined
554 #include <Slice/Grammar.h>
555 #include <IceUtil/InputUtil.h>
556 
557 #include <iomanip>
558 
559 #include <stdlib.h>
560 #include <math.h>
561 
562 #if defined(_MSC_VER)
563 // '<' : signed/unsigned mismatch
564 #   pragma warning(disable:4018)
565 // 'initializing' : conversion from '__int64' to 'int', possible loss of data
566 #   pragma warning(disable:4244)
567 
568 #   if defined(ICE_64)
569 //
570 // '=' : conversion from 'size_t' to 'int', possible loss of data
571 // The result of fread() is a size_t and gets inserted into an int
572 //
573 #       pragma warning(disable:4267)
574 #   endif
575 #endif
576 
577 #if defined(__GNUC__)
578 #   pragma GCC diagnostic ignored "-Wsign-compare"
579 #endif
580 
581 #ifdef _MSC_VER
582 #   ifdef slice_wrap
583 #      undef slice_wrap
584 #      define slice_wrap() 1
585 #   endif
586 #   define YY_NO_UNISTD_H
587 #endif
588 
589 #ifdef __SUNPRO_CC
590 #   ifdef slice_wrap
591 #      undef slice_wrap
592 #      define slice_wrap() 1
593 #   endif
594 #   ifdef ICE_64
595 #       pragma error_messages(off,truncwarn)
596 #   endif
597 #endif
598 
599 using namespace std;
600 using namespace Slice;
601 
602 namespace Slice
603 {
604 
605 //
606 // Definitions for the case-insensitive keyword-token map.
607 //
608 typedef std::map<std::string, int> StringTokenMap;
609 static StringTokenMap keywordMap;
610 
611 void initScanner();
612 int checkKeyword(string&);
613 int checkIdentifier(string&);
614 
615 }
616 
617 #define YY_USER_INIT initScanner();
618 
619 
620 
621 #line 626 "src/Slice/Scanner.cpp"
622 
623 #define INITIAL 0
624 #define BOMSCAN 1
625 #define MAINSCAN 2
626 
627 #ifndef YY_NO_UNISTD_H
628 /* Special case for "unistd.h", since it is non-ANSI. We include it way
629  * down here because we want the user's section 1 to have been scanned first.
630  * The user has a chance to override it with an option.
631  */
632 #include <unistd.h>
633 #endif
634 
635 #ifndef YY_EXTRA_TYPE
636 #define YY_EXTRA_TYPE void *
637 #endif
638 
639 static int yy_init_globals (void );
640 
641 /* Accessor methods to globals.
642    These are made visible to non-reentrant scanners for convenience. */
643 
644 int slice_lex_destroy (void );
645 
646 int slice_get_debug (void );
647 
648 void slice_set_debug (int debug_flag  );
649 
650 YY_EXTRA_TYPE slice_get_extra (void );
651 
652 void slice_set_extra (YY_EXTRA_TYPE user_defined  );
653 
654 FILE *slice_get_in (void );
655 
656 void slice_set_in  (FILE * in_str  );
657 
658 FILE *slice_get_out (void );
659 
660 void slice_set_out  (FILE * out_str  );
661 
662 yy_size_t slice_get_leng (void );
663 
664 char *slice_get_text (void );
665 
666 int slice_get_lineno (void );
667 
668 void slice_set_lineno (int line_number  );
669 
670 /* Macros after this point can all be overridden by user definitions in
671  * section 1.
672  */
673 
674 #ifndef YY_SKIP_YYWRAP
675 #ifdef __cplusplus
676 extern "C" int slice_wrap (void );
677 #else
678 extern int slice_wrap (void );
679 #endif
680 #endif
681 
682     static void yyunput (int c,char *buf_ptr  );
683 
684 #ifndef yytext_ptr
685 static void yy_flex_strncpy (char *,yyconst char *,int );
686 #endif
687 
688 #ifdef YY_NEED_STRLEN
689 static int yy_flex_strlen (yyconst char * );
690 #endif
691 
692 #ifndef YY_NO_INPUT
693 
694 #ifdef __cplusplus
695 static int yyinput (void );
696 #else
697 static int input (void );
698 #endif
699 
700 #endif
701 
702 /* Amount of stuff to slurp up with each read. */
703 #ifndef YY_READ_BUF_SIZE
704 #define YY_READ_BUF_SIZE 8192
705 #endif
706 
707 /* Copy whatever the last rule matched to the standard output. */
708 #ifndef ECHO
709 /* This used to be an fputs(), but since the string might contain NUL's,
710  * we now use fwrite().
711  */
712 #define ECHO do { if (fwrite( slice_text, slice_leng, 1, slice_out )) {} } while (0)
713 #endif
714 
715 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
716  * is returned in "result".
717  */
718 #ifndef YY_INPUT
719 #define YY_INPUT(buf,result,max_size) \
720 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
721 		{ \
722 		int c = '*'; \
723 		size_t n; \
724 		for ( n = 0; n < max_size && \
725 			     (c = getc( slice_in )) != EOF && c != '\n'; ++n ) \
726 			buf[n] = (char) c; \
727 		if ( c == '\n' ) \
728 			buf[n++] = (char) c; \
729 		if ( c == EOF && ferror( slice_in ) ) \
730 			YY_FATAL_ERROR( "input in flex scanner failed" ); \
731 		result = n; \
732 		} \
733 	else \
734 		{ \
735 		errno=0; \
736 		while ( (result = fread(buf, 1, max_size, slice_in))==0 && ferror(slice_in)) \
737 			{ \
738 			if( errno != EINTR) \
739 				{ \
740 				YY_FATAL_ERROR( "input in flex scanner failed" ); \
741 				break; \
742 				} \
743 			errno=0; \
744 			clearerr(slice_in); \
745 			} \
746 		}\
747 \
748 
749 #endif
750 
751 /* No semi-colon after return; correct usage is to write "yyterminate();" -
752  * we don't want an extra ';' after the "return" because that will cause
753  * some compilers to complain about unreachable statements.
754  */
755 #ifndef yyterminate
756 #define yyterminate() return YY_NULL
757 #endif
758 
759 /* Number of entries by which start-condition stack grows. */
760 #ifndef YY_START_STACK_INCR
761 #define YY_START_STACK_INCR 25
762 #endif
763 
764 /* Report a fatal error. */
765 #ifndef YY_FATAL_ERROR
766 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
767 #endif
768 
769 /* end tables serialization structures and prototypes */
770 
771 /* Default declaration of generated scanner - a define so the user can
772  * easily add parameters.
773  */
774 #ifndef YY_DECL
775 #define YY_DECL_IS_OURS 1
776 
777 extern int slice_lex (void);
778 
779 #define YY_DECL int slice_lex (void)
780 #endif /* !YY_DECL */
781 
782 /* Code executed at the beginning of each rule, after slice_text and slice_leng
783  * have been set up.
784  */
785 #ifndef YY_USER_ACTION
786 #define YY_USER_ACTION
787 #endif
788 
789 /* Code executed at the end of each rule. */
790 #ifndef YY_BREAK
791 #define YY_BREAK break;
792 #endif
793 
794 #define YY_RULE_SETUP \
795 	if ( slice_leng > 0 ) \
796 		YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
797 				(slice_text[slice_leng - 1] == '\n'); \
798 	YY_USER_ACTION
799 
800 /** The main scanner function which does all the work.
801  */
802 YY_DECL
803 {
804 	register yy_state_type yy_current_state;
805 	register char *yy_cp, *yy_bp;
806 	register int yy_act;
807 
808 #line 93 "src/Slice/Scanner.l"
809 
810 
811 #line 816 "src/Slice/Scanner.cpp"
812 
813 	if ( !(yy_init) )
814 		{
815 		(yy_init) = 1;
816 
817 #ifdef YY_USER_INIT
818 		YY_USER_INIT;
819 #endif
820 
821 		if ( ! (yy_start) )
822 			(yy_start) = 1;	/* first start state */
823 
824 		if ( ! slice_in )
825 			slice_in = stdin;
826 
827 		if ( ! slice_out )
828 			slice_out = stdout;
829 
830 		if ( ! YY_CURRENT_BUFFER ) {
831 			slice_ensure_buffer_stack ();
832 			YY_CURRENT_BUFFER_LVALUE =
833 				slice__create_buffer(slice_in,YY_BUF_SIZE );
834 		}
835 
836 		slice__load_buffer_state( );
837 		}
838 
839 	while ( 1 )		/* loops until end-of-file is reached */
840 		{
841 		yy_cp = (yy_c_buf_p);
842 
843 		/* Support of slice_text. */
844 		*yy_cp = (yy_hold_char);
845 
846 		/* yy_bp points to the position in yy_ch_buf of the start of
847 		 * the current run.
848 		 */
849 		yy_bp = yy_cp;
850 
851 		yy_current_state = (yy_start);
852 		yy_current_state += YY_AT_BOL();
853 yy_match:
854 		do
855 			{
856 			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
857 			if ( yy_accept[yy_current_state] )
858 				{
859 				(yy_last_accepting_state) = yy_current_state;
860 				(yy_last_accepting_cpos) = yy_cp;
861 				}
862 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
863 				{
864 				yy_current_state = (int) yy_def[yy_current_state];
865 				if ( yy_current_state >= 76 )
866 					yy_c = yy_meta[(unsigned int) yy_c];
867 				}
868 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
869 			++yy_cp;
870 			}
871 		while ( yy_current_state != 75 );
872 		yy_cp = (yy_last_accepting_cpos);
873 		yy_current_state = (yy_last_accepting_state);
874 
875 yy_find_action:
876 		yy_act = yy_accept[yy_current_state];
877 
878 		YY_DO_BEFORE_ACTION;
879 
880 do_action:	/* This label is used only to access EOF actions. */
881 
882 		switch ( yy_act )
883 	{ /* beginning of action switch */
884 			case 0: /* must back up */
885 			/* undo the effects of YY_DO_BEFORE_ACTION */
886 			*yy_cp = (yy_hold_char);
887 			yy_cp = (yy_last_accepting_cpos);
888 			yy_current_state = (yy_last_accepting_state);
889 			goto yy_find_action;
890 
891 case 1:
892 *yy_cp = (yy_hold_char); /* undo effects of setting up slice_text */
893 (yy_c_buf_p) = yy_cp -= 1;
894 YY_DO_BEFORE_ACTION; /* set up slice_text again */
895 YY_RULE_SETUP
896 #line 95 "src/Slice/Scanner.l"
897 {
898     if(unit->scanPosition(slice_text))
899     {
900         BEGIN(BOMSCAN);
901     }
902 }
903 	YY_BREAK
904 case 2:
905 /* rule 2 can match eol */
906 *yy_cp = (yy_hold_char); /* undo effects of setting up slice_text */
907 (yy_c_buf_p) = yy_cp -= 1;
908 YY_DO_BEFORE_ACTION; /* set up slice_text again */
909 YY_RULE_SETUP
910 #line 102 "src/Slice/Scanner.l"
911 {
912     if(unit->scanPosition(slice_text))
913     {
914         BEGIN(BOMSCAN);
915     }
916 }
917 	YY_BREAK
918 case 3:
919 *yy_cp = (yy_hold_char); /* undo effects of setting up slice_text */
920 (yy_c_buf_p) = yy_cp -= 1;
921 YY_DO_BEFORE_ACTION; /* set up slice_text again */
922 YY_RULE_SETUP
923 #line 109 "src/Slice/Scanner.l"
924 {
925     if(unit->scanPosition(slice_text))
926     {
927         BEGIN(BOMSCAN);
928     }
929 }
930 	YY_BREAK
931 case 4:
932 /* rule 4 can match eol */
933 *yy_cp = (yy_hold_char); /* undo effects of setting up slice_text */
934 (yy_c_buf_p) = yy_cp -= 1;
935 YY_DO_BEFORE_ACTION; /* set up slice_text again */
936 YY_RULE_SETUP
937 #line 116 "src/Slice/Scanner.l"
938 {
939     if(unit->scanPosition(slice_text))
940     {
941         BEGIN(BOMSCAN);
942     }
943 }
944 	YY_BREAK
945 case 5:
946 YY_RULE_SETUP
947 #line 123 "src/Slice/Scanner.l"
948 {
949     // C++-style comment
950     BEGIN(MAINSCAN);
951     int c;
952     do
953     {
954         c = yyinput();
955         if(c == '\n')
956         {
957             unit->nextLine();
958         }
959     }
960     while(c != '\n' && c != EOF);
961 }
962 	YY_BREAK
963 case 6:
964 YY_RULE_SETUP
965 #line 138 "src/Slice/Scanner.l"
966 {
967     // C-style comment
968     BEGIN(MAINSCAN);
969     string comment = slice_text + 2;
970     while(true)
971     {
972         int c = yyinput();
973         if(c == '\n')
974         {
975             comment += static_cast<char>(c);
976             unit->nextLine();
977         }
978         else if(c == '*')
979         {
980             int next = yyinput();
981             if(next == '/')
982             {
983                 break;
984             }
985             else
986             {
987                 comment += static_cast<char>(c);
988                 unput(next);
989             }
990         }
991         else if(c == EOF)
992         {
993             unit->warning(All, "EOF in comment");
994             break;
995         }
996         else
997         {
998             comment += static_cast<char>(c);
999         }
1000     }
1001     if(!comment.empty() && comment[0] == '*')
1002     {
1003         unit->setComment(comment);
1004     }
1005 }
1006 	YY_BREAK
1007 case 7:
1008 YY_RULE_SETUP
1009 #line 179 "src/Slice/Scanner.l"
1010 {
1011     BEGIN(MAINSCAN);
1012     return ICE_METADATA_OPEN;
1013 }
1014 	YY_BREAK
1015 case 8:
1016 YY_RULE_SETUP
1017 #line 184 "src/Slice/Scanner.l"
1018 {
1019     BEGIN(MAINSCAN);
1020     return ICE_METADATA_CLOSE;
1021 }
1022 	YY_BREAK
1023 case 9:
1024 YY_RULE_SETUP
1025 #line 189 "src/Slice/Scanner.l"
1026 {
1027     BEGIN(MAINSCAN);
1028     return ICE_GLOBAL_METADATA_OPEN;
1029 }
1030 	YY_BREAK
1031 case 10:
1032 YY_RULE_SETUP
1033 #line 194 "src/Slice/Scanner.l"
1034 {
1035     BEGIN(MAINSCAN);
1036     return ICE_GLOBAL_METADATA_CLOSE;
1037 }
1038 	YY_BREAK
1039 case 11:
1040 /* rule 11 can match eol */
1041 YY_RULE_SETUP
1042 #line 199 "src/Slice/Scanner.l"
1043 {
1044     BEGIN(MAINSCAN);
1045     StringTokPtr ident = new StringTok;
1046     ident->v = *slice_text == '\\' ? slice_text + 1 : slice_text;
1047     ident->v.erase(ident->v.find_first_of(" \t\v\n\r\f("));
1048     *yylvalp = ident;
1049     if(*slice_text == '\\')
1050     {
1051         if(checkIdentifier(ident->v) == ICE_SCOPED_IDENTIFIER)
1052         {
1053             unit->error("Operation identifiers cannot be scoped: `" + (ident->v) + "'");
1054         }
1055         return ICE_IDENT_OP;
1056     }
1057     int st = checkKeyword(ident->v);
1058     if(st == ICE_IDENTIFIER)
1059     {
1060         return ICE_IDENT_OP;
1061     }
1062     else if(st == ICE_SCOPED_IDENTIFIER)
1063     {
1064         unit->error("Operation identifiers cannot be scoped: `" + (ident->v) + "'");
1065         return ICE_IDENT_OP;
1066     }
1067     else if(st == ICE_OPTIONAL)
1068     {
1069         return ICE_OPTIONAL_OP;
1070     }
1071     else
1072     {
1073         return ICE_KEYWORD_OP;
1074     }
1075 }
1076 	YY_BREAK
1077 case 12:
1078 YY_RULE_SETUP
1079 #line 233 "src/Slice/Scanner.l"
1080 {
1081     BEGIN(MAINSCAN);
1082     StringTokPtr ident = new StringTok;
1083     ident->v = *slice_text == '\\' ? slice_text + 1 : slice_text;
1084     *yylvalp = ident;
1085     return *slice_text == '\\' ? checkIdentifier(ident->v) : checkKeyword(ident->v);
1086 }
1087 	YY_BREAK
1088 case 13:
1089 YY_RULE_SETUP
1090 #line 241 "src/Slice/Scanner.l"
1091 {
1092     BEGIN(MAINSCAN);
1093     StringTokPtr str = new StringTok;
1094     str->literal = "\"";
1095     while(true)
1096     {
1097         int c = yyinput();
1098         str->literal += static_cast<char>(c);
1099         if(c == '"')
1100         {
1101             break;
1102         }
1103         else if(c == EOF)
1104         {
1105             unit->error("EOF in string");
1106             break;
1107         }
1108         else if(c < 32 || c == 127)
1109         {
1110             unit->error("a string literal can only contain printable ASCII characters and non-ASCII characters");
1111             break;
1112         }
1113         else if(c == '\\')
1114         {
1115             int next = yyinput();
1116             str->literal += static_cast<char>(next);
1117             switch(next)
1118             {
1119                 case '\\':
1120                 {
1121                     //
1122                     // add extra escape to our internal string
1123                     //
1124                     str->v += '\\';
1125                     str->v += '\\';
1126                     break;
1127                 }
1128                 case '"':
1129                 case '\'':
1130                 case '?':
1131                 {
1132                     str->v += static_cast<char>(next);
1133                     break;
1134                 }
1135                 case 'a':
1136                 {
1137                     str->v += '\a';
1138                     break;
1139                 }
1140                 case 'b':
1141                 {
1142                     str->v += '\b';
1143                     break;
1144                 }
1145                 case 'f':
1146                 {
1147                     str->v += '\f';
1148                     break;
1149                 }
1150                 case 'n':
1151                 {
1152                     str->v += '\n';
1153                     break;
1154                 }
1155                 case 'r':
1156                 {
1157                     str->v += '\r';
1158                     break;
1159                 }
1160                 case 't':
1161                 {
1162                     str->v += '\t';
1163                     break;
1164                 }
1165                 case 'v':
1166                 {
1167                     str->v += '\v';
1168                     break;
1169                 }
1170 
1171                 //
1172                 // Octal value \nnn limited to three octal digits but terminate at the first character
1173                 // that is not a valid octal digit if encountered sooner.
1174                 //
1175                 case '0':
1176                 case '1':
1177                 case '2':
1178                 case '3':
1179                 case '4':
1180                 case '5':
1181                 case '6':
1182                 case '7':
1183                 {
1184                     static string octalDigits = "01234567";
1185                     string escape;
1186                     escape += static_cast<char>(next);
1187                     for(int i = 0; i < 2; ++i)
1188                     {
1189                         next = yyinput();
1190                         if(octalDigits.find_first_of(static_cast<char>(next)) == string::npos)
1191                         {
1192                             unput(next);
1193                             break;
1194                         }
1195                         escape += static_cast<char>(next);
1196                     }
1197                     str->literal += escape;
1198                     IceUtil::Int64 value = IceUtilInternal::strToInt64(escape.c_str(), 0, 8);
1199                     if(value > 255)
1200                     {
1201                         unit->error(string("octal escape sequence out of range: `\\") + escape + "'");
1202                     }
1203                     str->v += static_cast<char>(value);
1204                     break;
1205                 }
1206 
1207                 case 'x':
1208                 {
1209                     string escape = "";
1210                     next = yyinput();
1211 
1212                     //
1213                     // Unlike C++, we limit hex escape sequences to 2 hex digits
1214                     //
1215                     while(isxdigit(static_cast<char>(next)) && escape.length() < 2)
1216                     {
1217                         escape += static_cast<char>(next);
1218                         next = yyinput();
1219                     }
1220                     unput(next);
1221 
1222                     if(escape.length() == 0)
1223                     {
1224                         unit->error("no hex digit in hex escape sequence");
1225                     }
1226 
1227                     str->literal += escape;
1228                     IceUtil::Int64 value = IceUtilInternal::strToInt64(escape.c_str(), 0, 16);
1229 
1230                     assert(value >= 0 && value <= 255);
1231                     str->v += static_cast<char>(value);
1232                     break;
1233                 }
1234 
1235                 //
1236                 // Universal character name
1237                 //
1238                 case 'u':
1239                 case 'U':
1240                 {
1241                     string escape = "";
1242                     c = next;
1243                     int size = (c == 'u') ? 4 : 8;
1244                     while(size > 0)
1245                     {
1246                         next = yyinput();
1247                         if(!isxdigit(next))
1248                         {
1249                             unit->error(string("unknown escape sequence in string literal: `\\") +
1250                                                static_cast<char>(c) + escape + static_cast<char>(next) + "'");
1251                             unput(next);
1252                             break;
1253                         }
1254                         escape += static_cast<char>(next);
1255                         --size;
1256                     }
1257 
1258                     if(size == 0)
1259                     {
1260                         // All digits read, check value
1261                         IceUtil::Int64 codePoint = IceUtilInternal::strToInt64(escape.c_str(), 0, 16);
1262                         if(codePoint >= 0xd800 && codePoint <= 0xdfff)
1263                         {
1264                             unit->error(string("a universal character name cannot designate a surrogate: `\\") +
1265                                                static_cast<char>(c) + escape + "'");
1266                         }
1267                     }
1268 
1269                     str->literal += escape;
1270                     str->v += string("\\") + static_cast<char>(c) + escape;
1271                     break;
1272                 }
1273 
1274                 default:
1275                 {
1276                     ostringstream os;
1277                     os << "unknown escape sequence `\\" << static_cast<char>(next) << "'";
1278                     unit->warning(All, os.str());
1279 
1280                     // Escape the \ in this unknown escape sequence
1281                     str->v += '\\';
1282                     str->v += '\\';
1283                     unput(next);
1284                 }
1285             }
1286         }
1287         else
1288         {
1289             str->v += static_cast<char>(c);
1290         }
1291     }
1292     *yylvalp = str;
1293     return ICE_STRING_LITERAL;
1294 }
1295 	YY_BREAK
1296 case 14:
1297 YY_RULE_SETUP
1298 #line 446 "src/Slice/Scanner.l"
1299 {
1300     BEGIN(MAINSCAN);
1301     IntegerTokPtr itp = new IntegerTok;
1302     itp->literal = string(slice_text);
1303     *yylvalp = itp;
1304     if(!IceUtilInternal::stringToInt64(string(slice_text), itp->v))
1305     {
1306         assert(itp->v != 0);
1307         string msg = "integer constant `";
1308         msg += slice_text;
1309         msg += "' out of range";
1310         unit->error(msg);
1311     }
1312     return ICE_INTEGER_LITERAL;
1313 }
1314 	YY_BREAK
1315 case 15:
1316 YY_RULE_SETUP
1317 #line 462 "src/Slice/Scanner.l"
1318 {
1319     BEGIN(MAINSCAN);
1320     errno = 0;
1321     FloatingTokPtr ftp = new FloatingTok;
1322     *yylvalp = ftp;
1323     string literal(slice_text);
1324     ftp->literal = literal;
1325     char lastChar = literal[literal.size() - 1];
1326     if(lastChar == 'f' || lastChar == 'F')
1327     {
1328         literal = literal.substr(0, literal.size() - 1);    // Clobber trailing 'f' or 'F' suffix
1329     }
1330     ftp->v = strtod(literal.c_str(), 0);
1331     if((ftp->v == HUGE_VAL || ftp->v == -HUGE_VAL) && errno == ERANGE)
1332     {
1333         string msg = "floating-point constant `";
1334         msg += slice_text;
1335         msg += "' too large (overflow)";
1336         unit->error(msg);
1337     }
1338     else if(ftp->v == 0 && errno == ERANGE)
1339     {
1340         string msg = "floating-point constant `";
1341         msg += slice_text;
1342         msg += "' too small (underflow)";
1343     unit->error(msg);
1344     }
1345     return ICE_FLOATING_POINT_LITERAL;
1346 }
1347 	YY_BREAK
1348 case 16:
1349 /* rule 16 can match eol */
1350 YY_RULE_SETUP
1351 #line 492 "src/Slice/Scanner.l"
1352 {
1353     // Ignore white-space
1354 
1355     if(unit->currentLine() != 0)
1356     {
1357         BEGIN(MAINSCAN);
1358     }
1359     if(slice_text[0] == '\n')
1360     {
1361         unit->nextLine();
1362     }
1363 }
1364 	YY_BREAK
1365 case 17:
1366 YY_RULE_SETUP
1367 #line 505 "src/Slice/Scanner.l"
1368 {
1369     // Ignore UTF-8 BOM, rule only active when parsing start of file.
1370 
1371     BEGIN(MAINSCAN);
1372 }
1373 	YY_BREAK
1374 case 18:
1375 YY_RULE_SETUP
1376 #line 511 "src/Slice/Scanner.l"
1377 {
1378     BEGIN(MAINSCAN);
1379     if(slice_text[0] < 32 || slice_text[0] > 126)
1380     {
1381         stringstream s;
1382         s << "illegal input character: '\\";
1383         s.width(3);
1384         s.fill('0');
1385         s << oct << static_cast<int>(static_cast<unsigned char>(slice_text[0]));
1386         s << "'";
1387         unit->error(s.str());
1388         return BAD_CHAR;
1389     }
1390     return slice_text[0];
1391 }
1392 	YY_BREAK
1393 case 19:
1394 YY_RULE_SETUP
1395 #line 527 "src/Slice/Scanner.l"
1396 ECHO;
1397 	YY_BREAK
1398 #line 1403 "src/Slice/Scanner.cpp"
1399 case YY_STATE_EOF(INITIAL):
1400 case YY_STATE_EOF(BOMSCAN):
1401 case YY_STATE_EOF(MAINSCAN):
1402 	yyterminate();
1403 
1404 	case YY_END_OF_BUFFER:
1405 		{
1406 		/* Amount of text matched not including the EOB char. */
1407 		int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1408 
1409 		/* Undo the effects of YY_DO_BEFORE_ACTION. */
1410 		*yy_cp = (yy_hold_char);
1411 		YY_RESTORE_YY_MORE_OFFSET
1412 
1413 		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1414 			{
1415 			/* We're scanning a new file or input source.  It's
1416 			 * possible that this happened because the user
1417 			 * just pointed slice_in at a new source and called
1418 			 * slice_lex().  If so, then we have to assure
1419 			 * consistency between YY_CURRENT_BUFFER and our
1420 			 * globals.  Here is the right place to do so, because
1421 			 * this is the first action (other than possibly a
1422 			 * back-up) that will match for the new input source.
1423 			 */
1424 			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1425 			YY_CURRENT_BUFFER_LVALUE->yy_input_file = slice_in;
1426 			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1427 			}
1428 
1429 		/* Note that here we test for yy_c_buf_p "<=" to the position
1430 		 * of the first EOB in the buffer, since yy_c_buf_p will
1431 		 * already have been incremented past the NUL character
1432 		 * (since all states make transitions on EOB to the
1433 		 * end-of-buffer state).  Contrast this with the test
1434 		 * in input().
1435 		 */
1436 		if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1437 			{ /* This was really a NUL. */
1438 			yy_state_type yy_next_state;
1439 
1440 			(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1441 
1442 			yy_current_state = yy_get_previous_state(  );
1443 
1444 			/* Okay, we're now positioned to make the NUL
1445 			 * transition.  We couldn't have
1446 			 * yy_get_previous_state() go ahead and do it
1447 			 * for us because it doesn't know how to deal
1448 			 * with the possibility of jamming (and we don't
1449 			 * want to build jamming into it because then it
1450 			 * will run more slowly).
1451 			 */
1452 
1453 			yy_next_state = yy_try_NUL_trans( yy_current_state );
1454 
1455 			yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1456 
1457 			if ( yy_next_state )
1458 				{
1459 				/* Consume the NUL. */
1460 				yy_cp = ++(yy_c_buf_p);
1461 				yy_current_state = yy_next_state;
1462 				goto yy_match;
1463 				}
1464 
1465 			else
1466 				{
1467 				yy_cp = (yy_last_accepting_cpos);
1468 				yy_current_state = (yy_last_accepting_state);
1469 				goto yy_find_action;
1470 				}
1471 			}
1472 
1473 		else switch ( yy_get_next_buffer(  ) )
1474 			{
1475 			case EOB_ACT_END_OF_FILE:
1476 				{
1477 				(yy_did_buffer_switch_on_eof) = 0;
1478 
1479 				if ( slice_wrap( ) )
1480 					{
1481 					/* Note: because we've taken care in
1482 					 * yy_get_next_buffer() to have set up
1483 					 * slice_text, we can now set up
1484 					 * yy_c_buf_p so that if some total
1485 					 * hoser (like flex itself) wants to
1486 					 * call the scanner after we return the
1487 					 * YY_NULL, it'll still work - another
1488 					 * YY_NULL will get returned.
1489 					 */
1490 					(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1491 
1492 					yy_act = YY_STATE_EOF(YY_START);
1493 					goto do_action;
1494 					}
1495 
1496 				else
1497 					{
1498 					if ( ! (yy_did_buffer_switch_on_eof) )
1499 						YY_NEW_FILE;
1500 					}
1501 				break;
1502 				}
1503 
1504 			case EOB_ACT_CONTINUE_SCAN:
1505 				(yy_c_buf_p) =
1506 					(yytext_ptr) + yy_amount_of_matched_text;
1507 
1508 				yy_current_state = yy_get_previous_state(  );
1509 
1510 				yy_cp = (yy_c_buf_p);
1511 				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1512 				goto yy_match;
1513 
1514 			case EOB_ACT_LAST_MATCH:
1515 				(yy_c_buf_p) =
1516 				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1517 
1518 				yy_current_state = yy_get_previous_state(  );
1519 
1520 				yy_cp = (yy_c_buf_p);
1521 				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1522 				goto yy_find_action;
1523 			}
1524 		break;
1525 		}
1526 
1527 	default:
1528 		YY_FATAL_ERROR(
1529 			"fatal flex scanner internal error--no action found" );
1530 	} /* end of action switch */
1531 		} /* end of scanning one token */
1532 } /* end of slice_lex */
1533 
1534 /* yy_get_next_buffer - try to read in a new buffer
1535  *
1536  * Returns a code representing an action:
1537  *	EOB_ACT_LAST_MATCH -
1538  *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1539  *	EOB_ACT_END_OF_FILE - end of file
1540  */
1541 static int yy_get_next_buffer (void)
1542 {
1543     	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1544 	register char *source = (yytext_ptr);
1545 	register int number_to_move, i;
1546 	int ret_val;
1547 
1548 	if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1549 		YY_FATAL_ERROR(
1550 		"fatal flex scanner internal error--end of buffer missed" );
1551 
1552 	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1553 		{ /* Don't try to fill the buffer, so this is an EOF. */
1554 		if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1555 			{
1556 			/* We matched a single character, the EOB, so
1557 			 * treat this as a final EOF.
1558 			 */
1559 			return EOB_ACT_END_OF_FILE;
1560 			}
1561 
1562 		else
1563 			{
1564 			/* We matched some text prior to the EOB, first
1565 			 * process it.
1566 			 */
1567 			return EOB_ACT_LAST_MATCH;
1568 			}
1569 		}
1570 
1571 	/* Try to read more data. */
1572 
1573 	/* First move last chars to start of buffer. */
1574 	number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1575 
1576 	for ( i = 0; i < number_to_move; ++i )
1577 		*(dest++) = *(source++);
1578 
1579 	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1580 		/* don't do the read, it's not guaranteed to return an EOF,
1581 		 * just force an EOF
1582 		 */
1583 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1584 
1585 	else
1586 		{
1587 			yy_size_t num_to_read =
1588 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1589 
1590 		while ( num_to_read <= 0 )
1591 			{ /* Not enough room in the buffer - grow it. */
1592 
1593 			/* just a shorter name for the current buffer */
1594 			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1595 
1596 			int yy_c_buf_p_offset =
1597 				(int) ((yy_c_buf_p) - b->yy_ch_buf);
1598 
1599 			if ( b->yy_is_our_buffer )
1600 				{
1601 				yy_size_t new_size = b->yy_buf_size * 2;
1602 
1603 				if ( new_size <= 0 )
1604 					b->yy_buf_size += b->yy_buf_size / 8;
1605 				else
1606 					b->yy_buf_size *= 2;
1607 
1608 				b->yy_ch_buf = (char *)
1609 					/* Include room in for 2 EOB chars. */
1610 					slice_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
1611 				}
1612 			else
1613 				/* Can't grow it, we don't own it. */
1614 				b->yy_ch_buf = 0;
1615 
1616 			if ( ! b->yy_ch_buf )
1617 				YY_FATAL_ERROR(
1618 				"fatal error - scanner input buffer overflow" );
1619 
1620 			(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1621 
1622 			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1623 						number_to_move - 1;
1624 
1625 			}
1626 
1627 		if ( num_to_read > YY_READ_BUF_SIZE )
1628 			num_to_read = YY_READ_BUF_SIZE;
1629 
1630 		/* Read in more data. */
1631 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1632 			(yy_n_chars), num_to_read );
1633 
1634 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1635 		}
1636 
1637 	if ( (yy_n_chars) == 0 )
1638 		{
1639 		if ( number_to_move == YY_MORE_ADJ )
1640 			{
1641 			ret_val = EOB_ACT_END_OF_FILE;
1642 			slice_restart(slice_in  );
1643 			}
1644 
1645 		else
1646 			{
1647 			ret_val = EOB_ACT_LAST_MATCH;
1648 			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1649 				YY_BUFFER_EOF_PENDING;
1650 			}
1651 		}
1652 
1653 	else
1654 		ret_val = EOB_ACT_CONTINUE_SCAN;
1655 
1656 	if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1657 		/* Extend the array by 50%, plus the number we really need. */
1658 		yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1659 		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) slice_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
1660 		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1661 			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1662 	}
1663 
1664 	(yy_n_chars) += number_to_move;
1665 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1666 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1667 
1668 	(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1669 
1670 	return ret_val;
1671 }
1672 
1673 /* yy_get_previous_state - get the state just before the EOB char was reached */
1674 
yy_get_previous_state(void)1675     static yy_state_type yy_get_previous_state (void)
1676 {
1677 	register yy_state_type yy_current_state;
1678 	register char *yy_cp;
1679 
1680 	yy_current_state = (yy_start);
1681 	yy_current_state += YY_AT_BOL();
1682 
1683 	for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1684 		{
1685 		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1686 		if ( yy_accept[yy_current_state] )
1687 			{
1688 			(yy_last_accepting_state) = yy_current_state;
1689 			(yy_last_accepting_cpos) = yy_cp;
1690 			}
1691 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1692 			{
1693 			yy_current_state = (int) yy_def[yy_current_state];
1694 			if ( yy_current_state >= 76 )
1695 				yy_c = yy_meta[(unsigned int) yy_c];
1696 			}
1697 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1698 		}
1699 
1700 	return yy_current_state;
1701 }
1702 
1703 /* yy_try_NUL_trans - try to make a transition on the NUL character
1704  *
1705  * synopsis
1706  *	next_state = yy_try_NUL_trans( current_state );
1707  */
yy_try_NUL_trans(yy_state_type yy_current_state)1708     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
1709 {
1710 	register int yy_is_jam;
1711     	register char *yy_cp = (yy_c_buf_p);
1712 
1713 	register YY_CHAR yy_c = 1;
1714 	if ( yy_accept[yy_current_state] )
1715 		{
1716 		(yy_last_accepting_state) = yy_current_state;
1717 		(yy_last_accepting_cpos) = yy_cp;
1718 		}
1719 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1720 		{
1721 		yy_current_state = (int) yy_def[yy_current_state];
1722 		if ( yy_current_state >= 76 )
1723 			yy_c = yy_meta[(unsigned int) yy_c];
1724 		}
1725 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1726 	yy_is_jam = (yy_current_state == 75);
1727 
1728 		return yy_is_jam ? 0 : yy_current_state;
1729 }
1730 
yyunput(int c,register char * yy_bp)1731     static void yyunput (int c, register char * yy_bp )
1732 {
1733 	register char *yy_cp;
1734 
1735     yy_cp = (yy_c_buf_p);
1736 
1737 	/* undo effects of setting up slice_text */
1738 	*yy_cp = (yy_hold_char);
1739 
1740 	if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1741 		{ /* need to shift things up to make room */
1742 		/* +2 for EOB chars. */
1743 		register yy_size_t number_to_move = (yy_n_chars) + 2;
1744 		register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1745 					YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1746 		register char *source =
1747 				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1748 
1749 		while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1750 			*--dest = *--source;
1751 
1752 		yy_cp += (int) (dest - source);
1753 		yy_bp += (int) (dest - source);
1754 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1755 			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1756 
1757 		if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1758 			YY_FATAL_ERROR( "flex scanner push-back overflow" );
1759 		}
1760 
1761 	*--yy_cp = (char) c;
1762 
1763 	(yytext_ptr) = yy_bp;
1764 	(yy_hold_char) = *yy_cp;
1765 	(yy_c_buf_p) = yy_cp;
1766 }
1767 
1768 #ifndef YY_NO_INPUT
1769 #ifdef __cplusplus
yyinput(void)1770     static int yyinput (void)
1771 #else
1772     static int input  (void)
1773 #endif
1774 
1775 {
1776 	int c;
1777 
1778 	*(yy_c_buf_p) = (yy_hold_char);
1779 
1780 	if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1781 		{
1782 		/* yy_c_buf_p now points to the character we want to return.
1783 		 * If this occurs *before* the EOB characters, then it's a
1784 		 * valid NUL; if not, then we've hit the end of the buffer.
1785 		 */
1786 		if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1787 			/* This was really a NUL. */
1788 			*(yy_c_buf_p) = '\0';
1789 
1790 		else
1791 			{ /* need more input */
1792 			yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1793 			++(yy_c_buf_p);
1794 
1795 			switch ( yy_get_next_buffer(  ) )
1796 				{
1797 				case EOB_ACT_LAST_MATCH:
1798 					/* This happens because yy_g_n_b()
1799 					 * sees that we've accumulated a
1800 					 * token and flags that we need to
1801 					 * try matching the token before
1802 					 * proceeding.  But for input(),
1803 					 * there's no matching to consider.
1804 					 * So convert the EOB_ACT_LAST_MATCH
1805 					 * to EOB_ACT_END_OF_FILE.
1806 					 */
1807 
1808 					/* Reset buffer status. */
1809 					slice_restart(slice_in );
1810 
1811 					/*FALLTHROUGH*/
1812 
1813 				case EOB_ACT_END_OF_FILE:
1814 					{
1815 					if ( slice_wrap( ) )
1816 						return EOF;
1817 
1818 					if ( ! (yy_did_buffer_switch_on_eof) )
1819 						YY_NEW_FILE;
1820 #ifdef __cplusplus
1821 					return yyinput();
1822 #else
1823 					return input();
1824 #endif
1825 					}
1826 
1827 				case EOB_ACT_CONTINUE_SCAN:
1828 					(yy_c_buf_p) = (yytext_ptr) + offset;
1829 					break;
1830 				}
1831 			}
1832 		}
1833 
1834 	c = *(unsigned char *) (yy_c_buf_p);	/* cast for 8-bit char's */
1835 	*(yy_c_buf_p) = '\0';	/* preserve slice_text */
1836 	(yy_hold_char) = *++(yy_c_buf_p);
1837 
1838 	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
1839 
1840 	return c;
1841 }
1842 #endif	/* ifndef YY_NO_INPUT */
1843 
1844 /** Immediately switch to a different input stream.
1845  * @param input_file A readable stream.
1846  *
1847  * @note This function does not reset the start condition to @c INITIAL .
1848  */
slice_restart(FILE * input_file)1849     void slice_restart  (FILE * input_file )
1850 {
1851 
1852 	if ( ! YY_CURRENT_BUFFER ){
1853         slice_ensure_buffer_stack ();
1854 		YY_CURRENT_BUFFER_LVALUE =
1855             slice__create_buffer(slice_in,YY_BUF_SIZE );
1856 	}
1857 
1858 	slice__init_buffer(YY_CURRENT_BUFFER,input_file );
1859 	slice__load_buffer_state( );
1860 }
1861 
1862 /** Switch to a different input buffer.
1863  * @param new_buffer The new input buffer.
1864  *
1865  */
slice__switch_to_buffer(YY_BUFFER_STATE new_buffer)1866     void slice__switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
1867 {
1868 
1869 	/* TODO. We should be able to replace this entire function body
1870 	 * with
1871 	 *		slice_pop_buffer_state();
1872 	 *		slice_push_buffer_state(new_buffer);
1873      */
1874 	slice_ensure_buffer_stack ();
1875 	if ( YY_CURRENT_BUFFER == new_buffer )
1876 		return;
1877 
1878 	if ( YY_CURRENT_BUFFER )
1879 		{
1880 		/* Flush out information for old buffer. */
1881 		*(yy_c_buf_p) = (yy_hold_char);
1882 		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1883 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1884 		}
1885 
1886 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1887 	slice__load_buffer_state( );
1888 
1889 	/* We don't actually know whether we did this switch during
1890 	 * EOF (slice_wrap()) processing, but the only time this flag
1891 	 * is looked at is after slice_wrap() is called, so it's safe
1892 	 * to go ahead and always set it.
1893 	 */
1894 	(yy_did_buffer_switch_on_eof) = 1;
1895 }
1896 
slice__load_buffer_state(void)1897 static void slice__load_buffer_state  (void)
1898 {
1899     	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1900 	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1901 	slice_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1902 	(yy_hold_char) = *(yy_c_buf_p);
1903 }
1904 
1905 /** Allocate and initialize an input buffer state.
1906  * @param file A readable stream.
1907  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1908  *
1909  * @return the allocated buffer state.
1910  */
slice__create_buffer(FILE * file,int size)1911     YY_BUFFER_STATE slice__create_buffer  (FILE * file, int  size )
1912 {
1913 	YY_BUFFER_STATE b;
1914 
1915 	b = (YY_BUFFER_STATE) slice_alloc(sizeof( struct yy_buffer_state )  );
1916 	if ( ! b )
1917 		YY_FATAL_ERROR( "out of dynamic memory in slice__create_buffer()" );
1918 
1919 	b->yy_buf_size = size;
1920 
1921 	/* yy_ch_buf has to be 2 characters longer than the size given because
1922 	 * we need to put in 2 end-of-buffer characters.
1923 	 */
1924 	b->yy_ch_buf = (char *) slice_alloc(b->yy_buf_size + 2  );
1925 	if ( ! b->yy_ch_buf )
1926 		YY_FATAL_ERROR( "out of dynamic memory in slice__create_buffer()" );
1927 
1928 	b->yy_is_our_buffer = 1;
1929 
1930 	slice__init_buffer(b,file );
1931 
1932 	return b;
1933 }
1934 
1935 /** Destroy the buffer.
1936  * @param b a buffer created with slice__create_buffer()
1937  *
1938  */
slice__delete_buffer(YY_BUFFER_STATE b)1939     void slice__delete_buffer (YY_BUFFER_STATE  b )
1940 {
1941 
1942 	if ( ! b )
1943 		return;
1944 
1945 	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1946 		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1947 
1948 	if ( b->yy_is_our_buffer )
1949 		slice_free((void *) b->yy_ch_buf  );
1950 
1951 	slice_free((void *) b  );
1952 }
1953 
1954 /* Initializes or reinitializes a buffer.
1955  * This function is sometimes called more than once on the same buffer,
1956  * such as during a slice_restart() or at EOF.
1957  */
slice__init_buffer(YY_BUFFER_STATE b,FILE * file)1958     static void slice__init_buffer  (YY_BUFFER_STATE  b, FILE * file )
1959 
1960 {
1961 	int oerrno = errno;
1962 
1963 	slice__flush_buffer(b );
1964 
1965 	b->yy_input_file = file;
1966 	b->yy_fill_buffer = 1;
1967 
1968     /* If b is the current buffer, then slice__init_buffer was _probably_
1969      * called from slice_restart() or through yy_get_next_buffer.
1970      * In that case, we don't want to reset the lineno or column.
1971      */
1972     if (b != YY_CURRENT_BUFFER){
1973         b->yy_bs_lineno = 1;
1974         b->yy_bs_column = 0;
1975     }
1976 
1977         b->yy_is_interactive = 0;
1978 
1979 	errno = oerrno;
1980 }
1981 
1982 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1983  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1984  *
1985  */
slice__flush_buffer(YY_BUFFER_STATE b)1986     void slice__flush_buffer (YY_BUFFER_STATE  b )
1987 {
1988     	if ( ! b )
1989 		return;
1990 
1991 	b->yy_n_chars = 0;
1992 
1993 	/* We always need two end-of-buffer characters.  The first causes
1994 	 * a transition to the end-of-buffer state.  The second causes
1995 	 * a jam in that state.
1996 	 */
1997 	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1998 	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1999 
2000 	b->yy_buf_pos = &b->yy_ch_buf[0];
2001 
2002 	b->yy_at_bol = 1;
2003 	b->yy_buffer_status = YY_BUFFER_NEW;
2004 
2005 	if ( b == YY_CURRENT_BUFFER )
2006 		slice__load_buffer_state( );
2007 }
2008 
2009 /** Pushes the new state onto the stack. The new state becomes
2010  *  the current state. This function will allocate the stack
2011  *  if necessary.
2012  *  @param new_buffer The new state.
2013  *
2014  */
slice_push_buffer_state(YY_BUFFER_STATE new_buffer)2015 void slice_push_buffer_state (YY_BUFFER_STATE new_buffer )
2016 {
2017     	if (new_buffer == NULL)
2018 		return;
2019 
2020 	slice_ensure_buffer_stack();
2021 
2022 	/* This block is copied from slice__switch_to_buffer. */
2023 	if ( YY_CURRENT_BUFFER )
2024 		{
2025 		/* Flush out information for old buffer. */
2026 		*(yy_c_buf_p) = (yy_hold_char);
2027 		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
2028 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2029 		}
2030 
2031 	/* Only push if top exists. Otherwise, replace top. */
2032 	if (YY_CURRENT_BUFFER)
2033 		(yy_buffer_stack_top)++;
2034 	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2035 
2036 	/* copied from slice__switch_to_buffer. */
2037 	slice__load_buffer_state( );
2038 	(yy_did_buffer_switch_on_eof) = 1;
2039 }
2040 
2041 /** Removes and deletes the top of the stack, if present.
2042  *  The next element becomes the new top.
2043  *
2044  */
slice_pop_buffer_state(void)2045 void slice_pop_buffer_state (void)
2046 {
2047     	if (!YY_CURRENT_BUFFER)
2048 		return;
2049 
2050 	slice__delete_buffer(YY_CURRENT_BUFFER );
2051 	YY_CURRENT_BUFFER_LVALUE = NULL;
2052 	if ((yy_buffer_stack_top) > 0)
2053 		--(yy_buffer_stack_top);
2054 
2055 	if (YY_CURRENT_BUFFER) {
2056 		slice__load_buffer_state( );
2057 		(yy_did_buffer_switch_on_eof) = 1;
2058 	}
2059 }
2060 
2061 /* Allocates the stack if it does not exist.
2062  *  Guarantees space for at least one push.
2063  */
slice_ensure_buffer_stack(void)2064 static void slice_ensure_buffer_stack (void)
2065 {
2066 	yy_size_t num_to_alloc;
2067 
2068 	if (!(yy_buffer_stack)) {
2069 
2070 		/* First allocation is just for 2 elements, since we don't know if this
2071 		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2072 		 * immediate realloc on the next call.
2073          */
2074 		num_to_alloc = 1;
2075 		(yy_buffer_stack) = (struct yy_buffer_state**)slice_alloc
2076 								(num_to_alloc * sizeof(struct yy_buffer_state*)
2077 								);
2078 		if ( ! (yy_buffer_stack) )
2079 			YY_FATAL_ERROR( "out of dynamic memory in slice_ensure_buffer_stack()" );
2080 
2081 		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2082 
2083 		(yy_buffer_stack_max) = num_to_alloc;
2084 		(yy_buffer_stack_top) = 0;
2085 		return;
2086 	}
2087 
2088 	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
2089 
2090 		/* Increase the buffer to prepare for a possible push. */
2091 		int grow_size = 8 /* arbitrary grow size */;
2092 
2093 		num_to_alloc = (yy_buffer_stack_max) + grow_size;
2094 		(yy_buffer_stack) = (struct yy_buffer_state**)slice_realloc
2095 								((yy_buffer_stack),
2096 								num_to_alloc * sizeof(struct yy_buffer_state*)
2097 								);
2098 		if ( ! (yy_buffer_stack) )
2099 			YY_FATAL_ERROR( "out of dynamic memory in slice_ensure_buffer_stack()" );
2100 
2101 		/* zero only the new slots.*/
2102 		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
2103 		(yy_buffer_stack_max) = num_to_alloc;
2104 	}
2105 }
2106 
2107 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2108  * @param base the character buffer
2109  * @param size the size in bytes of the character buffer
2110  *
2111  * @return the newly allocated buffer state object.
2112  */
slice__scan_buffer(char * base,yy_size_t size)2113 YY_BUFFER_STATE slice__scan_buffer  (char * base, yy_size_t  size )
2114 {
2115 	YY_BUFFER_STATE b;
2116 
2117 	if ( size < 2 ||
2118 	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
2119 	     base[size-1] != YY_END_OF_BUFFER_CHAR )
2120 		/* They forgot to leave room for the EOB's. */
2121 		return 0;
2122 
2123 	b = (YY_BUFFER_STATE) slice_alloc(sizeof( struct yy_buffer_state )  );
2124 	if ( ! b )
2125 		YY_FATAL_ERROR( "out of dynamic memory in slice__scan_buffer()" );
2126 
2127 	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
2128 	b->yy_buf_pos = b->yy_ch_buf = base;
2129 	b->yy_is_our_buffer = 0;
2130 	b->yy_input_file = 0;
2131 	b->yy_n_chars = b->yy_buf_size;
2132 	b->yy_is_interactive = 0;
2133 	b->yy_at_bol = 1;
2134 	b->yy_fill_buffer = 0;
2135 	b->yy_buffer_status = YY_BUFFER_NEW;
2136 
2137 	slice__switch_to_buffer(b  );
2138 
2139 	return b;
2140 }
2141 
2142 /** Setup the input buffer state to scan a string. The next call to slice_lex() will
2143  * scan from a @e copy of @a str.
2144  * @param yystr a NUL-terminated string to scan
2145  *
2146  * @return the newly allocated buffer state object.
2147  * @note If you want to scan bytes that may contain NUL values, then use
2148  *       slice__scan_bytes() instead.
2149  */
slice__scan_string(yyconst char * yystr)2150 YY_BUFFER_STATE slice__scan_string (yyconst char * yystr )
2151 {
2152 
2153 	return slice__scan_bytes(yystr,strlen(yystr) );
2154 }
2155 
2156 /** Setup the input buffer state to scan the given bytes. The next call to slice_lex() will
2157  * scan from a @e copy of @a bytes.
2158  * @param yybytes the byte buffer to scan
2159  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2160  *
2161  * @return the newly allocated buffer state object.
2162  */
slice__scan_bytes(yyconst char * yybytes,yy_size_t _yybytes_len)2163 YY_BUFFER_STATE slice__scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len )
2164 {
2165 	YY_BUFFER_STATE b;
2166 	char *buf;
2167 	yy_size_t n;
2168 	int i;
2169 
2170 	/* Get memory for full buffer, including space for trailing EOB's. */
2171 	n = _yybytes_len + 2;
2172 	buf = (char *) slice_alloc(n  );
2173 	if ( ! buf )
2174 		YY_FATAL_ERROR( "out of dynamic memory in slice__scan_bytes()" );
2175 
2176 	for ( i = 0; i < _yybytes_len; ++i )
2177 		buf[i] = yybytes[i];
2178 
2179 	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2180 
2181 	b = slice__scan_buffer(buf,n );
2182 	if ( ! b )
2183 		YY_FATAL_ERROR( "bad buffer in slice__scan_bytes()" );
2184 
2185 	/* It's okay to grow etc. this buffer, and we should throw it
2186 	 * away when we're done.
2187 	 */
2188 	b->yy_is_our_buffer = 1;
2189 
2190 	return b;
2191 }
2192 
2193 #ifndef YY_EXIT_FAILURE
2194 #define YY_EXIT_FAILURE 2
2195 #endif
2196 
yy_fatal_error(yyconst char * msg)2197 static void yy_fatal_error (yyconst char* msg )
2198 {
2199     	(void) fprintf( stderr, "%s\n", msg );
2200 	exit( YY_EXIT_FAILURE );
2201 }
2202 
2203 /* Redefine yyless() so it works in section 3 code. */
2204 
2205 #undef yyless
2206 #define yyless(n) \
2207 	do \
2208 		{ \
2209 		/* Undo effects of setting up slice_text. */ \
2210         int yyless_macro_arg = (n); \
2211         YY_LESS_LINENO(yyless_macro_arg);\
2212 		slice_text[slice_leng] = (yy_hold_char); \
2213 		(yy_c_buf_p) = slice_text + yyless_macro_arg; \
2214 		(yy_hold_char) = *(yy_c_buf_p); \
2215 		*(yy_c_buf_p) = '\0'; \
2216 		slice_leng = yyless_macro_arg; \
2217 		} \
2218 	while ( 0 )
2219 
2220 /* Accessor  methods (get/set functions) to struct members. */
2221 
2222 /** Get the current line number.
2223  *
2224  */
slice_get_lineno(void)2225 int slice_get_lineno  (void)
2226 {
2227 
2228     return slice_lineno;
2229 }
2230 
2231 /** Get the input stream.
2232  *
2233  */
slice_get_in(void)2234 FILE *slice_get_in  (void)
2235 {
2236         return slice_in;
2237 }
2238 
2239 /** Get the output stream.
2240  *
2241  */
slice_get_out(void)2242 FILE *slice_get_out  (void)
2243 {
2244         return slice_out;
2245 }
2246 
2247 /** Get the length of the current token.
2248  *
2249  */
slice_get_leng(void)2250 yy_size_t slice_get_leng  (void)
2251 {
2252         return slice_leng;
2253 }
2254 
2255 /** Get the current token.
2256  *
2257  */
2258 
slice_get_text(void)2259 char *slice_get_text  (void)
2260 {
2261         return slice_text;
2262 }
2263 
2264 /** Set the current line number.
2265  * @param line_number
2266  *
2267  */
slice_set_lineno(int line_number)2268 void slice_set_lineno (int  line_number )
2269 {
2270 
2271     slice_lineno = line_number;
2272 }
2273 
2274 /** Set the input stream. This does not discard the current
2275  * input buffer.
2276  * @param in_str A readable stream.
2277  *
2278  * @see slice__switch_to_buffer
2279  */
slice_set_in(FILE * in_str)2280 void slice_set_in (FILE *  in_str )
2281 {
2282         slice_in = in_str ;
2283 }
2284 
slice_set_out(FILE * out_str)2285 void slice_set_out (FILE *  out_str )
2286 {
2287         slice_out = out_str ;
2288 }
2289 
slice_get_debug(void)2290 int slice_get_debug  (void)
2291 {
2292         return slice__flex_debug;
2293 }
2294 
slice_set_debug(int bdebug)2295 void slice_set_debug (int  bdebug )
2296 {
2297         slice__flex_debug = bdebug ;
2298 }
2299 
yy_init_globals(void)2300 static int yy_init_globals (void)
2301 {
2302         /* Initialization is the same as for the non-reentrant scanner.
2303      * This function is called from slice_lex_destroy(), so don't allocate here.
2304      */
2305 
2306     (yy_buffer_stack) = 0;
2307     (yy_buffer_stack_top) = 0;
2308     (yy_buffer_stack_max) = 0;
2309     (yy_c_buf_p) = (char *) 0;
2310     (yy_init) = 0;
2311     (yy_start) = 0;
2312 
2313 /* Defined in main.c */
2314 #ifdef YY_STDINIT
2315     slice_in = stdin;
2316     slice_out = stdout;
2317 #else
2318     slice_in = (FILE *) 0;
2319     slice_out = (FILE *) 0;
2320 #endif
2321 
2322     /* For future reference: Set errno on error, since we are called by
2323      * slice_lex_init()
2324      */
2325     return 0;
2326 }
2327 
2328 /* slice_lex_destroy is for both reentrant and non-reentrant scanners. */
slice_lex_destroy(void)2329 int slice_lex_destroy  (void)
2330 {
2331 
2332     /* Pop the buffer stack, destroying each element. */
2333 	while(YY_CURRENT_BUFFER){
2334 		slice__delete_buffer(YY_CURRENT_BUFFER  );
2335 		YY_CURRENT_BUFFER_LVALUE = NULL;
2336 		slice_pop_buffer_state();
2337 	}
2338 
2339 	/* Destroy the stack itself. */
2340 	slice_free((yy_buffer_stack) );
2341 	(yy_buffer_stack) = NULL;
2342 
2343     /* Reset the globals. This is important in a non-reentrant scanner so the next time
2344      * slice_lex() is called, initialization will occur. */
2345     yy_init_globals( );
2346 
2347     return 0;
2348 }
2349 
2350 /*
2351  * Internal utility routines.
2352  */
2353 
2354 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,yyconst char * s2,int n)2355 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2356 {
2357 	register int i;
2358 	for ( i = 0; i < n; ++i )
2359 		s1[i] = s2[i];
2360 }
2361 #endif
2362 
2363 #ifdef YY_NEED_STRLEN
yy_flex_strlen(yyconst char * s)2364 static int yy_flex_strlen (yyconst char * s )
2365 {
2366 	register int n;
2367 	for ( n = 0; s[n]; ++n )
2368 		;
2369 
2370 	return n;
2371 }
2372 #endif
2373 
slice_alloc(yy_size_t size)2374 void *slice_alloc (yy_size_t  size )
2375 {
2376 	return (void *) malloc( size );
2377 }
2378 
slice_realloc(void * ptr,yy_size_t size)2379 void *slice_realloc  (void * ptr, yy_size_t  size )
2380 {
2381 	/* The cast to (char *) in the following accommodates both
2382 	 * implementations that use char* generic pointers, and those
2383 	 * that use void* generic pointers.  It works with the latter
2384 	 * because both ANSI C and C++ allow castless assignment from
2385 	 * any pointer type to void*, and deal with argument conversions
2386 	 * as though doing an assignment.
2387 	 */
2388 	return (void *) realloc( (char *) ptr, size );
2389 }
2390 
slice_free(void * ptr)2391 void slice_free (void * ptr )
2392 {
2393 	free( (char *) ptr );	/* see slice_realloc() for (char *) cast */
2394 }
2395 
2396 #define YYTABLES_NAME "yytables"
2397 
2398 #line 527 "src/Slice/Scanner.l"
2399 
2400 
2401 
2402 namespace Slice {
2403 
2404 //
2405 // initScanner() fills the keyword map with all keyword-token pairs.
2406 //
2407 
2408 void
initScanner()2409 initScanner()
2410 {
2411     keywordMap["module"] = ICE_MODULE;
2412     keywordMap["class"] = ICE_CLASS;
2413     keywordMap["interface"] = ICE_INTERFACE;
2414     keywordMap["exception"] = ICE_EXCEPTION;
2415     keywordMap["struct"] = ICE_STRUCT;
2416     keywordMap["sequence"] = ICE_SEQUENCE;
2417     keywordMap["dictionary"] = ICE_DICTIONARY;
2418     keywordMap["enum"] = ICE_ENUM;
2419     keywordMap["out"] = ICE_OUT;
2420     keywordMap["extends"] = ICE_EXTENDS;
2421     keywordMap["implements"] = ICE_IMPLEMENTS;
2422     keywordMap["throws"] = ICE_THROWS;
2423     keywordMap["void"] = ICE_VOID;
2424     keywordMap["byte"] = ICE_BYTE;
2425     keywordMap["bool"] = ICE_BOOL;
2426     keywordMap["short"] = ICE_SHORT;
2427     keywordMap["int"] = ICE_INT;
2428     keywordMap["long"] = ICE_LONG;
2429     keywordMap["float"] = ICE_FLOAT;
2430     keywordMap["double"] = ICE_DOUBLE;
2431     keywordMap["string"] = ICE_STRING;
2432     keywordMap["Object"] = ICE_OBJECT;
2433     keywordMap["LocalObject"] = ICE_LOCAL_OBJECT;
2434     keywordMap["local"] = ICE_LOCAL;
2435     keywordMap["const"] = ICE_CONST;
2436     keywordMap["false"] = ICE_FALSE;
2437     keywordMap["true"] = ICE_TRUE;
2438     keywordMap["idempotent"] = ICE_IDEMPOTENT;
2439     keywordMap["optional"] = ICE_OPTIONAL;
2440     keywordMap["Value"] = ICE_VALUE;
2441 }
2442 
2443 //
2444 // Check if an identifier looks like a keyword.
2445 // If the identifier is a keyword, return the
2446 // corresponding keyword token; otherwise, return
2447 // an identifier token.
2448 //
2449 
2450 int
checkKeyword(string & id)2451 checkKeyword(string& id)
2452 {
2453     StringTokenMap::const_iterator pos = keywordMap.find(id);
2454     if(pos != keywordMap.end())
2455     {
2456         if(pos->first != id)
2457         {
2458             string msg;
2459             msg = "illegal identifier: `" + id + "' differs from keyword `";
2460             msg += pos->first + "' only in capitalization";
2461             unit->error(msg);
2462             id = pos->first;
2463         }
2464         return pos->second;
2465     }
2466     return checkIdentifier(id);
2467 }
2468 
2469 //
2470 // Checks an identifier for any illegal syntax and
2471 // determines whether it's scoped. If it is, this
2472 // returns a scoped identifier token; otherwise this
2473 // returns a normal identifier token.
2474 //
2475 
checkIdentifier(string & id)2476 int checkIdentifier(string& id)
2477 {
2478     // check whether the identifier is scoped
2479     size_t scopeIndex = id.rfind("::");
2480     bool isScoped = scopeIndex != string::npos;
2481     string name;
2482     if(isScoped)
2483     {
2484         name = id.substr(scopeIndex + 2); // Only check the unscoped identifier for syntax
2485     }
2486     else
2487     {
2488         name = id;
2489     }
2490 
2491     // check the identifier for reserved suffixes
2492     static const string suffixBlacklist[] = { "Helper", "Holder", "Prx", "Ptr" };
2493     for(size_t i = 0; i < sizeof(suffixBlacklist) / sizeof(*suffixBlacklist); ++i)
2494     {
2495         if(name.find(suffixBlacklist[i], name.size() - suffixBlacklist[i].size()) != string::npos)
2496         {
2497             unit->error("illegal identifier `" + name + "': `" + suffixBlacklist[i] + "' suffix is reserved");
2498         }
2499     }
2500 
2501     // check the identifier for illegal underscores
2502     size_t index = name.find('_');
2503     if(index == 0)
2504     {
2505         unit->error("illegal leading underscore in identifier `" + name + "'");
2506     }
2507     else if(name.rfind('_') == (name.size() - 1))
2508     {
2509         unit->error("illegal trailing underscore in identifier `" + name + "'");
2510     }
2511     else if(name.find("__") != string::npos)
2512     {
2513         unit->error("illegal double underscore in identifier `" + name + "'");
2514     }
2515     else if(index != string::npos && unit->currentIncludeLevel() == 0 && !unit->allowUnderscore())
2516     {
2517         DefinitionContextPtr dc = unit->currentDefinitionContext();
2518         assert(dc);
2519         if(dc->findMetaData("underscore") != "underscore") // no 'underscore' global metadata
2520         {
2521             unit->error("illegal underscore in identifier `" + name + "'");
2522         }
2523     }
2524 
2525     // Check the identifier for illegal ice prefixes
2526     if(unit->currentIncludeLevel() == 0 && !unit->allowIcePrefix() && name.size() > 2)
2527     {
2528         DefinitionContextPtr dc = unit->currentDefinitionContext();
2529         assert(dc);
2530         if(dc->findMetaData("ice-prefix") != "ice-prefix") // no 'ice-prefix' metadata
2531         {
2532             string prefix3;
2533             prefix3 += ::tolower(static_cast<unsigned char>(name[0]));
2534             prefix3 += ::tolower(static_cast<unsigned char>(name[1]));
2535             prefix3 += ::tolower(static_cast<unsigned char>(name[2]));
2536             if(prefix3 == "ice")
2537             {
2538                 unit->error("illegal identifier `" + name + "': `" + name.substr(0, 3) + "' prefix is reserved");
2539             }
2540         }
2541     }
2542 
2543     return isScoped ? ICE_SCOPED_IDENTIFIER : ICE_IDENTIFIER;
2544 }
2545 
2546 }
2547 
2548