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