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