comparison Bison-Flex/BasicCompiler-MemoryBase/UTF8/script-scanner.cc @ 4:805d39d28230

add Compiler-stackbase
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 May 2011 08:00:38 +0900
parents
children
comparison
equal deleted inserted replaced
3:3cea2e8a0e4b 4:805d39d28230
1 #line 2 "script-scanner.cc"
2
3 #line 4 "script-scanner.cc"
4
5 #define YY_INT_ALIGNED short int
6
7 /* A lexical scanner generated by flex */
8
9 #define FLEX_SCANNER
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 5
12 #define YY_FLEX_SUBMINOR_VERSION 33
13 #if YY_FLEX_SUBMINOR_VERSION > 0
14 #define FLEX_BETA
15 #endif
16
17 /* First, we deal with platform-specific or compiler-specific issues. */
18
19 /* begin standard C headers. */
20 #include <stdio.h>
21 #include <string.h>
22 #include <errno.h>
23 #include <stdlib.h>
24
25 /* end standard C headers. */
26
27 /* flex integer type definitions */
28
29 #ifndef FLEXINT_H
30 #define FLEXINT_H
31
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
34 #if __STDC_VERSION__ >= 199901L
35
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
38 */
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
41 #endif
42
43 #include <inttypes.h>
44 typedef int8_t flex_int8_t;
45 typedef uint8_t flex_uint8_t;
46 typedef int16_t flex_int16_t;
47 typedef uint16_t flex_uint16_t;
48 typedef int32_t flex_int32_t;
49 typedef uint32_t flex_uint32_t;
50 #else
51 typedef signed char flex_int8_t;
52 typedef short int flex_int16_t;
53 typedef int flex_int32_t;
54 typedef unsigned char flex_uint8_t;
55 typedef unsigned short int flex_uint16_t;
56 typedef unsigned int flex_uint32_t;
57 #endif /* ! C99 */
58
59 /* Limits of integral types. */
60 #ifndef INT8_MIN
61 #define INT8_MIN (-128)
62 #endif
63 #ifndef INT16_MIN
64 #define INT16_MIN (-32767-1)
65 #endif
66 #ifndef INT32_MIN
67 #define INT32_MIN (-2147483647-1)
68 #endif
69 #ifndef INT8_MAX
70 #define INT8_MAX (127)
71 #endif
72 #ifndef INT16_MAX
73 #define INT16_MAX (32767)
74 #endif
75 #ifndef INT32_MAX
76 #define INT32_MAX (2147483647)
77 #endif
78 #ifndef UINT8_MAX
79 #define UINT8_MAX (255U)
80 #endif
81 #ifndef UINT16_MAX
82 #define UINT16_MAX (65535U)
83 #endif
84 #ifndef UINT32_MAX
85 #define UINT32_MAX (4294967295U)
86 #endif
87
88 #endif /* ! FLEXINT_H */
89
90 #ifdef __cplusplus
91
92 /* The "const" storage-class-modifier is valid. */
93 #define YY_USE_CONST
94
95 #else /* ! __cplusplus */
96
97 #if __STDC__
98
99 #define YY_USE_CONST
100
101 #endif /* __STDC__ */
102 #endif /* ! __cplusplus */
103
104 #ifdef YY_USE_CONST
105 #define yyconst const
106 #else
107 #define yyconst
108 #endif
109
110 /* Returned upon end-of-file. */
111 #define YY_NULL 0
112
113 /* Promotes a possibly negative, possibly signed char to an unsigned
114 * integer for use as an array index. If the signed char is negative,
115 * we want to instead treat it as an 8-bit unsigned char, hence the
116 * double cast.
117 */
118 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
119
120 /* Enter a start condition. This macro really ought to take a parameter,
121 * but we do it the disgusting crufty way forced on us by the ()-less
122 * definition of BEGIN.
123 */
124 #define BEGIN (yy_start) = 1 + 2 *
125
126 /* Translate the current start state into a value that can be later handed
127 * to BEGIN to return to the state. The YYSTATE alias is for lex
128 * compatibility.
129 */
130 #define YY_START (((yy_start) - 1) / 2)
131 #define YYSTATE YY_START
132
133 /* Action number for EOF rule of a given start state. */
134 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
135
136 /* Special action meaning "start processing a new file". */
137 #define YY_NEW_FILE yyrestart(yyin )
138
139 #define YY_END_OF_BUFFER_CHAR 0
140
141 /* Size of default input buffer. */
142 #ifndef YY_BUF_SIZE
143 #define YY_BUF_SIZE 16384
144 #endif
145
146 /* The state buf must be large enough to hold one state per character in the main buffer.
147 */
148 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
149
150 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
151 #define YY_TYPEDEF_YY_BUFFER_STATE
152 typedef struct yy_buffer_state *YY_BUFFER_STATE;
153 #endif
154
155 extern int yyleng;
156
157 extern FILE *yyin, *yyout;
158
159 #define EOB_ACT_CONTINUE_SCAN 0
160 #define EOB_ACT_END_OF_FILE 1
161 #define EOB_ACT_LAST_MATCH 2
162
163 #define YY_LESS_LINENO(n)
164
165 /* Return all but the first "n" matched characters back to the input stream. */
166 #define yyless(n) \
167 do \
168 { \
169 /* Undo effects of setting up yytext. */ \
170 int yyless_macro_arg = (n); \
171 YY_LESS_LINENO(yyless_macro_arg);\
172 *yy_cp = (yy_hold_char); \
173 YY_RESTORE_YY_MORE_OFFSET \
174 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
175 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
176 } \
177 while ( 0 )
178
179 #define unput(c) yyunput( c, (yytext_ptr) )
180
181 /* The following is because we cannot portably get our hands on size_t
182 * (without autoconf's help, which isn't available because we want
183 * flex-generated scanners to compile on their own).
184 */
185
186 #ifndef YY_TYPEDEF_YY_SIZE_T
187 #define YY_TYPEDEF_YY_SIZE_T
188 typedef unsigned int yy_size_t;
189 #endif
190
191 #ifndef YY_STRUCT_YY_BUFFER_STATE
192 #define YY_STRUCT_YY_BUFFER_STATE
193 struct yy_buffer_state
194 {
195 FILE *yy_input_file;
196
197 char *yy_ch_buf; /* input buffer */
198 char *yy_buf_pos; /* current position in input buffer */
199
200 /* Size of input buffer in bytes, not including room for EOB
201 * characters.
202 */
203 yy_size_t yy_buf_size;
204
205 /* Number of characters read into yy_ch_buf, not including EOB
206 * characters.
207 */
208 int yy_n_chars;
209
210 /* Whether we "own" the buffer - i.e., we know we created it,
211 * and can realloc() it to grow it, and should free() it to
212 * delete it.
213 */
214 int yy_is_our_buffer;
215
216 /* Whether this is an "interactive" input source; if so, and
217 * if we're using stdio for input, then we want to use getc()
218 * instead of fread(), to make sure we stop fetching input after
219 * each newline.
220 */
221 int yy_is_interactive;
222
223 /* Whether we're considered to be at the beginning of a line.
224 * If so, '^' rules will be active on the next match, otherwise
225 * not.
226 */
227 int yy_at_bol;
228
229 int yy_bs_lineno; /**< The line count. */
230 int yy_bs_column; /**< The column count. */
231
232 /* Whether to try to fill the input buffer when we reach the
233 * end of it.
234 */
235 int yy_fill_buffer;
236
237 int yy_buffer_status;
238
239 #define YY_BUFFER_NEW 0
240 #define YY_BUFFER_NORMAL 1
241 /* When an EOF's been seen but there's still some text to process
242 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
243 * shouldn't try reading from the input source any more. We might
244 * still have a bunch of tokens to match, though, because of
245 * possible backing-up.
246 *
247 * When we actually see the EOF, we change the status to "new"
248 * (via yyrestart()), so that the user can continue scanning by
249 * just pointing yyin at a new input file.
250 */
251 #define YY_BUFFER_EOF_PENDING 2
252
253 };
254 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
255
256 /* Stack of input buffers. */
257 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
258 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
259 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
260
261 /* We provide macros for accessing buffer states in case in the
262 * future we want to put the buffer states in a more general
263 * "scanner state".
264 *
265 * Returns the top of the stack, or NULL.
266 */
267 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
268 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
269 : NULL)
270
271 /* Same as previous macro, but useful when we know that the buffer stack is not
272 * NULL or when we need an lvalue. For internal use only.
273 */
274 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
275
276 /* yy_hold_char holds the character lost when yytext is formed. */
277 static char yy_hold_char;
278 static int yy_n_chars; /* number of characters read into yy_ch_buf */
279 int yyleng;
280
281 /* Points to current character in buffer. */
282 static char *yy_c_buf_p = (char *) 0;
283 static int yy_init = 0; /* whether we need to initialize */
284 static int yy_start = 0; /* start state number */
285
286 /* Flag which is used to allow yywrap()'s to do buffer switches
287 * instead of setting up a fresh yyin. A bit of a hack ...
288 */
289 static int yy_did_buffer_switch_on_eof;
290
291 void yyrestart (FILE *input_file );
292 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
293 YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
294 void yy_delete_buffer (YY_BUFFER_STATE b );
295 void yy_flush_buffer (YY_BUFFER_STATE b );
296 void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
297 void yypop_buffer_state (void );
298
299 static void yyensure_buffer_stack (void );
300 static void yy_load_buffer_state (void );
301 static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
302
303 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
304
305 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
306 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
307 YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
308
309 void *yyalloc (yy_size_t );
310 void *yyrealloc (void *,yy_size_t );
311 void yyfree (void * );
312
313 #define yy_new_buffer yy_create_buffer
314
315 #define yy_set_interactive(is_interactive) \
316 { \
317 if ( ! YY_CURRENT_BUFFER ){ \
318 yyensure_buffer_stack (); \
319 YY_CURRENT_BUFFER_LVALUE = \
320 yy_create_buffer(yyin,YY_BUF_SIZE ); \
321 } \
322 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
323 }
324
325 #define yy_set_bol(at_bol) \
326 { \
327 if ( ! YY_CURRENT_BUFFER ){\
328 yyensure_buffer_stack (); \
329 YY_CURRENT_BUFFER_LVALUE = \
330 yy_create_buffer(yyin,YY_BUF_SIZE ); \
331 } \
332 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
333 }
334
335 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
336
337 /* Begin user sect3 */
338
339 #define yywrap() 1
340 #define YY_SKIP_YYWRAP
341
342 typedef unsigned char YY_CHAR;
343
344 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
345
346 typedef int yy_state_type;
347
348 extern int yylineno;
349
350 int yylineno = 1;
351
352 extern char *yytext;
353 #define yytext_ptr yytext
354
355 static yy_state_type yy_get_previous_state (void );
356 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
357 static int yy_get_next_buffer (void );
358 static void yy_fatal_error (yyconst char msg[] );
359
360 /* Done after the current pattern has been matched and before the
361 * corresponding action - sets up yytext.
362 */
363 #define YY_DO_BEFORE_ACTION \
364 (yytext_ptr) = yy_bp; \
365 yyleng = (size_t) (yy_cp - yy_bp); \
366 (yy_hold_char) = *yy_cp; \
367 *yy_cp = '\0'; \
368 (yy_c_buf_p) = yy_cp;
369
370 #define YY_NUM_RULES 31
371 #define YY_END_OF_BUFFER 32
372 /* This struct is not used in this scanner,
373 but its presence is necessary. */
374 struct yy_trans_info
375 {
376 flex_int32_t yy_verify;
377 flex_int32_t yy_nxt;
378 };
379 static yyconst flex_int16_t yy_accept[75] =
380 { 0,
381 0, 0, 29, 29, 32, 28, 24, 18, 28, 19,
382 2, 26, 25, 17, 19, 19, 19, 27, 28, 28,
383 27, 27, 27, 27, 27, 27, 27, 27, 29, 30,
384 24, 21, 25, 23, 20, 22, 27, 16, 1, 27,
385 27, 27, 4, 27, 27, 27, 27, 27, 9, 27,
386 27, 29, 27, 13, 8, 27, 27, 27, 3, 27,
387 27, 27, 6, 27, 10, 27, 14, 5, 12, 27,
388 7, 15, 11, 0
389 } ;
390
391 static yyconst flex_int32_t yy_ec[256] =
392 { 0,
393 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
396 1, 2, 4, 1, 5, 1, 6, 1, 7, 6,
397 6, 6, 6, 6, 6, 1, 6, 8, 9, 9,
398 9, 9, 9, 9, 9, 9, 9, 10, 1, 11,
399 12, 13, 1, 1, 14, 14, 14, 14, 14, 14,
400 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
401 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
402 1, 15, 1, 16, 14, 1, 17, 14, 14, 18,
403
404 19, 20, 14, 21, 22, 14, 14, 23, 24, 25,
405 26, 27, 14, 28, 29, 30, 14, 14, 31, 32,
406 14, 14, 1, 1, 1, 1, 1, 1, 1, 1,
407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
420 1, 1, 1, 1, 1
421 } ;
422
423 static yyconst flex_int32_t yy_meta[33] =
424 { 0,
425 1, 1, 2, 1, 1, 1, 1, 3, 3, 1,
426 1, 1, 1, 3, 1, 1, 3, 3, 3, 3,
427 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
428 3, 3
429 } ;
430
431 static yyconst flex_int16_t yy_base[78] =
432 { 0,
433 0, 0, 83, 82, 84, 87, 81, 87, 70, 87,
434 87, 87, 25, 87, 69, 68, 67, 0, 75, 72,
435 12, 50, 55, 55, 45, 19, 18, 21, 0, 87,
436 70, 87, 37, 87, 87, 87, 0, 87, 87, 42,
437 52, 41, 0, 36, 45, 41, 41, 45, 0, 38,
438 40, 0, 42, 38, 0, 29, 33, 39, 0, 31,
439 37, 31, 0, 33, 0, 21, 0, 0, 0, 24,
440 0, 0, 0, 87, 46, 38, 49
441 } ;
442
443 static yyconst flex_int16_t yy_def[78] =
444 { 0,
445 74, 1, 75, 75, 74, 74, 74, 74, 74, 74,
446 74, 74, 74, 74, 74, 74, 74, 76, 74, 74,
447 76, 76, 76, 76, 76, 76, 76, 76, 77, 74,
448 74, 74, 74, 74, 74, 74, 76, 74, 74, 76,
449 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
450 76, 77, 76, 76, 76, 76, 76, 76, 76, 76,
451 76, 76, 76, 76, 76, 76, 76, 76, 76, 76,
452 76, 76, 76, 0, 74, 74, 74
453 } ;
454
455 static yyconst flex_int16_t yy_nxt[120] =
456 { 0,
457 6, 7, 8, 9, 6, 10, 11, 12, 13, 14,
458 15, 16, 17, 18, 19, 20, 18, 18, 21, 22,
459 18, 23, 18, 18, 24, 18, 25, 26, 18, 27,
460 28, 18, 33, 33, 40, 46, 41, 47, 48, 50,
461 37, 51, 73, 49, 33, 33, 29, 29, 29, 52,
462 72, 52, 71, 70, 69, 68, 67, 66, 65, 64,
463 63, 62, 61, 60, 59, 58, 57, 56, 55, 54,
464 53, 31, 45, 44, 43, 42, 39, 38, 36, 35,
465 34, 32, 31, 74, 30, 30, 5, 74, 74, 74,
466 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
467
468 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
469 74, 74, 74, 74, 74, 74, 74, 74, 74
470 } ;
471
472 static yyconst flex_int16_t yy_chk[120] =
473 { 0,
474 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
475 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
476 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
477 1, 1, 13, 13, 21, 26, 21, 26, 27, 28,
478 76, 28, 70, 27, 33, 33, 75, 75, 75, 77,
479 66, 77, 64, 62, 61, 60, 58, 57, 56, 54,
480 53, 51, 50, 48, 47, 46, 45, 44, 42, 41,
481 40, 31, 25, 24, 23, 22, 20, 19, 17, 16,
482 15, 9, 7, 5, 4, 3, 74, 74, 74, 74,
483 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
484
485 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
486 74, 74, 74, 74, 74, 74, 74, 74, 74
487 } ;
488
489 static yy_state_type yy_last_accepting_state;
490 static char *yy_last_accepting_cpos;
491
492 extern int yy_flex_debug;
493 int yy_flex_debug = 0;
494
495 /* The intent behind this definition is that it'll catch
496 * any uses of REJECT which flex missed.
497 */
498 #define REJECT reject_used_but_not_detected
499 #define yymore() yymore_used_but_not_detected
500 #define YY_MORE_ADJ 0
501 #define YY_RESTORE_YY_MORE_OFFSET
502 char *yytext;
503 #line 1 "script-scanner.ll"
504 #line 2 "script-scanner.ll"
505 #include <cstdlib>
506 #include <errno.h>
507 #include <limits.h>
508 #include <string>
509 #include "compiler.h"
510 #include "script-parser.hh"
511
512 #ifdef _MSC_VER
513 #pragma warning(disable:4018)
514 #pragma warning(disable:4102)
515 #pragma warning(disable:4244)
516 #pragma warning(disable:4267)
517 #pragma warning(disable:4996)
518 #endif
519
520 #undef yywrap
521 #define yywrap() 1
522
523 #define yyterminate() return token::END_OF_FILE
524 #define YY_NO_UNISTD_H 1
525
526 #line 38 "script-scanner.ll"
527 #define YY_USER_ACTION yylloc->columns(yyleng);
528 #line 529 "script-scanner.cc"
529
530 #define INITIAL 0
531 #define COMMENT 1
532
533 #ifndef YY_NO_UNISTD_H
534 /* Special case for "unistd.h", since it is non-ANSI. We include it way
535 * down here because we want the user's section 1 to have been scanned first.
536 * The user has a chance to override it with an option.
537 */
538 #include <unistd.h>
539 #endif
540
541 #ifndef YY_EXTRA_TYPE
542 #define YY_EXTRA_TYPE void *
543 #endif
544
545 static int yy_init_globals (void );
546
547 /* Macros after this point can all be overridden by user definitions in
548 * section 1.
549 */
550
551 #ifndef YY_SKIP_YYWRAP
552 #ifdef __cplusplus
553 extern "C" int yywrap (void );
554 #else
555 extern int yywrap (void );
556 #endif
557 #endif
558
559 #ifndef yytext_ptr
560 static void yy_flex_strncpy (char *,yyconst char *,int );
561 #endif
562
563 #ifdef YY_NEED_STRLEN
564 static int yy_flex_strlen (yyconst char * );
565 #endif
566
567 #ifndef YY_NO_INPUT
568
569 #ifdef __cplusplus
570 static int yyinput (void );
571 #else
572 static int input (void );
573 #endif
574
575 #endif
576
577 /* Amount of stuff to slurp up with each read. */
578 #ifndef YY_READ_BUF_SIZE
579 #define YY_READ_BUF_SIZE 8192
580 #endif
581
582 /* Copy whatever the last rule matched to the standard output. */
583 #ifndef ECHO
584 /* This used to be an fputs(), but since the string might contain NUL's,
585 * we now use fwrite().
586 */
587 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
588 #endif
589
590 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
591 * is returned in "result".
592 */
593 #ifndef YY_INPUT
594 #define YY_INPUT(buf,result,max_size) \
595 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
596 { \
597 int c = '*'; \
598 size_t n; \
599 for ( n = 0; n < max_size && \
600 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
601 buf[n] = (char) c; \
602 if ( c == '\n' ) \
603 buf[n++] = (char) c; \
604 if ( c == EOF && ferror( yyin ) ) \
605 YY_FATAL_ERROR( "input in flex scanner failed" ); \
606 result = n; \
607 } \
608 else \
609 { \
610 errno=0; \
611 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
612 { \
613 if( errno != EINTR) \
614 { \
615 YY_FATAL_ERROR( "input in flex scanner failed" ); \
616 break; \
617 } \
618 errno=0; \
619 clearerr(yyin); \
620 } \
621 }\
622 \
623
624 #endif
625
626 /* No semi-colon after return; correct usage is to write "yyterminate();" -
627 * we don't want an extra ';' after the "return" because that will cause
628 * some compilers to complain about unreachable statements.
629 */
630 #ifndef yyterminate
631 #define yyterminate() return YY_NULL
632 #endif
633
634 /* Number of entries by which start-condition stack grows. */
635 #ifndef YY_START_STACK_INCR
636 #define YY_START_STACK_INCR 25
637 #endif
638
639 /* Report a fatal error. */
640 #ifndef YY_FATAL_ERROR
641 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
642 #endif
643
644 /* end tables serialization structures and prototypes */
645
646 /* Default declaration of generated scanner - a define so the user can
647 * easily add parameters.
648 */
649 #ifndef YY_DECL
650 #define YY_DECL_IS_OURS 1
651
652 extern int yylex (void);
653
654 #define YY_DECL int yylex (void)
655 #endif /* !YY_DECL */
656
657 /* Code executed at the beginning of each rule, after yytext and yyleng
658 * have been set up.
659 */
660 #ifndef YY_USER_ACTION
661 #define YY_USER_ACTION
662 #endif
663
664 /* Code executed at the end of each rule. */
665 #ifndef YY_BREAK
666 #define YY_BREAK break;
667 #endif
668
669 #define YY_RULE_SETUP \
670 YY_USER_ACTION
671
672 /** The main scanner function which does all the work.
673 */
674 YY_DECL
675 {
676 register yy_state_type yy_current_state;
677 register char *yy_cp, *yy_bp;
678 register int yy_act;
679
680 #line 40 "script-scanner.ll"
681
682
683 typedef yy::script_parser::token token;
684
685 yylloc->step();
686
687 std::string string_buffer;
688
689 #line 690 "script-scanner.cc"
690
691 if ( !(yy_init) )
692 {
693 (yy_init) = 1;
694
695 #ifdef YY_USER_INIT
696 YY_USER_INIT;
697 #endif
698
699 if ( ! (yy_start) )
700 (yy_start) = 1; /* first start state */
701
702 if ( ! yyin )
703 yyin = stdin;
704
705 if ( ! yyout )
706 yyout = stdout;
707
708 if ( ! YY_CURRENT_BUFFER ) {
709 yyensure_buffer_stack ();
710 YY_CURRENT_BUFFER_LVALUE =
711 yy_create_buffer(yyin,YY_BUF_SIZE );
712 }
713
714 yy_load_buffer_state( );
715 }
716
717 while ( 1 ) /* loops until end-of-file is reached */
718 {
719 yy_cp = (yy_c_buf_p);
720
721 /* Support of yytext. */
722 *yy_cp = (yy_hold_char);
723
724 /* yy_bp points to the position in yy_ch_buf of the start of
725 * the current run.
726 */
727 yy_bp = yy_cp;
728
729 yy_current_state = (yy_start);
730 yy_match:
731 do
732 {
733 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
734 if ( yy_accept[yy_current_state] )
735 {
736 (yy_last_accepting_state) = yy_current_state;
737 (yy_last_accepting_cpos) = yy_cp;
738 }
739 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
740 {
741 yy_current_state = (int) yy_def[yy_current_state];
742 if ( yy_current_state >= 75 )
743 yy_c = yy_meta[(unsigned int) yy_c];
744 }
745 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
746 ++yy_cp;
747 }
748 while ( yy_current_state != 74 );
749 yy_cp = (yy_last_accepting_cpos);
750 yy_current_state = (yy_last_accepting_state);
751
752 yy_find_action:
753 yy_act = yy_accept[yy_current_state];
754
755 YY_DO_BEFORE_ACTION;
756
757 do_action: /* This label is used only to access EOF actions. */
758
759 switch ( yy_act )
760 { /* beginning of action switch */
761 case 0: /* must back up */
762 /* undo the effects of YY_DO_BEFORE_ACTION */
763 *yy_cp = (yy_hold_char);
764 yy_cp = (yy_last_accepting_cpos);
765 yy_current_state = (yy_last_accepting_state);
766 goto yy_find_action;
767
768 case 1:
769 YY_RULE_SETUP
770 #line 49 "script-scanner.ll"
771 { yylloc->step(); BEGIN(COMMENT); }
772 YY_BREAK
773 case 2:
774 YY_RULE_SETUP
775 #line 50 "script-scanner.ll"
776 { yylloc->step(); BEGIN(COMMENT); }
777 YY_BREAK
778 case 3:
779 YY_RULE_SETUP
780 #line 51 "script-scanner.ll"
781 { yylloc->step(); BEGIN(COMMENT); }
782 YY_BREAK
783 case 4:
784 YY_RULE_SETUP
785 #line 53 "script-scanner.ll"
786 return token::TK_IF;
787 YY_BREAK
788 case 5:
789 YY_RULE_SETUP
790 #line 54 "script-scanner.ll"
791 return token::TK_THEN;
792 YY_BREAK
793 case 6:
794 YY_RULE_SETUP
795 #line 55 "script-scanner.ll"
796 return token::TK_ELSE;
797 YY_BREAK
798 case 7:
799 YY_RULE_SETUP
800 #line 56 "script-scanner.ll"
801 return token::TK_ENDIF;
802 YY_BREAK
803 case 8:
804 YY_RULE_SETUP
805 #line 57 "script-scanner.ll"
806 return token::TK_FOR;
807 YY_BREAK
808 case 9:
809 YY_RULE_SETUP
810 #line 58 "script-scanner.ll"
811 return token::TK_TO;
812 YY_BREAK
813 case 10:
814 YY_RULE_SETUP
815 #line 59 "script-scanner.ll"
816 return token::TK_NEXT;
817 YY_BREAK
818 case 11:
819 YY_RULE_SETUP
820 #line 60 "script-scanner.ll"
821 return token::TK_WHILE;
822 YY_BREAK
823 case 12:
824 YY_RULE_SETUP
825 #line 61 "script-scanner.ll"
826 return token::TK_WEND;
827 YY_BREAK
828 case 13:
829 YY_RULE_SETUP
830 #line 62 "script-scanner.ll"
831 return token::TK_END;
832 YY_BREAK
833 case 14:
834 YY_RULE_SETUP
835 #line 63 "script-scanner.ll"
836 return token::TK_RAND;
837 YY_BREAK
838 case 15:
839 YY_RULE_SETUP
840 #line 64 "script-scanner.ll"
841 return token::TK_PRINT;
842 YY_BREAK
843 case 16:
844 /* rule 16 can match eol */
845 YY_RULE_SETUP
846 #line 66 "script-scanner.ll"
847 yylloc->lines();
848 YY_BREAK
849 case 17:
850 YY_RULE_SETUP
851 #line 68 "script-scanner.ll"
852 return token::TK_NEWLINE;
853 YY_BREAK
854 case 18:
855 /* rule 18 can match eol */
856 YY_RULE_SETUP
857 #line 69 "script-scanner.ll"
858 { yylloc->lines(); return token::TK_NEWLINE; }
859 YY_BREAK
860 case 19:
861 YY_RULE_SETUP
862 #line 70 "script-scanner.ll"
863 return yy::script_parser::token_type(yytext[0]);
864 YY_BREAK
865 case 20:
866 YY_RULE_SETUP
867 #line 72 "script-scanner.ll"
868 return token::TK_EQ;
869 YY_BREAK
870 case 21:
871 YY_RULE_SETUP
872 #line 73 "script-scanner.ll"
873 return token::TK_NE;
874 YY_BREAK
875 case 22:
876 YY_RULE_SETUP
877 #line 74 "script-scanner.ll"
878 return token::TK_GE;
879 YY_BREAK
880 case 23:
881 YY_RULE_SETUP
882 #line 75 "script-scanner.ll"
883 return token::TK_LE;
884 YY_BREAK
885 case 24:
886 YY_RULE_SETUP
887 #line 77 "script-scanner.ll"
888 yylloc->step();
889 YY_BREAK
890 case 25:
891 YY_RULE_SETUP
892 #line 78 "script-scanner.ll"
893 {
894 errno = 0;
895 long n = strtol(yytext, NULL, 10);
896 if (n < LONG_MIN || n > LONG_MAX || errno == ERANGE)
897 driver.error(*yylloc, "整数が範囲外です。");
898 yylval->ival = n;
899 return token::TK_IVAL;
900 }
901 YY_BREAK
902 case 26:
903 YY_RULE_SETUP
904 #line 86 "script-scanner.ll"
905 {
906 yylval->ival = 0;
907 return token::TK_IVAL;
908 }
909 YY_BREAK
910 case 27:
911 YY_RULE_SETUP
912 #line 90 "script-scanner.ll"
913 {
914 yylval->sval = new std::string(yytext);
915 return token::TK_IDENTIFIER;
916 }
917 YY_BREAK
918 case 28:
919 YY_RULE_SETUP
920 #line 94 "script-scanner.ll"
921 driver.error(*yylloc, "この文字を識別子で使用することはできません。");
922 YY_BREAK
923
924
925 case 29:
926 YY_RULE_SETUP
927 #line 97 "script-scanner.ll"
928
929 YY_BREAK
930 case 30:
931 /* rule 30 can match eol */
932 YY_RULE_SETUP
933 #line 98 "script-scanner.ll"
934 {
935 yylloc->lines();
936 yylloc->step();
937 BEGIN(INITIAL);
938 }
939 YY_BREAK
940
941 case 31:
942 YY_RULE_SETUP
943 #line 104 "script-scanner.ll"
944 ECHO;
945 YY_BREAK
946 #line 947 "script-scanner.cc"
947 case YY_STATE_EOF(INITIAL):
948 case YY_STATE_EOF(COMMENT):
949 yyterminate();
950
951 case YY_END_OF_BUFFER:
952 {
953 /* Amount of text matched not including the EOB char. */
954 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
955
956 /* Undo the effects of YY_DO_BEFORE_ACTION. */
957 *yy_cp = (yy_hold_char);
958 YY_RESTORE_YY_MORE_OFFSET
959
960 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
961 {
962 /* We're scanning a new file or input source. It's
963 * possible that this happened because the user
964 * just pointed yyin at a new source and called
965 * yylex(). If so, then we have to assure
966 * consistency between YY_CURRENT_BUFFER and our
967 * globals. Here is the right place to do so, because
968 * this is the first action (other than possibly a
969 * back-up) that will match for the new input source.
970 */
971 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
972 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
973 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
974 }
975
976 /* Note that here we test for yy_c_buf_p "<=" to the position
977 * of the first EOB in the buffer, since yy_c_buf_p will
978 * already have been incremented past the NUL character
979 * (since all states make transitions on EOB to the
980 * end-of-buffer state). Contrast this with the test
981 * in input().
982 */
983 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
984 { /* This was really a NUL. */
985 yy_state_type yy_next_state;
986
987 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
988
989 yy_current_state = yy_get_previous_state( );
990
991 /* Okay, we're now positioned to make the NUL
992 * transition. We couldn't have
993 * yy_get_previous_state() go ahead and do it
994 * for us because it doesn't know how to deal
995 * with the possibility of jamming (and we don't
996 * want to build jamming into it because then it
997 * will run more slowly).
998 */
999
1000 yy_next_state = yy_try_NUL_trans( yy_current_state );
1001
1002 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1003
1004 if ( yy_next_state )
1005 {
1006 /* Consume the NUL. */
1007 yy_cp = ++(yy_c_buf_p);
1008 yy_current_state = yy_next_state;
1009 goto yy_match;
1010 }
1011
1012 else
1013 {
1014 yy_cp = (yy_last_accepting_cpos);
1015 yy_current_state = (yy_last_accepting_state);
1016 goto yy_find_action;
1017 }
1018 }
1019
1020 else switch ( yy_get_next_buffer( ) )
1021 {
1022 case EOB_ACT_END_OF_FILE:
1023 {
1024 (yy_did_buffer_switch_on_eof) = 0;
1025
1026 if ( yywrap( ) )
1027 {
1028 /* Note: because we've taken care in
1029 * yy_get_next_buffer() to have set up
1030 * yytext, we can now set up
1031 * yy_c_buf_p so that if some total
1032 * hoser (like flex itself) wants to
1033 * call the scanner after we return the
1034 * YY_NULL, it'll still work - another
1035 * YY_NULL will get returned.
1036 */
1037 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1038
1039 yy_act = YY_STATE_EOF(YY_START);
1040 goto do_action;
1041 }
1042
1043 else
1044 {
1045 if ( ! (yy_did_buffer_switch_on_eof) )
1046 YY_NEW_FILE;
1047 }
1048 break;
1049 }
1050
1051 case EOB_ACT_CONTINUE_SCAN:
1052 (yy_c_buf_p) =
1053 (yytext_ptr) + yy_amount_of_matched_text;
1054
1055 yy_current_state = yy_get_previous_state( );
1056
1057 yy_cp = (yy_c_buf_p);
1058 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1059 goto yy_match;
1060
1061 case EOB_ACT_LAST_MATCH:
1062 (yy_c_buf_p) =
1063 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1064
1065 yy_current_state = yy_get_previous_state( );
1066
1067 yy_cp = (yy_c_buf_p);
1068 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1069 goto yy_find_action;
1070 }
1071 break;
1072 }
1073
1074 default:
1075 YY_FATAL_ERROR(
1076 "fatal flex scanner internal error--no action found" );
1077 } /* end of action switch */
1078 } /* end of scanning one token */
1079 } /* end of yylex */
1080
1081 /* yy_get_next_buffer - try to read in a new buffer
1082 *
1083 * Returns a code representing an action:
1084 * EOB_ACT_LAST_MATCH -
1085 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1086 * EOB_ACT_END_OF_FILE - end of file
1087 */
1088 static int yy_get_next_buffer (void)
1089 {
1090 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1091 register char *source = (yytext_ptr);
1092 register int number_to_move, i;
1093 int ret_val;
1094
1095 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1096 YY_FATAL_ERROR(
1097 "fatal flex scanner internal error--end of buffer missed" );
1098
1099 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1100 { /* Don't try to fill the buffer, so this is an EOF. */
1101 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1102 {
1103 /* We matched a single character, the EOB, so
1104 * treat this as a final EOF.
1105 */
1106 return EOB_ACT_END_OF_FILE;
1107 }
1108
1109 else
1110 {
1111 /* We matched some text prior to the EOB, first
1112 * process it.
1113 */
1114 return EOB_ACT_LAST_MATCH;
1115 }
1116 }
1117
1118 /* Try to read more data. */
1119
1120 /* First move last chars to start of buffer. */
1121 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1122
1123 for ( i = 0; i < number_to_move; ++i )
1124 *(dest++) = *(source++);
1125
1126 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1127 /* don't do the read, it's not guaranteed to return an EOF,
1128 * just force an EOF
1129 */
1130 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1131
1132 else
1133 {
1134 int num_to_read =
1135 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1136
1137 while ( num_to_read <= 0 )
1138 { /* Not enough room in the buffer - grow it. */
1139
1140 /* just a shorter name for the current buffer */
1141 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1142
1143 int yy_c_buf_p_offset =
1144 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1145
1146 if ( b->yy_is_our_buffer )
1147 {
1148 int new_size = b->yy_buf_size * 2;
1149
1150 if ( new_size <= 0 )
1151 b->yy_buf_size += b->yy_buf_size / 8;
1152 else
1153 b->yy_buf_size *= 2;
1154
1155 b->yy_ch_buf = (char *)
1156 /* Include room in for 2 EOB chars. */
1157 yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1158 }
1159 else
1160 /* Can't grow it, we don't own it. */
1161 b->yy_ch_buf = 0;
1162
1163 if ( ! b->yy_ch_buf )
1164 YY_FATAL_ERROR(
1165 "fatal error - scanner input buffer overflow" );
1166
1167 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1168
1169 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1170 number_to_move - 1;
1171
1172 }
1173
1174 if ( num_to_read > YY_READ_BUF_SIZE )
1175 num_to_read = YY_READ_BUF_SIZE;
1176
1177 /* Read in more data. */
1178 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1179 (yy_n_chars), (size_t) num_to_read );
1180
1181 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1182 }
1183
1184 if ( (yy_n_chars) == 0 )
1185 {
1186 if ( number_to_move == YY_MORE_ADJ )
1187 {
1188 ret_val = EOB_ACT_END_OF_FILE;
1189 yyrestart(yyin );
1190 }
1191
1192 else
1193 {
1194 ret_val = EOB_ACT_LAST_MATCH;
1195 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1196 YY_BUFFER_EOF_PENDING;
1197 }
1198 }
1199
1200 else
1201 ret_val = EOB_ACT_CONTINUE_SCAN;
1202
1203 (yy_n_chars) += number_to_move;
1204 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1205 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1206
1207 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1208
1209 return ret_val;
1210 }
1211
1212 /* yy_get_previous_state - get the state just before the EOB char was reached */
1213
1214 static yy_state_type yy_get_previous_state (void)
1215 {
1216 register yy_state_type yy_current_state;
1217 register char *yy_cp;
1218
1219 yy_current_state = (yy_start);
1220
1221 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1222 {
1223 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1224 if ( yy_accept[yy_current_state] )
1225 {
1226 (yy_last_accepting_state) = yy_current_state;
1227 (yy_last_accepting_cpos) = yy_cp;
1228 }
1229 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1230 {
1231 yy_current_state = (int) yy_def[yy_current_state];
1232 if ( yy_current_state >= 75 )
1233 yy_c = yy_meta[(unsigned int) yy_c];
1234 }
1235 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1236 }
1237
1238 return yy_current_state;
1239 }
1240
1241 /* yy_try_NUL_trans - try to make a transition on the NUL character
1242 *
1243 * synopsis
1244 * next_state = yy_try_NUL_trans( current_state );
1245 */
1246 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1247 {
1248 register int yy_is_jam;
1249 register char *yy_cp = (yy_c_buf_p);
1250
1251 register YY_CHAR yy_c = 1;
1252 if ( yy_accept[yy_current_state] )
1253 {
1254 (yy_last_accepting_state) = yy_current_state;
1255 (yy_last_accepting_cpos) = yy_cp;
1256 }
1257 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1258 {
1259 yy_current_state = (int) yy_def[yy_current_state];
1260 if ( yy_current_state >= 75 )
1261 yy_c = yy_meta[(unsigned int) yy_c];
1262 }
1263 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1264 yy_is_jam = (yy_current_state == 74);
1265
1266 return yy_is_jam ? 0 : yy_current_state;
1267 }
1268
1269 #ifndef YY_NO_INPUT
1270 #ifdef __cplusplus
1271 static int yyinput (void)
1272 #else
1273 static int input (void)
1274 #endif
1275
1276 {
1277 int c;
1278
1279 *(yy_c_buf_p) = (yy_hold_char);
1280
1281 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1282 {
1283 /* yy_c_buf_p now points to the character we want to return.
1284 * If this occurs *before* the EOB characters, then it's a
1285 * valid NUL; if not, then we've hit the end of the buffer.
1286 */
1287 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1288 /* This was really a NUL. */
1289 *(yy_c_buf_p) = '\0';
1290
1291 else
1292 { /* need more input */
1293 int offset = (yy_c_buf_p) - (yytext_ptr);
1294 ++(yy_c_buf_p);
1295
1296 switch ( yy_get_next_buffer( ) )
1297 {
1298 case EOB_ACT_LAST_MATCH:
1299 /* This happens because yy_g_n_b()
1300 * sees that we've accumulated a
1301 * token and flags that we need to
1302 * try matching the token before
1303 * proceeding. But for input(),
1304 * there's no matching to consider.
1305 * So convert the EOB_ACT_LAST_MATCH
1306 * to EOB_ACT_END_OF_FILE.
1307 */
1308
1309 /* Reset buffer status. */
1310 yyrestart(yyin );
1311
1312 /*FALLTHROUGH*/
1313
1314 case EOB_ACT_END_OF_FILE:
1315 {
1316 if ( yywrap( ) )
1317 return EOF;
1318
1319 if ( ! (yy_did_buffer_switch_on_eof) )
1320 YY_NEW_FILE;
1321 #ifdef __cplusplus
1322 return yyinput();
1323 #else
1324 return input();
1325 #endif
1326 }
1327
1328 case EOB_ACT_CONTINUE_SCAN:
1329 (yy_c_buf_p) = (yytext_ptr) + offset;
1330 break;
1331 }
1332 }
1333 }
1334
1335 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1336 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1337 (yy_hold_char) = *++(yy_c_buf_p);
1338
1339 return c;
1340 }
1341 #endif /* ifndef YY_NO_INPUT */
1342
1343 /** Immediately switch to a different input stream.
1344 * @param input_file A readable stream.
1345 *
1346 * @note This function does not reset the start condition to @c INITIAL .
1347 */
1348 void yyrestart (FILE * input_file )
1349 {
1350
1351 if ( ! YY_CURRENT_BUFFER ){
1352 yyensure_buffer_stack ();
1353 YY_CURRENT_BUFFER_LVALUE =
1354 yy_create_buffer(yyin,YY_BUF_SIZE );
1355 }
1356
1357 yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1358 yy_load_buffer_state( );
1359 }
1360
1361 /** Switch to a different input buffer.
1362 * @param new_buffer The new input buffer.
1363 *
1364 */
1365 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1366 {
1367
1368 /* TODO. We should be able to replace this entire function body
1369 * with
1370 * yypop_buffer_state();
1371 * yypush_buffer_state(new_buffer);
1372 */
1373 yyensure_buffer_stack ();
1374 if ( YY_CURRENT_BUFFER == new_buffer )
1375 return;
1376
1377 if ( YY_CURRENT_BUFFER )
1378 {
1379 /* Flush out information for old buffer. */
1380 *(yy_c_buf_p) = (yy_hold_char);
1381 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1382 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1383 }
1384
1385 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1386 yy_load_buffer_state( );
1387
1388 /* We don't actually know whether we did this switch during
1389 * EOF (yywrap()) processing, but the only time this flag
1390 * is looked at is after yywrap() is called, so it's safe
1391 * to go ahead and always set it.
1392 */
1393 (yy_did_buffer_switch_on_eof) = 1;
1394 }
1395
1396 static void yy_load_buffer_state (void)
1397 {
1398 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1399 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1400 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1401 (yy_hold_char) = *(yy_c_buf_p);
1402 }
1403
1404 /** Allocate and initialize an input buffer state.
1405 * @param file A readable stream.
1406 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1407 *
1408 * @return the allocated buffer state.
1409 */
1410 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1411 {
1412 YY_BUFFER_STATE b;
1413
1414 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1415 if ( ! b )
1416 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1417
1418 b->yy_buf_size = size;
1419
1420 /* yy_ch_buf has to be 2 characters longer than the size given because
1421 * we need to put in 2 end-of-buffer characters.
1422 */
1423 b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
1424 if ( ! b->yy_ch_buf )
1425 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1426
1427 b->yy_is_our_buffer = 1;
1428
1429 yy_init_buffer(b,file );
1430
1431 return b;
1432 }
1433
1434 /** Destroy the buffer.
1435 * @param b a buffer created with yy_create_buffer()
1436 *
1437 */
1438 void yy_delete_buffer (YY_BUFFER_STATE b )
1439 {
1440
1441 if ( ! b )
1442 return;
1443
1444 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1445 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1446
1447 if ( b->yy_is_our_buffer )
1448 yyfree((void *) b->yy_ch_buf );
1449
1450 yyfree((void *) b );
1451 }
1452
1453 /* Initializes or reinitializes a buffer.
1454 * This function is sometimes called more than once on the same buffer,
1455 * such as during a yyrestart() or at EOF.
1456 */
1457 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1458
1459 {
1460 int oerrno = errno;
1461
1462 yy_flush_buffer(b );
1463
1464 b->yy_input_file = file;
1465 b->yy_fill_buffer = 1;
1466
1467 /* If b is the current buffer, then yy_init_buffer was _probably_
1468 * called from yyrestart() or through yy_get_next_buffer.
1469 * In that case, we don't want to reset the lineno or column.
1470 */
1471 if (b != YY_CURRENT_BUFFER){
1472 b->yy_bs_lineno = 1;
1473 b->yy_bs_column = 0;
1474 }
1475
1476 b->yy_is_interactive = 0;
1477
1478 errno = oerrno;
1479 }
1480
1481 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1482 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1483 *
1484 */
1485 void yy_flush_buffer (YY_BUFFER_STATE b )
1486 {
1487 if ( ! b )
1488 return;
1489
1490 b->yy_n_chars = 0;
1491
1492 /* We always need two end-of-buffer characters. The first causes
1493 * a transition to the end-of-buffer state. The second causes
1494 * a jam in that state.
1495 */
1496 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1497 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1498
1499 b->yy_buf_pos = &b->yy_ch_buf[0];
1500
1501 b->yy_at_bol = 1;
1502 b->yy_buffer_status = YY_BUFFER_NEW;
1503
1504 if ( b == YY_CURRENT_BUFFER )
1505 yy_load_buffer_state( );
1506 }
1507
1508 /** Pushes the new state onto the stack. The new state becomes
1509 * the current state. This function will allocate the stack
1510 * if necessary.
1511 * @param new_buffer The new state.
1512 *
1513 */
1514 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1515 {
1516 if (new_buffer == NULL)
1517 return;
1518
1519 yyensure_buffer_stack();
1520
1521 /* This block is copied from yy_switch_to_buffer. */
1522 if ( YY_CURRENT_BUFFER )
1523 {
1524 /* Flush out information for old buffer. */
1525 *(yy_c_buf_p) = (yy_hold_char);
1526 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1527 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1528 }
1529
1530 /* Only push if top exists. Otherwise, replace top. */
1531 if (YY_CURRENT_BUFFER)
1532 (yy_buffer_stack_top)++;
1533 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1534
1535 /* copied from yy_switch_to_buffer. */
1536 yy_load_buffer_state( );
1537 (yy_did_buffer_switch_on_eof) = 1;
1538 }
1539
1540 /** Removes and deletes the top of the stack, if present.
1541 * The next element becomes the new top.
1542 *
1543 */
1544 void yypop_buffer_state (void)
1545 {
1546 if (!YY_CURRENT_BUFFER)
1547 return;
1548
1549 yy_delete_buffer(YY_CURRENT_BUFFER );
1550 YY_CURRENT_BUFFER_LVALUE = NULL;
1551 if ((yy_buffer_stack_top) > 0)
1552 --(yy_buffer_stack_top);
1553
1554 if (YY_CURRENT_BUFFER) {
1555 yy_load_buffer_state( );
1556 (yy_did_buffer_switch_on_eof) = 1;
1557 }
1558 }
1559
1560 /* Allocates the stack if it does not exist.
1561 * Guarantees space for at least one push.
1562 */
1563 static void yyensure_buffer_stack (void)
1564 {
1565 int num_to_alloc;
1566
1567 if (!(yy_buffer_stack)) {
1568
1569 /* First allocation is just for 2 elements, since we don't know if this
1570 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1571 * immediate realloc on the next call.
1572 */
1573 num_to_alloc = 1;
1574 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1575 (num_to_alloc * sizeof(struct yy_buffer_state*)
1576 );
1577
1578 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1579
1580 (yy_buffer_stack_max) = num_to_alloc;
1581 (yy_buffer_stack_top) = 0;
1582 return;
1583 }
1584
1585 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1586
1587 /* Increase the buffer to prepare for a possible push. */
1588 int grow_size = 8 /* arbitrary grow size */;
1589
1590 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1591 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1592 ((yy_buffer_stack),
1593 num_to_alloc * sizeof(struct yy_buffer_state*)
1594 );
1595
1596 /* zero only the new slots.*/
1597 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1598 (yy_buffer_stack_max) = num_to_alloc;
1599 }
1600 }
1601
1602 #ifndef YY_EXIT_FAILURE
1603 #define YY_EXIT_FAILURE 2
1604 #endif
1605
1606 static void yy_fatal_error (yyconst char* msg )
1607 {
1608 (void) fprintf( stderr, "%s\n", msg );
1609 exit( YY_EXIT_FAILURE );
1610 }
1611
1612 /* Redefine yyless() so it works in section 3 code. */
1613
1614 #undef yyless
1615 #define yyless(n) \
1616 do \
1617 { \
1618 /* Undo effects of setting up yytext. */ \
1619 int yyless_macro_arg = (n); \
1620 YY_LESS_LINENO(yyless_macro_arg);\
1621 yytext[yyleng] = (yy_hold_char); \
1622 (yy_c_buf_p) = yytext + yyless_macro_arg; \
1623 (yy_hold_char) = *(yy_c_buf_p); \
1624 *(yy_c_buf_p) = '\0'; \
1625 yyleng = yyless_macro_arg; \
1626 } \
1627 while ( 0 )
1628
1629 /* Accessor methods (get/set functions) to struct members. */
1630
1631 /** Get the current line number.
1632 *
1633 */
1634 int yyget_lineno (void)
1635 {
1636
1637 return yylineno;
1638 }
1639
1640 /** Get the input stream.
1641 *
1642 */
1643 FILE *yyget_in (void)
1644 {
1645 return yyin;
1646 }
1647
1648 /** Get the output stream.
1649 *
1650 */
1651 FILE *yyget_out (void)
1652 {
1653 return yyout;
1654 }
1655
1656 /** Get the length of the current token.
1657 *
1658 */
1659 int yyget_leng (void)
1660 {
1661 return yyleng;
1662 }
1663
1664 /** Get the current token.
1665 *
1666 */
1667
1668 char *yyget_text (void)
1669 {
1670 return yytext;
1671 }
1672
1673 /** Set the current line number.
1674 * @param line_number
1675 *
1676 */
1677 void yyset_lineno (int line_number )
1678 {
1679
1680 yylineno = line_number;
1681 }
1682
1683 /** Set the input stream. This does not discard the current
1684 * input buffer.
1685 * @param in_str A readable stream.
1686 *
1687 * @see yy_switch_to_buffer
1688 */
1689 void yyset_in (FILE * in_str )
1690 {
1691 yyin = in_str ;
1692 }
1693
1694 void yyset_out (FILE * out_str )
1695 {
1696 yyout = out_str ;
1697 }
1698
1699 int yyget_debug (void)
1700 {
1701 return yy_flex_debug;
1702 }
1703
1704 void yyset_debug (int bdebug )
1705 {
1706 yy_flex_debug = bdebug ;
1707 }
1708
1709 static int yy_init_globals (void)
1710 {
1711 /* Initialization is the same as for the non-reentrant scanner.
1712 * This function is called from yylex_destroy(), so don't allocate here.
1713 */
1714
1715 (yy_buffer_stack) = 0;
1716 (yy_buffer_stack_top) = 0;
1717 (yy_buffer_stack_max) = 0;
1718 (yy_c_buf_p) = (char *) 0;
1719 (yy_init) = 0;
1720 (yy_start) = 0;
1721
1722 /* Defined in main.c */
1723 #ifdef YY_STDINIT
1724 yyin = stdin;
1725 yyout = stdout;
1726 #else
1727 yyin = (FILE *) 0;
1728 yyout = (FILE *) 0;
1729 #endif
1730
1731 /* For future reference: Set errno on error, since we are called by
1732 * yylex_init()
1733 */
1734 return 0;
1735 }
1736
1737 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
1738 int yylex_destroy (void)
1739 {
1740
1741 /* Pop the buffer stack, destroying each element. */
1742 while(YY_CURRENT_BUFFER){
1743 yy_delete_buffer(YY_CURRENT_BUFFER );
1744 YY_CURRENT_BUFFER_LVALUE = NULL;
1745 yypop_buffer_state();
1746 }
1747
1748 /* Destroy the stack itself. */
1749 yyfree((yy_buffer_stack) );
1750 (yy_buffer_stack) = NULL;
1751
1752 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1753 * yylex() is called, initialization will occur. */
1754 yy_init_globals( );
1755
1756 return 0;
1757 }
1758
1759 /*
1760 * Internal utility routines.
1761 */
1762
1763 #ifndef yytext_ptr
1764 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1765 {
1766 register int i;
1767 for ( i = 0; i < n; ++i )
1768 s1[i] = s2[i];
1769 }
1770 #endif
1771
1772 #ifdef YY_NEED_STRLEN
1773 static int yy_flex_strlen (yyconst char * s )
1774 {
1775 register int n;
1776 for ( n = 0; s[n]; ++n )
1777 ;
1778
1779 return n;
1780 }
1781 #endif
1782
1783 void *yyalloc (yy_size_t size )
1784 {
1785 return (void *) malloc( size );
1786 }
1787
1788 void *yyrealloc (void * ptr, yy_size_t size )
1789 {
1790 /* The cast to (char *) in the following accommodates both
1791 * implementations that use char* generic pointers, and those
1792 * that use void* generic pointers. It works with the latter
1793 * because both ANSI C and C++ allow castless assignment from
1794 * any pointer type to void*, and deal with argument conversions
1795 * as though doing an assignment.
1796 */
1797 return (void *) realloc( (char *) ptr, size );
1798 }
1799
1800 void yyfree (void * ptr )
1801 {
1802 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
1803 }
1804
1805 #define YYTABLES_NAME "yytables"
1806
1807 #line 104 "script-scanner.ll"
1808
1809
1810
1811 void compiler::scan_begin()
1812 {
1813 if ((yyin = fopen(file.c_str(), "r")) == 0)
1814 error(file + " がオープンできません。");
1815 }
1816
1817 void compiler::scan_end()
1818 {
1819 fclose(yyin);
1820 yylex_destroy();
1821 }
1822