bool 1.0.1 → 1.0.2

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