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