5 #define YY_INT_ALIGNED short int
7 /* A lexical scanner generated by flex */
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 5
12 #define YY_FLEX_SUBMINOR_VERSION 35
13 #if YY_FLEX_SUBMINOR_VERSION > 0
17 /* First, we deal with platform-specific or compiler-specific issues. */
19 /* begin standard C headers. */
25 /* end standard C headers. */
27 /* flex integer type definitions */
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
34 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
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
;
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
;
59 /* Limits of integral types. */
61 #define INT8_MIN (-128)
64 #define INT16_MIN (-32767-1)
67 #define INT32_MIN (-2147483647-1)
70 #define INT8_MAX (127)
73 #define INT16_MAX (32767)
76 #define INT32_MAX (2147483647)
79 #define UINT8_MAX (255U)
82 #define UINT16_MAX (65535U)
85 #define UINT32_MAX (4294967295U)
88 #endif /* ! FLEXINT_H */
92 /* The "const" storage-class-modifier is valid. */
95 #else /* ! __cplusplus */
97 /* C99 requires __STDC__ to be defined as 1. */
98 #if defined (__STDC__)
102 #endif /* defined (__STDC__) */
103 #endif /* ! __cplusplus */
106 #define yyconst const
111 /* Returned upon end-of-file. */
114 /* Promotes a possibly negative, possibly signed char to an unsigned
115 * integer for use as an array index. If the signed char is negative,
116 * we want to instead treat it as an 8-bit unsigned char, hence the
119 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
121 /* Enter a start condition. This macro really ought to take a parameter,
122 * but we do it the disgusting crufty way forced on us by the ()-less
123 * definition of BEGIN.
125 #define BEGIN (yy_start) = 1 + 2 *
127 /* Translate the current start state into a value that can be later handed
128 * to BEGIN to return to the state. The YYSTATE alias is for lex
131 #define YY_START (((yy_start) - 1) / 2)
132 #define YYSTATE YY_START
134 /* Action number for EOF rule of a given start state. */
135 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
137 /* Special action meaning "start processing a new file". */
138 #define YY_NEW_FILE yyrestart(yyin )
140 #define YY_END_OF_BUFFER_CHAR 0
142 /* Size of default input buffer. */
144 #define YY_BUF_SIZE 16384
147 /* The state buf must be large enough to hold one state per character in the main buffer.
149 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
151 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
152 #define YY_TYPEDEF_YY_BUFFER_STATE
153 typedef struct yy_buffer_state
*YY_BUFFER_STATE
;
158 extern FILE *yyin
, *yyout
;
160 #define EOB_ACT_CONTINUE_SCAN 0
161 #define EOB_ACT_END_OF_FILE 1
162 #define EOB_ACT_LAST_MATCH 2
164 #define YY_LESS_LINENO(n)
166 /* Return all but the first "n" matched characters back to the input stream. */
170 /* Undo effects of setting up yytext. */ \
171 int yyless_macro_arg = (n); \
172 YY_LESS_LINENO(yyless_macro_arg);\
173 *yy_cp = (yy_hold_char); \
174 YY_RESTORE_YY_MORE_OFFSET \
175 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
176 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
180 #define unput(c) yyunput( c, (yytext_ptr) )
182 #ifndef YY_TYPEDEF_YY_SIZE_T
183 #define YY_TYPEDEF_YY_SIZE_T
184 typedef size_t yy_size_t
;
187 #ifndef YY_STRUCT_YY_BUFFER_STATE
188 #define YY_STRUCT_YY_BUFFER_STATE
189 struct yy_buffer_state
193 char *yy_ch_buf
; /* input buffer */
194 char *yy_buf_pos
; /* current position in input buffer */
196 /* Size of input buffer in bytes, not including room for EOB
199 yy_size_t yy_buf_size
;
201 /* Number of characters read into yy_ch_buf, not including EOB
206 /* Whether we "own" the buffer - i.e., we know we created it,
207 * and can realloc() it to grow it, and should free() it to
210 int yy_is_our_buffer
;
212 /* Whether this is an "interactive" input source; if so, and
213 * if we're using stdio for input, then we want to use getc()
214 * instead of fread(), to make sure we stop fetching input after
217 int yy_is_interactive
;
219 /* Whether we're considered to be at the beginning of a line.
220 * If so, '^' rules will be active on the next match, otherwise
225 int yy_bs_lineno
; /**< The line count. */
226 int yy_bs_column
; /**< The column count. */
228 /* Whether to try to fill the input buffer when we reach the
233 int yy_buffer_status
;
235 #define YY_BUFFER_NEW 0
236 #define YY_BUFFER_NORMAL 1
237 /* When an EOF's been seen but there's still some text to process
238 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
239 * shouldn't try reading from the input source any more. We might
240 * still have a bunch of tokens to match, though, because of
241 * possible backing-up.
243 * When we actually see the EOF, we change the status to "new"
244 * (via yyrestart()), so that the user can continue scanning by
245 * just pointing yyin at a new input file.
247 #define YY_BUFFER_EOF_PENDING 2
250 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
252 /* Stack of input buffers. */
253 static size_t yy_buffer_stack_top
= 0; /**< index of top of stack. */
254 static size_t yy_buffer_stack_max
= 0; /**< capacity of stack. */
255 static YY_BUFFER_STATE
* yy_buffer_stack
= 0; /**< Stack as an array. */
257 /* We provide macros for accessing buffer states in case in the
258 * future we want to put the buffer states in a more general
261 * Returns the top of the stack, or NULL.
263 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
264 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
267 /* Same as previous macro, but useful when we know that the buffer stack is not
268 * NULL or when we need an lvalue. For internal use only.
270 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
272 /* yy_hold_char holds the character lost when yytext is formed. */
273 static char yy_hold_char
;
274 static int yy_n_chars
; /* number of characters read into yy_ch_buf */
277 /* Points to current character in buffer. */
278 static char *yy_c_buf_p
= (char *) 0;
279 static int yy_init
= 0; /* whether we need to initialize */
280 static int yy_start
= 0; /* start state number */
282 /* Flag which is used to allow yywrap()'s to do buffer switches
283 * instead of setting up a fresh yyin. A bit of a hack ...
285 static int yy_did_buffer_switch_on_eof
;
287 void yyrestart (FILE *input_file
);
288 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer
);
289 YY_BUFFER_STATE
yy_create_buffer (FILE *file
,int size
);
290 void yy_delete_buffer (YY_BUFFER_STATE b
);
291 void yy_flush_buffer (YY_BUFFER_STATE b
);
292 void yypush_buffer_state (YY_BUFFER_STATE new_buffer
);
293 void yypop_buffer_state (void );
295 static void yyensure_buffer_stack (void );
296 static void yy_load_buffer_state (void );
297 static void yy_init_buffer (YY_BUFFER_STATE b
,FILE *file
);
299 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
301 YY_BUFFER_STATE
yy_scan_buffer (char *base
,yy_size_t size
);
302 YY_BUFFER_STATE
yy_scan_string (yyconst
char *yy_str
);
303 YY_BUFFER_STATE
yy_scan_bytes (yyconst
char *bytes
,int len
);
305 void *yyalloc (yy_size_t
);
306 void *yyrealloc (void *,yy_size_t
);
307 void yyfree (void * );
309 #define yy_new_buffer yy_create_buffer
311 #define yy_set_interactive(is_interactive) \
313 if ( ! YY_CURRENT_BUFFER ){ \
314 yyensure_buffer_stack (); \
315 YY_CURRENT_BUFFER_LVALUE = \
316 yy_create_buffer(yyin,YY_BUF_SIZE ); \
318 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
321 #define yy_set_bol(at_bol) \
323 if ( ! YY_CURRENT_BUFFER ){\
324 yyensure_buffer_stack (); \
325 YY_CURRENT_BUFFER_LVALUE = \
326 yy_create_buffer(yyin,YY_BUF_SIZE ); \
328 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
331 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
333 /* Begin user sect3 */
335 typedef unsigned char YY_CHAR
;
337 FILE *yyin
= (FILE *) 0, *yyout
= (FILE *) 0;
339 typedef int yy_state_type
;
346 #define yytext_ptr yytext
348 static yy_state_type
yy_get_previous_state (void );
349 static yy_state_type
yy_try_NUL_trans (yy_state_type current_state
);
350 static int yy_get_next_buffer (void );
351 static void yy_fatal_error (yyconst
char msg
[] );
353 /* Done after the current pattern has been matched and before the
354 * corresponding action - sets up yytext.
356 #define YY_DO_BEFORE_ACTION \
357 (yytext_ptr) = yy_bp; \
358 yyleng = (size_t) (yy_cp - yy_bp); \
359 (yy_hold_char) = *yy_cp; \
361 (yy_c_buf_p) = yy_cp;
363 #define YY_NUM_RULES 21
364 #define YY_END_OF_BUFFER 22
365 /* This struct is not used in this scanner,
366 but its presence is necessary. */
369 flex_int32_t yy_verify
;
372 static yyconst flex_int16_t yy_accept
[111] =
374 0, 0, 13, 13, 0, 0, 22, 20, 19, 19,
375 20, 20, 17, 17, 20, 20, 18, 20, 13, 13,
376 13, 13, 13, 13, 13, 13, 2, 3, 1, 0,
377 0, 9, 8, 0, 0, 0, 0, 0, 15, 17,
378 12, 15, 4, 0, 0, 0, 0, 0, 6, 13,
379 13, 8, 13, 13, 13, 13, 13, 13, 12, 13,
380 13, 13, 0, 7, 0, 10, 0, 11, 0, 15,
381 15, 0, 0, 10, 13, 11, 13, 13, 13, 13,
382 0, 15, 0, 0, 0, 13, 13, 13, 13, 15,
383 5, 16, 13, 15, 13, 15, 13, 15, 13, 0,
385 0, 0, 14, 0, 0, 12, 14, 10, 11, 0
388 static yyconst flex_int32_t yy_ec
[256] =
390 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
391 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
392 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
393 1, 2, 1, 4, 5, 1, 1, 1, 1, 1,
394 1, 1, 6, 1, 7, 8, 9, 10, 11, 11,
395 11, 11, 10, 11, 11, 11, 11, 12, 1, 1,
396 13, 1, 1, 1, 9, 9, 9, 9, 9, 9,
397 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
398 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
399 14, 15, 16, 1, 9, 1, 9, 9, 17, 18,
401 19, 9, 9, 9, 20, 9, 9, 21, 9, 22,
402 9, 9, 9, 9, 9, 9, 23, 9, 9, 9,
403 9, 9, 1, 1, 1, 1, 1, 1, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406 1, 1, 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,
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
420 static yyconst flex_int32_t yy_meta
[24] =
422 1, 2, 2, 1, 1, 3, 3, 3, 3, 3,
423 3, 4, 3, 1, 1, 1, 3, 3, 3, 3,
427 static yyconst flex_int16_t yy_base
[122] =
429 0, 230, 23, 229, 44, 45, 233, 395, 227, 395,
430 47, 42, 61, 83, 95, 85, 395, 228, 0, 105,
431 44, 120, 136, 158, 0, 54, 395, 395, 395, 227,
432 96, 395, 395, 225, 0, 168, 214, 180, 192, 204,
433 395, 216, 395, 237, 110, 144, 207, 222, 395, 0,
434 247, 0, 89, 0, 211, 261, 274, 0, 0, 199,
435 65, 92, 217, 395, 203, 395, 202, 395, 296, 192,
436 93, 48, 191, 0, 199, 0, 308, 0, 191, 140,
437 191, 141, 193, 162, 184, 187, 159, 168, 320, 150,
438 395, 182, 126, 170, 114, 97, 95, 187, 194, 330,
440 99, 342, 0, 164, 188, 74, 395, 62, 46, 395,
441 355, 359, 362, 365, 369, 373, 376, 380, 384, 387,
445 static yyconst flex_int16_t yy_def
[122] =
447 110, 1, 110, 3, 111, 111, 110, 110, 110, 110,
448 112, 110, 110, 113, 110, 114, 110, 115, 116, 117,
449 116, 110, 22, 116, 116, 118, 110, 110, 110, 119,
450 112, 110, 110, 112, 15, 110, 110, 113, 120, 113,
451 110, 120, 110, 110, 114, 114, 114, 115, 110, 116,
452 117, 116, 117, 24, 116, 23, 110, 23, 116, 57,
453 24, 118, 119, 110, 110, 110, 38, 110, 120, 42,
454 42, 44, 114, 116, 56, 116, 57, 57, 57, 24,
455 69, 42, 72, 83, 114, 77, 57, 24, 116, 42,
456 110, 114, 57, 42, 57, 42, 57, 42, 57, 121,
458 121, 121, 36, 121, 121, 121, 110, 121, 121, 0,
459 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
463 static yyconst flex_int16_t yy_nxt
[419] =
465 8, 9, 10, 11, 8, 8, 12, 13, 14, 15,
466 15, 16, 8, 17, 8, 8, 14, 14, 14, 14,
467 14, 14, 14, 19, 9, 10, 20, 19, 19, 21,
468 22, 23, 24, 24, 16, 19, 25, 19, 19, 23,
469 23, 23, 23, 23, 23, 23, 28, 28, 107, 32,
470 33, 35, 35, 54, 54, 48, 49, 83, 84, 29,
471 29, 34, 36, 36, 107, 48, 37, 38, 39, 39,
472 40, 40, 50, 41, 80, 80, 107, 39, 39, 39,
473 42, 39, 39, 39, 36, 36, 46, 46, 37, 38,
474 31, 110, 47, 48, 49, 41, 43, 43, 32, 33,
476 31, 107, 44, 48, 35, 35, 31, 32, 52, 82,
477 34, 46, 46, 99, 70, 98, 31, 47, 70, 53,
478 50, 36, 36, 50, 50, 55, 56, 57, 57, 58,
479 58, 97, 59, 50, 50, 50, 57, 57, 57, 60,
480 57, 57, 57, 58, 58, 46, 46, 50, 95, 88,
481 89, 47, 58, 58, 58, 58, 58, 58, 58, 43,
482 43, 90, 70, 91, 91, 61, 107, 54, 54, 36,
483 36, 70, 94, 37, 65, 50, 108, 89, 89, 93,
484 41, 110, 110, 110, 110, 110, 67, 96, 100, 100,
485 107, 70, 68, 36, 36, 100, 100, 37, 69, 50,
487 109, 92, 84, 110, 41, 36, 36, 87, 70, 37,
488 38, 50, 85, 70, 110, 68, 41, 36, 36, 64,
489 79, 37, 69, 74, 49, 73, 66, 110, 41, 64,
490 49, 30, 110, 26, 18, 110, 110, 71, 43, 43,
491 110, 110, 110, 110, 110, 110, 72, 72, 31, 32,
492 52, 110, 110, 110, 110, 110, 110, 110, 31, 110,
493 110, 53, 110, 110, 110, 110, 50, 75, 110, 110,
494 110, 110, 110, 76, 50, 36, 36, 50, 50, 55,
495 77, 78, 78, 78, 78, 110, 59, 50, 50, 50,
496 78, 78, 78, 78, 78, 78, 78, 110, 110, 110,
498 110, 110, 81, 110, 110, 110, 110, 110, 68, 110,
499 110, 110, 110, 50, 86, 110, 110, 110, 110, 110,
500 76, 91, 91, 110, 110, 110, 110, 110, 110, 89,
501 89, 102, 103, 110, 110, 104, 105, 110, 110, 110,
502 110, 110, 106, 102, 103, 110, 110, 104, 105, 110,
503 110, 110, 110, 110, 106, 27, 27, 27, 27, 31,
504 31, 31, 31, 40, 40, 45, 45, 45, 45, 48,
505 48, 48, 48, 50, 110, 50, 51, 51, 51, 51,
506 62, 62, 62, 62, 63, 63, 63, 63, 70, 70,
507 101, 101, 101, 101, 7, 110, 110, 110, 110, 110,
509 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
510 110, 110, 110, 110, 110, 110, 110, 110
513 static yyconst flex_int16_t yy_chk
[419] =
515 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
516 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
517 1, 1, 1, 3, 3, 3, 3, 3, 3, 3,
518 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
519 3, 3, 3, 3, 3, 3, 5, 6, 109, 11,
520 11, 12, 12, 21, 21, 26, 26, 72, 72, 5,
521 6, 11, 13, 13, 108, 26, 13, 13, 13, 13,
522 13, 13, 61, 13, 61, 61, 106, 13, 13, 13,
523 13, 13, 13, 13, 14, 14, 16, 16, 14, 14,
524 53, 53, 16, 62, 62, 14, 15, 15, 31, 31,
526 53, 101, 15, 62, 15, 15, 20, 20, 20, 71,
527 31, 45, 45, 97, 71, 96, 20, 45, 96, 20,
528 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
529 22, 95, 22, 22, 22, 22, 22, 22, 22, 22,
530 22, 22, 22, 23, 23, 46, 46, 80, 93, 80,
531 80, 46, 23, 23, 23, 23, 23, 23, 23, 24,
532 24, 82, 82, 84, 84, 24, 104, 24, 24, 36,
533 36, 90, 90, 36, 36, 88, 104, 88, 88, 87,
534 36, 38, 38, 92, 92, 38, 38, 94, 98, 98,
535 105, 94, 38, 39, 39, 99, 99, 39, 39, 86,
537 105, 85, 83, 81, 39, 40, 40, 79, 98, 40,
538 40, 75, 73, 70, 67, 65, 40, 42, 42, 63,
539 60, 42, 42, 55, 48, 47, 37, 34, 42, 30,
540 18, 9, 7, 4, 2, 0, 0, 42, 44, 44,
541 0, 0, 0, 0, 0, 0, 44, 44, 51, 51,
542 51, 0, 0, 0, 0, 0, 0, 0, 51, 0,
543 0, 51, 56, 56, 0, 0, 56, 56, 0, 0,
544 0, 0, 0, 56, 57, 57, 57, 57, 57, 57,
545 57, 57, 57, 57, 57, 0, 57, 57, 57, 57,
546 57, 57, 57, 57, 57, 57, 57, 69, 69, 0,
548 0, 69, 69, 0, 0, 0, 0, 0, 69, 77,
549 77, 0, 0, 77, 77, 0, 0, 0, 0, 0,
550 77, 89, 89, 0, 0, 0, 0, 0, 0, 89,
551 89, 100, 100, 0, 0, 100, 100, 0, 0, 0,
552 0, 0, 100, 102, 102, 0, 0, 102, 102, 0,
553 0, 0, 0, 0, 102, 111, 111, 111, 111, 112,
554 112, 112, 112, 113, 113, 114, 114, 114, 114, 115,
555 115, 115, 115, 116, 0, 116, 117, 117, 117, 117,
556 118, 118, 118, 118, 119, 119, 119, 119, 120, 120,
557 121, 121, 121, 121, 110, 110, 110, 110, 110, 110,
559 110, 110, 110, 110, 110, 110, 110, 110, 110, 110,
560 110, 110, 110, 110, 110, 110, 110, 110
563 static yy_state_type yy_last_accepting_state
;
564 static char *yy_last_accepting_cpos
;
566 extern int yy_flex_debug
;
567 int yy_flex_debug
= 0;
569 /* The intent behind this definition is that it'll catch
570 * any uses of REJECT which flex missed.
572 #define REJECT reject_used_but_not_detected
573 #define yymore() yymore_used_but_not_detected
574 #define YY_MORE_ADJ 0
575 #define YY_RESTORE_YY_MORE_OFFSET
583 #include "../lib/q.h"
585 #include "../lib/utf8.h"
587 //RVALUE {NUMBER}|{PERCENT}|{NAME}|\"{STRING}\"|{DIM}
588 //<a>. {printf("<a>%s\n", yytext);}
589 // %x: exclusive, %s: inclusive
590 char*type_names
[] = {"twip","number","command","string","assignment","identifier","label","end"};
597 static void count(char*text
, int len
, int condition
)
610 static char*prefix
= 0;
612 static void unescapeString(string_t
* tmp
)
615 /* fixme - this routine expects the string to be
618 for (p1
=(char*)tmp
->str
; (p
=strchr(p1
, '\\')); p1
= p
+1)
624 case '\\': p
[0] = '\\'; break;
625 case '"': p
[0] = '"'; break;
626 case 'b': p
[0] = '\b'; break;
627 case 'f': p
[0] = '\f'; break;
628 case 'n': p
[0] = '\n'; break;
629 case 'r': p
[0] = '\r'; break;
630 case 't': p
[0] = '\t'; break;
631 case 'x': case 'u': {
639 bracket
= 1;nr
++;max
++;
641 while(strchr("0123456789abcdefABCDEF", p
[nr
]) && (bracket
|| nr
< max
)) {
643 if(p
[nr
]>='0' && p
[nr
]<='9') num
|= p
[nr
] - '0';
644 if(p
[nr
]>='a' && p
[nr
]<='f') num
|= p
[nr
] - 'a' + 10;
645 if(p
[nr
]>='A' && p
[nr
]<='F') num
|= p
[nr
] - 'A' + 10;
648 if(bracket
&& p
[nr
]=='}') {
654 memcpy(p
, utf8
, new); // do not copy the terminating zero
660 tmp
->len
-= (nr
-new);
663 char*to
=p
+new,*from
=p
+nr
;
673 static void store(enum type_t type
, int line
, int column
, char*text
, int length
)
675 struct token_t token
;
679 token
.column
= column
;
680 //printf("->%d(%s) %s\n", type, type_names[type], text);fflush(stdout);
686 string_set2(&tmp
, "", 0);
687 token
.text_pos
= mem_putstring(&strings
, tmp
);
690 string_set2(&tmp
, text
+1, length
-2);
691 unescapeString(&tmp
);
692 token
.text_pos
= mem_putstring(&strings
, tmp
);
697 string_set2(&tmp
, text
, length
);
700 token
.text_pos
= mem_put(&strings
, prefix
, strlen(prefix
));
701 mem_putstring(&strings
, tmp
);
703 token
.text_pos
= mem_putstring(&strings
, tmp
);
708 string_set2(&tmp
, text
+1/*:*/, length
-5/*.end*/);
709 token
.text_pos
= mem_putstring(&strings
, tmp
);
712 string_set2(&tmp
, text
+1, length
-1);
713 token
.text_pos
= mem_putstring(&strings
, tmp
);
716 char*x
= &text
[length
-1];
717 if(x
[-1] == '-' || x
[-1] == '+')
719 do{x
--;} while(*x
==32 || *x
==10 || *x
==13 || *x
=='\t');
721 string_set2(&tmp
, text
, x
-text
);
722 token
.text_pos
= mem_putstring(&strings
, tmp
);
723 /*char*y,*x = strchr(text, '=');
726 do{y--;} while(*y==32 || *y==10 || *y==13 || *y=='\t');
727 do{x++;} while(*x==32 || *x==10 || *x==13 || *x=='\t');
728 token.text1 = (char*)put(&strings, text, y-text + 1, 1);
729 token.text2 = (char*)put(&strings, x, length-(x-text), 1);*/
733 mem_put(&tokens
, &token
, sizeof(struct token_t
));
737 #define MAX_INCLUDE_DEPTH 16
738 static YY_BUFFER_STATE include_stack
[MAX_INCLUDE_DEPTH
];
739 static int line_stack
[MAX_INCLUDE_DEPTH
];
740 static int column_stack
[MAX_INCLUDE_DEPTH
];
741 static int include_stack_ptr
= 0;
743 static void handleInclude(char*text
, int len
)
746 while(len
>=1 && (text
[0] == ' ' || text
[0] == '\t')) {
750 (text
[len
-1] == ' ' ||
751 text
[len
-1] == '\r' ||
752 text
[len
-1] == '\n')) {
755 if(len
>= 2 && text
[0] == '"' && text
[len
-1] == '"') {
759 if(include_stack_ptr
>= MAX_INCLUDE_DEPTH
) {
760 fprintf( stderr
, "Includes nested too deeply" );
763 include_stack
[include_stack_ptr
] = YY_CURRENT_BUFFER
;
764 line_stack
[include_stack_ptr
] = line
;
765 column_stack
[include_stack_ptr
] = column
;
767 yyin
= fopen(text
, "rb");
769 fprintf(stderr
, "Couldn't open %s\n", text
);
772 yy_switch_to_buffer(yy_create_buffer(yyin
,YY_BUF_SIZE
) );
782 #define c() {count(yytext, yyleng, YY_START);}
783 #define s(type) {store(type, line, column, yytext, yyleng);}
786 #line 787 "parser.yy.c"
792 #ifndef YY_NO_UNISTD_H
793 /* Special case for "unistd.h", since it is non-ANSI. We include it way
794 * down here because we want the user's section 1 to have been scanned first.
795 * The user has a chance to override it with an option.
800 #ifndef YY_EXTRA_TYPE
801 #define YY_EXTRA_TYPE void *
804 static int yy_init_globals (void );
806 /* Accessor methods to globals.
807 These are made visible to non-reentrant scanners for convenience. */
809 int yylex_destroy (void );
811 int yyget_debug (void );
813 void yyset_debug (int debug_flag
);
815 YY_EXTRA_TYPE
yyget_extra (void );
817 void yyset_extra (YY_EXTRA_TYPE user_defined
);
819 FILE *yyget_in (void );
821 void yyset_in (FILE * in_str
);
823 FILE *yyget_out (void );
825 void yyset_out (FILE * out_str
);
827 int yyget_leng (void );
829 char *yyget_text (void );
831 int yyget_lineno (void );
833 void yyset_lineno (int line_number
);
835 /* Macros after this point can all be overridden by user definitions in
839 #ifndef YY_SKIP_YYWRAP
841 extern "C" int yywrap (void );
843 extern int yywrap (void );
847 static void yyunput (int c
,char *buf_ptr
);
850 static void yy_flex_strncpy (char *,yyconst
char *,int );
853 #ifdef YY_NEED_STRLEN
854 static int yy_flex_strlen (yyconst
char * );
860 static int yyinput (void );
862 static int input (void );
867 /* Amount of stuff to slurp up with each read. */
868 #ifndef YY_READ_BUF_SIZE
869 #define YY_READ_BUF_SIZE 8192
872 /* Copy whatever the last rule matched to the standard output. */
874 /* This used to be an fputs(), but since the string might contain NUL's,
875 * we now use fwrite().
877 #define ECHO fwrite( yytext, yyleng, 1, yyout )
880 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
881 * is returned in "result".
884 #define YY_INPUT(buf,result,max_size) \
885 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
889 for ( n = 0; n < max_size && \
890 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
893 buf[n++] = (char) c; \
894 if ( c == EOF && ferror( yyin ) ) \
895 YY_FATAL_ERROR( "input in flex scanner failed" ); \
901 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
903 if( errno != EINTR) \
905 YY_FATAL_ERROR( "input in flex scanner failed" ); \
916 /* No semi-colon after return; correct usage is to write "yyterminate();" -
917 * we don't want an extra ';' after the "return" because that will cause
918 * some compilers to complain about unreachable statements.
921 #define yyterminate() return YY_NULL
924 /* Number of entries by which start-condition stack grows. */
925 #ifndef YY_START_STACK_INCR
926 #define YY_START_STACK_INCR 25
929 /* Report a fatal error. */
930 #ifndef YY_FATAL_ERROR
931 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
934 /* end tables serialization structures and prototypes */
936 /* Default declaration of generated scanner - a define so the user can
937 * easily add parameters.
940 #define YY_DECL_IS_OURS 1
942 extern int yylex (void);
944 #define YY_DECL int yylex (void)
945 #endif /* !YY_DECL */
947 /* Code executed at the beginning of each rule, after yytext and yyleng
950 #ifndef YY_USER_ACTION
951 #define YY_USER_ACTION
954 /* Code executed at the end of each rule. */
956 #define YY_BREAK break;
959 #define YY_RULE_SETUP \
961 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
962 (yytext[yyleng - 1] == '\n'); \
965 /** The main scanner function which does all the work.
969 register yy_state_type yy_current_state
;
970 register char *yy_cp
, *yy_bp
;
973 #line 220 "parser.lex"
976 #line 977 "parser.yy.c"
987 (yy_start
) = 1; /* first start state */
995 if ( ! YY_CURRENT_BUFFER
) {
996 yyensure_buffer_stack ();
997 YY_CURRENT_BUFFER_LVALUE
=
998 yy_create_buffer(yyin
,YY_BUF_SIZE
);
1001 yy_load_buffer_state( );
1004 while ( 1 ) /* loops until end-of-file is reached */
1006 yy_cp
= (yy_c_buf_p
);
1008 /* Support of yytext. */
1009 *yy_cp
= (yy_hold_char
);
1011 /* yy_bp points to the position in yy_ch_buf of the start of
1016 yy_current_state
= (yy_start
);
1017 yy_current_state
+= YY_AT_BOL();
1021 register YY_CHAR yy_c
= yy_ec
[YY_SC_TO_UI(*yy_cp
)];
1022 if ( yy_accept
[yy_current_state
] )
1024 (yy_last_accepting_state
) = yy_current_state
;
1025 (yy_last_accepting_cpos
) = yy_cp
;
1027 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1029 yy_current_state
= (int) yy_def
[yy_current_state
];
1030 if ( yy_current_state
>= 111 )
1031 yy_c
= yy_meta
[(unsigned int) yy_c
];
1033 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1036 while ( yy_current_state
!= 110 );
1037 yy_cp
= (yy_last_accepting_cpos
);
1038 yy_current_state
= (yy_last_accepting_state
);
1041 yy_act
= yy_accept
[yy_current_state
];
1043 YY_DO_BEFORE_ACTION
;
1045 do_action
: /* This label is used only to access EOF actions. */
1048 { /* beginning of action switch */
1049 case 0: /* must back up */
1050 /* undo the effects of YY_DO_BEFORE_ACTION */
1051 *yy_cp
= (yy_hold_char
);
1052 yy_cp
= (yy_last_accepting_cpos
);
1053 yy_current_state
= (yy_last_accepting_state
);
1054 goto yy_find_action
;
1058 #line 222 "parser.lex"
1063 #line 223 "parser.lex"
1067 /* rule 3 can match eol */
1069 #line 224 "parser.lex"
1073 /* rule 4 can match eol */
1074 *yy_cp
= (yy_hold_char
); /* undo effects of setting up yytext */
1075 (yy_c_buf_p
) = yy_cp
-= 1;
1076 YY_DO_BEFORE_ACTION
; /* set up yytext again */
1078 #line 225 "parser.lex"
1079 {s(TWIP
);c();BEGIN(0);}
1082 /* rule 5 can match eol */
1083 *yy_cp
= (yy_hold_char
); /* undo effects of setting up yytext */
1084 (yy_c_buf_p
) = yy_cp
-= 1;
1085 YY_DO_BEFORE_ACTION
; /* set up yytext again */
1087 #line 226 "parser.lex"
1088 {s(NUMBER
);c();BEGIN(0);}
1091 /* rule 6 can match eol */
1093 #line 227 "parser.lex"
1097 /* rule 7 can match eol */
1099 #line 228 "parser.lex"
1104 #line 229 "parser.lex"
1105 {s(STRING
);c();BEGIN(0);}
1108 *yy_cp
= (yy_hold_char
); /* undo effects of setting up yytext */
1109 (yy_c_buf_p
) = yy_cp
-= 1;
1110 YY_DO_BEFORE_ACTION
; /* set up yytext again */
1112 #line 230 "parser.lex"
1113 {c();printf("unterminated string in line %d: %s\n", line
, yytext
);exit(1);yyterminate();}
1116 /* rule 10 can match eol */
1118 #line 231 "parser.lex"
1119 {s(ASSIGNMENT
);prefix
="<plus>";c();BEGIN(R
);}
1122 /* rule 11 can match eol */
1124 #line 232 "parser.lex"
1125 {s(ASSIGNMENT
);prefix
="<minus>";c();BEGIN(R
);}
1128 /* rule 12 can match eol */
1130 #line 233 "parser.lex"
1131 {s(ASSIGNMENT
);c();BEGIN(R
);}
1133 /* values which appear only on the right-hand side of assignments, like: x=50% */
1136 #line 235 "parser.lex"
1137 {s(IDENTIFIER
);c();BEGIN(0);}
1141 /* rule 14 can match eol */
1143 #line 237 "parser.lex"
1144 {handleInclude(yytext
, yyleng
);}
1148 #line 238 "parser.lex"
1152 /* rule 16 can match eol */
1154 #line 239 "parser.lex"
1159 #line 240 "parser.lex"
1160 {s(IDENTIFIER
);c();}
1164 #line 241 "parser.lex"
1165 {c();BEGIN(BINARY
);}
1168 /* rule 19 can match eol */
1170 #line 242 "parser.lex"
1175 #line 243 "parser.lex"
1176 {char c
,c1
=yytext
[0];
1177 printf("Syntax error in line %d, %d: %s", line
, column
, yytext
);
1180 if(c
=='\n' || c
==EOF
)
1184 if(c1
>='0' && c1
<='9')
1185 printf(" (identifiers must not start with a digit)");
1191 case YY_STATE_EOF(INITIAL
):
1192 case YY_STATE_EOF(R
):
1193 case YY_STATE_EOF(BINARY
):
1194 #line 257 "parser.lex"
1196 if ( --include_stack_ptr
< 0 ) {
1200 yy_delete_buffer(YY_CURRENT_BUFFER
);
1201 yy_switch_to_buffer(include_stack
[include_stack_ptr
] );
1202 column
= column_stack
[include_stack_ptr
];
1203 line
= line_stack
[include_stack_ptr
];
1209 #line 270 "parser.lex"
1210 YY_FATAL_ERROR( "flex scanner jammed" );
1212 #line 1213 "parser.yy.c"
1214 case YY_END_OF_BUFFER
:
1216 /* Amount of text matched not including the EOB char. */
1217 int yy_amount_of_matched_text
= (int) (yy_cp
- (yytext_ptr
)) - 1;
1219 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1220 *yy_cp
= (yy_hold_char
);
1221 YY_RESTORE_YY_MORE_OFFSET
1223 if ( YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
== YY_BUFFER_NEW
)
1225 /* We're scanning a new file or input source. It's
1226 * possible that this happened because the user
1227 * just pointed yyin at a new source and called
1228 * yylex(). If so, then we have to assure
1229 * consistency between YY_CURRENT_BUFFER and our
1230 * globals. Here is the right place to do so, because
1231 * this is the first action (other than possibly a
1232 * back-up) that will match for the new input source.
1234 (yy_n_chars
) = YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
;
1235 YY_CURRENT_BUFFER_LVALUE
->yy_input_file
= yyin
;
1236 YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
= YY_BUFFER_NORMAL
;
1239 /* Note that here we test for yy_c_buf_p "<=" to the position
1240 * of the first EOB in the buffer, since yy_c_buf_p will
1241 * already have been incremented past the NUL character
1242 * (since all states make transitions on EOB to the
1243 * end-of-buffer state). Contrast this with the test
1246 if ( (yy_c_buf_p
) <= &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
)] )
1247 { /* This was really a NUL. */
1248 yy_state_type yy_next_state
;
1250 (yy_c_buf_p
) = (yytext_ptr
) + yy_amount_of_matched_text
;
1252 yy_current_state
= yy_get_previous_state( );
1254 /* Okay, we're now positioned to make the NUL
1255 * transition. We couldn't have
1256 * yy_get_previous_state() go ahead and do it
1257 * for us because it doesn't know how to deal
1258 * with the possibility of jamming (and we don't
1259 * want to build jamming into it because then it
1260 * will run more slowly).
1263 yy_next_state
= yy_try_NUL_trans( yy_current_state
);
1265 yy_bp
= (yytext_ptr
) + YY_MORE_ADJ
;
1267 if ( yy_next_state
)
1269 /* Consume the NUL. */
1270 yy_cp
= ++(yy_c_buf_p
);
1271 yy_current_state
= yy_next_state
;
1277 yy_cp
= (yy_last_accepting_cpos
);
1278 yy_current_state
= (yy_last_accepting_state
);
1279 goto yy_find_action
;
1283 else switch ( yy_get_next_buffer( ) )
1285 case EOB_ACT_END_OF_FILE
:
1287 (yy_did_buffer_switch_on_eof
) = 0;
1291 /* Note: because we've taken care in
1292 * yy_get_next_buffer() to have set up
1293 * yytext, we can now set up
1294 * yy_c_buf_p so that if some total
1295 * hoser (like flex itself) wants to
1296 * call the scanner after we return the
1297 * YY_NULL, it'll still work - another
1298 * YY_NULL will get returned.
1300 (yy_c_buf_p
) = (yytext_ptr
) + YY_MORE_ADJ
;
1302 yy_act
= YY_STATE_EOF(YY_START
);
1308 if ( ! (yy_did_buffer_switch_on_eof
) )
1314 case EOB_ACT_CONTINUE_SCAN
:
1316 (yytext_ptr
) + yy_amount_of_matched_text
;
1318 yy_current_state
= yy_get_previous_state( );
1320 yy_cp
= (yy_c_buf_p
);
1321 yy_bp
= (yytext_ptr
) + YY_MORE_ADJ
;
1324 case EOB_ACT_LAST_MATCH
:
1326 &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
)];
1328 yy_current_state
= yy_get_previous_state( );
1330 yy_cp
= (yy_c_buf_p
);
1331 yy_bp
= (yytext_ptr
) + YY_MORE_ADJ
;
1332 goto yy_find_action
;
1339 "fatal flex scanner internal error--no action found" );
1340 } /* end of action switch */
1341 } /* end of scanning one token */
1342 } /* end of yylex */
1344 /* yy_get_next_buffer - try to read in a new buffer
1346 * Returns a code representing an action:
1347 * EOB_ACT_LAST_MATCH -
1348 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1349 * EOB_ACT_END_OF_FILE - end of file
1351 static int yy_get_next_buffer (void)
1353 register char *dest
= YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
;
1354 register char *source
= (yytext_ptr
);
1355 register int number_to_move
, i
;
1358 if ( (yy_c_buf_p
) > &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
) + 1] )
1360 "fatal flex scanner internal error--end of buffer missed" );
1362 if ( YY_CURRENT_BUFFER_LVALUE
->yy_fill_buffer
== 0 )
1363 { /* Don't try to fill the buffer, so this is an EOF. */
1364 if ( (yy_c_buf_p
) - (yytext_ptr
) - YY_MORE_ADJ
== 1 )
1366 /* We matched a single character, the EOB, so
1367 * treat this as a final EOF.
1369 return EOB_ACT_END_OF_FILE
;
1374 /* We matched some text prior to the EOB, first
1377 return EOB_ACT_LAST_MATCH
;
1381 /* Try to read more data. */
1383 /* First move last chars to start of buffer. */
1384 number_to_move
= (int) ((yy_c_buf_p
) - (yytext_ptr
)) - 1;
1386 for ( i
= 0; i
< number_to_move
; ++i
)
1387 *(dest
++) = *(source
++);
1389 if ( YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
== YY_BUFFER_EOF_PENDING
)
1390 /* don't do the read, it's not guaranteed to return an EOF,
1393 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= (yy_n_chars
) = 0;
1398 YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
- number_to_move
- 1;
1400 while ( num_to_read
<= 0 )
1401 { /* Not enough room in the buffer - grow it. */
1403 /* just a shorter name for the current buffer */
1404 YY_BUFFER_STATE b
= YY_CURRENT_BUFFER
;
1406 int yy_c_buf_p_offset
=
1407 (int) ((yy_c_buf_p
) - b
->yy_ch_buf
);
1409 if ( b
->yy_is_our_buffer
)
1411 int new_size
= b
->yy_buf_size
* 2;
1413 if ( new_size
<= 0 )
1414 b
->yy_buf_size
+= b
->yy_buf_size
/ 8;
1416 b
->yy_buf_size
*= 2;
1418 b
->yy_ch_buf
= (char *)
1419 /* Include room in for 2 EOB chars. */
1420 yyrealloc((void *) b
->yy_ch_buf
,b
->yy_buf_size
+ 2 );
1423 /* Can't grow it, we don't own it. */
1426 if ( ! b
->yy_ch_buf
)
1428 "fatal error - scanner input buffer overflow" );
1430 (yy_c_buf_p
) = &b
->yy_ch_buf
[yy_c_buf_p_offset
];
1432 num_to_read
= YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
-
1437 if ( num_to_read
> YY_READ_BUF_SIZE
)
1438 num_to_read
= YY_READ_BUF_SIZE
;
1440 /* Read in more data. */
1441 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[number_to_move
]),
1442 (yy_n_chars
), (size_t) num_to_read
);
1444 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= (yy_n_chars
);
1447 if ( (yy_n_chars
) == 0 )
1449 if ( number_to_move
== YY_MORE_ADJ
)
1451 ret_val
= EOB_ACT_END_OF_FILE
;
1457 ret_val
= EOB_ACT_LAST_MATCH
;
1458 YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
=
1459 YY_BUFFER_EOF_PENDING
;
1464 ret_val
= EOB_ACT_CONTINUE_SCAN
;
1466 if ((yy_size_t
) ((yy_n_chars
) + number_to_move
) > YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
) {
1467 /* Extend the array by 50%, plus the number we really need. */
1468 yy_size_t new_size
= (yy_n_chars
) + number_to_move
+ ((yy_n_chars
) >> 1);
1469 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
= (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
,new_size
);
1470 if ( ! YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
)
1471 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1474 (yy_n_chars
) += number_to_move
;
1475 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
)] = YY_END_OF_BUFFER_CHAR
;
1476 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
) + 1] = YY_END_OF_BUFFER_CHAR
;
1478 (yytext_ptr
) = &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[0];
1483 /* yy_get_previous_state - get the state just before the EOB char was reached */
1485 static yy_state_type
yy_get_previous_state (void)
1487 register yy_state_type yy_current_state
;
1488 register char *yy_cp
;
1490 yy_current_state
= (yy_start
);
1491 yy_current_state
+= YY_AT_BOL();
1493 for ( yy_cp
= (yytext_ptr
) + YY_MORE_ADJ
; yy_cp
< (yy_c_buf_p
); ++yy_cp
)
1495 register YY_CHAR yy_c
= (*yy_cp
? yy_ec
[YY_SC_TO_UI(*yy_cp
)] : 1);
1496 if ( yy_accept
[yy_current_state
] )
1498 (yy_last_accepting_state
) = yy_current_state
;
1499 (yy_last_accepting_cpos
) = yy_cp
;
1501 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1503 yy_current_state
= (int) yy_def
[yy_current_state
];
1504 if ( yy_current_state
>= 111 )
1505 yy_c
= yy_meta
[(unsigned int) yy_c
];
1507 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1510 return yy_current_state
;
1513 /* yy_try_NUL_trans - try to make a transition on the NUL character
1516 * next_state = yy_try_NUL_trans( current_state );
1518 static yy_state_type
yy_try_NUL_trans (yy_state_type yy_current_state
)
1520 register int yy_is_jam
;
1521 register char *yy_cp
= (yy_c_buf_p
);
1523 register YY_CHAR yy_c
= 1;
1524 if ( yy_accept
[yy_current_state
] )
1526 (yy_last_accepting_state
) = yy_current_state
;
1527 (yy_last_accepting_cpos
) = yy_cp
;
1529 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1531 yy_current_state
= (int) yy_def
[yy_current_state
];
1532 if ( yy_current_state
>= 111 )
1533 yy_c
= yy_meta
[(unsigned int) yy_c
];
1535 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1536 yy_is_jam
= (yy_current_state
== 110);
1538 return yy_is_jam
? 0 : yy_current_state
;
1541 static void yyunput (int c
, register char * yy_bp
)
1543 register char *yy_cp
;
1545 yy_cp
= (yy_c_buf_p
);
1547 /* undo effects of setting up yytext */
1548 *yy_cp
= (yy_hold_char
);
1550 if ( yy_cp
< YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
+ 2 )
1551 { /* need to shift things up to make room */
1552 /* +2 for EOB chars. */
1553 register int number_to_move
= (yy_n_chars
) + 2;
1554 register char *dest
= &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[
1555 YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
+ 2];
1556 register char *source
=
1557 &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[number_to_move
];
1559 while ( source
> YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
)
1560 *--dest
= *--source
;
1562 yy_cp
+= (int) (dest
- source
);
1563 yy_bp
+= (int) (dest
- source
);
1564 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
=
1565 (yy_n_chars
) = YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
;
1567 if ( yy_cp
< YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
+ 2 )
1568 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1571 *--yy_cp
= (char) c
;
1573 (yytext_ptr
) = yy_bp
;
1574 (yy_hold_char
) = *yy_cp
;
1575 (yy_c_buf_p
) = yy_cp
;
1580 static int yyinput (void)
1582 static int input (void)
1588 *(yy_c_buf_p
) = (yy_hold_char
);
1590 if ( *(yy_c_buf_p
) == YY_END_OF_BUFFER_CHAR
)
1592 /* yy_c_buf_p now points to the character we want to return.
1593 * If this occurs *before* the EOB characters, then it's a
1594 * valid NUL; if not, then we've hit the end of the buffer.
1596 if ( (yy_c_buf_p
) < &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[(yy_n_chars
)] )
1597 /* This was really a NUL. */
1598 *(yy_c_buf_p
) = '\0';
1601 { /* need more input */
1602 int offset
= (yy_c_buf_p
) - (yytext_ptr
);
1605 switch ( yy_get_next_buffer( ) )
1607 case EOB_ACT_LAST_MATCH
:
1608 /* This happens because yy_g_n_b()
1609 * sees that we've accumulated a
1610 * token and flags that we need to
1611 * try matching the token before
1612 * proceeding. But for input(),
1613 * there's no matching to consider.
1614 * So convert the EOB_ACT_LAST_MATCH
1615 * to EOB_ACT_END_OF_FILE.
1618 /* Reset buffer status. */
1623 case EOB_ACT_END_OF_FILE
:
1628 if ( ! (yy_did_buffer_switch_on_eof
) )
1637 case EOB_ACT_CONTINUE_SCAN
:
1638 (yy_c_buf_p
) = (yytext_ptr
) + offset
;
1644 c
= *(unsigned char *) (yy_c_buf_p
); /* cast for 8-bit char's */
1645 *(yy_c_buf_p
) = '\0'; /* preserve yytext */
1646 (yy_hold_char
) = *++(yy_c_buf_p
);
1648 YY_CURRENT_BUFFER_LVALUE
->yy_at_bol
= (c
== '\n');
1652 #endif /* ifndef YY_NO_INPUT */
1654 /** Immediately switch to a different input stream.
1655 * @param input_file A readable stream.
1657 * @note This function does not reset the start condition to @c INITIAL .
1659 void yyrestart (FILE * input_file
)
1662 if ( ! YY_CURRENT_BUFFER
){
1663 yyensure_buffer_stack ();
1664 YY_CURRENT_BUFFER_LVALUE
=
1665 yy_create_buffer(yyin
,YY_BUF_SIZE
);
1668 yy_init_buffer(YY_CURRENT_BUFFER
,input_file
);
1669 yy_load_buffer_state( );
1672 /** Switch to a different input buffer.
1673 * @param new_buffer The new input buffer.
1676 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer
)
1679 /* TODO. We should be able to replace this entire function body
1681 * yypop_buffer_state();
1682 * yypush_buffer_state(new_buffer);
1684 yyensure_buffer_stack ();
1685 if ( YY_CURRENT_BUFFER
== new_buffer
)
1688 if ( YY_CURRENT_BUFFER
)
1690 /* Flush out information for old buffer. */
1691 *(yy_c_buf_p
) = (yy_hold_char
);
1692 YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
= (yy_c_buf_p
);
1693 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= (yy_n_chars
);
1696 YY_CURRENT_BUFFER_LVALUE
= new_buffer
;
1697 yy_load_buffer_state( );
1699 /* We don't actually know whether we did this switch during
1700 * EOF (yywrap()) processing, but the only time this flag
1701 * is looked at is after yywrap() is called, so it's safe
1702 * to go ahead and always set it.
1704 (yy_did_buffer_switch_on_eof
) = 1;
1707 static void yy_load_buffer_state (void)
1709 (yy_n_chars
) = YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
;
1710 (yytext_ptr
) = (yy_c_buf_p
) = YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
;
1711 yyin
= YY_CURRENT_BUFFER_LVALUE
->yy_input_file
;
1712 (yy_hold_char
) = *(yy_c_buf_p
);
1715 /** Allocate and initialize an input buffer state.
1716 * @param file A readable stream.
1717 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1719 * @return the allocated buffer state.
1721 YY_BUFFER_STATE
yy_create_buffer (FILE * file
, int size
)
1725 b
= (YY_BUFFER_STATE
) yyalloc(sizeof( struct yy_buffer_state
) );
1727 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1729 b
->yy_buf_size
= size
;
1731 /* yy_ch_buf has to be 2 characters longer than the size given because
1732 * we need to put in 2 end-of-buffer characters.
1734 b
->yy_ch_buf
= (char *) yyalloc(b
->yy_buf_size
+ 2 );
1735 if ( ! b
->yy_ch_buf
)
1736 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1738 b
->yy_is_our_buffer
= 1;
1740 yy_init_buffer(b
,file
);
1745 /** Destroy the buffer.
1746 * @param b a buffer created with yy_create_buffer()
1749 void yy_delete_buffer (YY_BUFFER_STATE b
)
1755 if ( b
== YY_CURRENT_BUFFER
) /* Not sure if we should pop here. */
1756 YY_CURRENT_BUFFER_LVALUE
= (YY_BUFFER_STATE
) 0;
1758 if ( b
->yy_is_our_buffer
)
1759 yyfree((void *) b
->yy_ch_buf
);
1761 yyfree((void *) b
);
1764 #ifndef _UNISTD_H /* assume unistd.h has isatty() for us */
1768 #ifdef __THROW /* this is a gnuism */
1769 extern int isatty (int ) __THROW
;
1771 extern int isatty (int );
1778 /* Initializes or reinitializes a buffer.
1779 * This function is sometimes called more than once on the same buffer,
1780 * such as during a yyrestart() or at EOF.
1782 static void yy_init_buffer (YY_BUFFER_STATE b
, FILE * file
)
1787 yy_flush_buffer(b
);
1789 b
->yy_input_file
= file
;
1790 b
->yy_fill_buffer
= 1;
1792 /* If b is the current buffer, then yy_init_buffer was _probably_
1793 * called from yyrestart() or through yy_get_next_buffer.
1794 * In that case, we don't want to reset the lineno or column.
1796 if (b
!= YY_CURRENT_BUFFER
){
1797 b
->yy_bs_lineno
= 1;
1798 b
->yy_bs_column
= 0;
1801 b
->yy_is_interactive
= file
? (isatty( fileno(file
) ) > 0) : 0;
1806 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1807 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1810 void yy_flush_buffer (YY_BUFFER_STATE b
)
1817 /* We always need two end-of-buffer characters. The first causes
1818 * a transition to the end-of-buffer state. The second causes
1819 * a jam in that state.
1821 b
->yy_ch_buf
[0] = YY_END_OF_BUFFER_CHAR
;
1822 b
->yy_ch_buf
[1] = YY_END_OF_BUFFER_CHAR
;
1824 b
->yy_buf_pos
= &b
->yy_ch_buf
[0];
1827 b
->yy_buffer_status
= YY_BUFFER_NEW
;
1829 if ( b
== YY_CURRENT_BUFFER
)
1830 yy_load_buffer_state( );
1833 /** Pushes the new state onto the stack. The new state becomes
1834 * the current state. This function will allocate the stack
1836 * @param new_buffer The new state.
1839 void yypush_buffer_state (YY_BUFFER_STATE new_buffer
)
1841 if (new_buffer
== NULL
)
1844 yyensure_buffer_stack();
1846 /* This block is copied from yy_switch_to_buffer. */
1847 if ( YY_CURRENT_BUFFER
)
1849 /* Flush out information for old buffer. */
1850 *(yy_c_buf_p
) = (yy_hold_char
);
1851 YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
= (yy_c_buf_p
);
1852 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= (yy_n_chars
);
1855 /* Only push if top exists. Otherwise, replace top. */
1856 if (YY_CURRENT_BUFFER
)
1857 (yy_buffer_stack_top
)++;
1858 YY_CURRENT_BUFFER_LVALUE
= new_buffer
;
1860 /* copied from yy_switch_to_buffer. */
1861 yy_load_buffer_state( );
1862 (yy_did_buffer_switch_on_eof
) = 1;
1865 /** Removes and deletes the top of the stack, if present.
1866 * The next element becomes the new top.
1869 void yypop_buffer_state (void)
1871 if (!YY_CURRENT_BUFFER
)
1874 yy_delete_buffer(YY_CURRENT_BUFFER
);
1875 YY_CURRENT_BUFFER_LVALUE
= NULL
;
1876 if ((yy_buffer_stack_top
) > 0)
1877 --(yy_buffer_stack_top
);
1879 if (YY_CURRENT_BUFFER
) {
1880 yy_load_buffer_state( );
1881 (yy_did_buffer_switch_on_eof
) = 1;
1885 /* Allocates the stack if it does not exist.
1886 * Guarantees space for at least one push.
1888 static void yyensure_buffer_stack (void)
1892 if (!(yy_buffer_stack
)) {
1894 /* First allocation is just for 2 elements, since we don't know if this
1895 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1896 * immediate realloc on the next call.
1899 (yy_buffer_stack
) = (struct yy_buffer_state
**)yyalloc
1900 (num_to_alloc
* sizeof(struct yy_buffer_state
*)
1902 if ( ! (yy_buffer_stack
) )
1903 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1905 memset((yy_buffer_stack
), 0, num_to_alloc
* sizeof(struct yy_buffer_state
*));
1907 (yy_buffer_stack_max
) = num_to_alloc
;
1908 (yy_buffer_stack_top
) = 0;
1912 if ((yy_buffer_stack_top
) >= ((yy_buffer_stack_max
)) - 1){
1914 /* Increase the buffer to prepare for a possible push. */
1915 int grow_size
= 8 /* arbitrary grow size */;
1917 num_to_alloc
= (yy_buffer_stack_max
) + grow_size
;
1918 (yy_buffer_stack
) = (struct yy_buffer_state
**)yyrealloc
1920 num_to_alloc
* sizeof(struct yy_buffer_state
*)
1922 if ( ! (yy_buffer_stack
) )
1923 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1925 /* zero only the new slots.*/
1926 memset((yy_buffer_stack
) + (yy_buffer_stack_max
), 0, grow_size
* sizeof(struct yy_buffer_state
*));
1927 (yy_buffer_stack_max
) = num_to_alloc
;
1931 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1932 * @param base the character buffer
1933 * @param size the size in bytes of the character buffer
1935 * @return the newly allocated buffer state object.
1937 YY_BUFFER_STATE
yy_scan_buffer (char * base
, yy_size_t size
)
1942 base
[size
-2] != YY_END_OF_BUFFER_CHAR
||
1943 base
[size
-1] != YY_END_OF_BUFFER_CHAR
)
1944 /* They forgot to leave room for the EOB's. */
1947 b
= (YY_BUFFER_STATE
) yyalloc(sizeof( struct yy_buffer_state
) );
1949 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1951 b
->yy_buf_size
= size
- 2; /* "- 2" to take care of EOB's */
1952 b
->yy_buf_pos
= b
->yy_ch_buf
= base
;
1953 b
->yy_is_our_buffer
= 0;
1954 b
->yy_input_file
= 0;
1955 b
->yy_n_chars
= b
->yy_buf_size
;
1956 b
->yy_is_interactive
= 0;
1958 b
->yy_fill_buffer
= 0;
1959 b
->yy_buffer_status
= YY_BUFFER_NEW
;
1961 yy_switch_to_buffer(b
);
1966 /** Setup the input buffer state to scan a string. The next call to yylex() will
1967 * scan from a @e copy of @a str.
1968 * @param yystr a NUL-terminated string to scan
1970 * @return the newly allocated buffer state object.
1971 * @note If you want to scan bytes that may contain NUL values, then use
1972 * yy_scan_bytes() instead.
1974 YY_BUFFER_STATE
yy_scan_string (yyconst
char * yystr
)
1977 return yy_scan_bytes(yystr
,strlen(yystr
) );
1980 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1981 * scan from a @e copy of @a bytes.
1982 * @param bytes the byte buffer to scan
1983 * @param len the number of bytes in the buffer pointed to by @a bytes.
1985 * @return the newly allocated buffer state object.
1987 YY_BUFFER_STATE
yy_scan_bytes (yyconst
char * yybytes
, int _yybytes_len
)
1994 /* Get memory for full buffer, including space for trailing EOB's. */
1995 n
= _yybytes_len
+ 2;
1996 buf
= (char *) yyalloc(n
);
1998 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2000 for ( i
= 0; i
< _yybytes_len
; ++i
)
2001 buf
[i
] = yybytes
[i
];
2003 buf
[_yybytes_len
] = buf
[_yybytes_len
+1] = YY_END_OF_BUFFER_CHAR
;
2005 b
= yy_scan_buffer(buf
,n
);
2007 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2009 /* It's okay to grow etc. this buffer, and we should throw it
2010 * away when we're done.
2012 b
->yy_is_our_buffer
= 1;
2017 #ifndef YY_EXIT_FAILURE
2018 #define YY_EXIT_FAILURE 2
2021 static void yy_fatal_error (yyconst
char* msg
)
2023 (void) fprintf( stderr
, "%s\n", msg
);
2024 exit( YY_EXIT_FAILURE
);
2027 /* Redefine yyless() so it works in section 3 code. */
2033 /* Undo effects of setting up yytext. */ \
2034 int yyless_macro_arg = (n); \
2035 YY_LESS_LINENO(yyless_macro_arg);\
2036 yytext[yyleng] = (yy_hold_char); \
2037 (yy_c_buf_p) = yytext + yyless_macro_arg; \
2038 (yy_hold_char) = *(yy_c_buf_p); \
2039 *(yy_c_buf_p) = '\0'; \
2040 yyleng = yyless_macro_arg; \
2044 /* Accessor methods (get/set functions) to struct members. */
2046 /** Get the current line number.
2049 int yyget_lineno (void)
2055 /** Get the input stream.
2058 FILE *yyget_in (void)
2063 /** Get the output stream.
2066 FILE *yyget_out (void)
2071 /** Get the length of the current token.
2074 int yyget_leng (void)
2079 /** Get the current token.
2083 char *yyget_text (void)
2088 /** Set the current line number.
2089 * @param line_number
2092 void yyset_lineno (int line_number
)
2095 yylineno
= line_number
;
2098 /** Set the input stream. This does not discard the current
2100 * @param in_str A readable stream.
2102 * @see yy_switch_to_buffer
2104 void yyset_in (FILE * in_str
)
2109 void yyset_out (FILE * out_str
)
2114 int yyget_debug (void)
2116 return yy_flex_debug
;
2119 void yyset_debug (int bdebug
)
2121 yy_flex_debug
= bdebug
;
2124 static int yy_init_globals (void)
2126 /* Initialization is the same as for the non-reentrant scanner.
2127 * This function is called from yylex_destroy(), so don't allocate here.
2130 (yy_buffer_stack
) = 0;
2131 (yy_buffer_stack_top
) = 0;
2132 (yy_buffer_stack_max
) = 0;
2133 (yy_c_buf_p
) = (char *) 0;
2137 /* Defined in main.c */
2146 /* For future reference: Set errno on error, since we are called by
2152 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
2153 int yylex_destroy (void)
2156 /* Pop the buffer stack, destroying each element. */
2157 while(YY_CURRENT_BUFFER
){
2158 yy_delete_buffer(YY_CURRENT_BUFFER
);
2159 YY_CURRENT_BUFFER_LVALUE
= NULL
;
2160 yypop_buffer_state();
2163 /* Destroy the stack itself. */
2164 yyfree((yy_buffer_stack
) );
2165 (yy_buffer_stack
) = NULL
;
2167 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2168 * yylex() is called, initialization will occur. */
2175 * Internal utility routines.
2179 static void yy_flex_strncpy (char* s1
, yyconst
char * s2
, int n
)
2182 for ( i
= 0; i
< n
; ++i
)
2187 #ifdef YY_NEED_STRLEN
2188 static int yy_flex_strlen (yyconst
char * s
)
2191 for ( n
= 0; s
[n
]; ++n
)
2198 void *yyalloc (yy_size_t size
)
2200 return (void *) malloc( size
);
2203 void *yyrealloc (void * ptr
, yy_size_t size
)
2205 /* The cast to (char *) in the following accommodates both
2206 * implementations that use char* generic pointers, and those
2207 * that use void* generic pointers. It works with the latter
2208 * because both ANSI C and C++ allow castless assignment from
2209 * any pointer type to void*, and deal with argument conversions
2210 * as though doing an assignment.
2212 return (void *) realloc( (char *) ptr
, size
);
2215 void yyfree (void * ptr
)
2217 free( (char *) ptr
); /* see yyrealloc() for (char *) cast */
2220 #define YYTABLES_NAME "yytables"
2222 #line 270 "parser.lex"
2231 void freeTokens(struct token_t
*file
)
2233 mem_clear(&strings
);
2237 struct token_t
* generateTokens(char*filename
)
2241 struct token_t
*result
;
2247 if(!strcmp(filename
,"-"))
2250 fi
= fopen(filename
, "rb");
2253 printf("Couldn't find file %s\n", filename
);
2260 mem_put(&strings
, &t
, 1); //hack- make all valid strings start at position >0
2266 #ifdef YY_CURRENT_BUFFER
2267 // some newer flex versions require it like this:
2268 yy_delete_buffer(YY_CURRENT_BUFFER
);
2270 yy_delete_buffer(yy_current_buffer
);
2273 result
= (struct token_t
*)tokens
.buffer
;
2274 num
= tokens
.pos
/sizeof(struct token_t
);
2276 for(t
=0;t
<tokens
.pos
/sizeof(struct token_t
);t
++) {
2277 if(result
[t
].text_pos
) {
2278 result
[t
].text
= &strings
.buffer
[result
[t
].text_pos
];