diff options
Diffstat (limited to 'LuaSL/src/LuaSL_lexer.l')
-rw-r--r-- | LuaSL/src/LuaSL_lexer.l | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/LuaSL/src/LuaSL_lexer.l b/LuaSL/src/LuaSL_lexer.l index 8e5e4ca..15cfae2 100644 --- a/LuaSL/src/LuaSL_lexer.l +++ b/LuaSL/src/LuaSL_lexer.l | |||
@@ -3,7 +3,7 @@ | |||
3 | #define excludeLexer | 3 | #define excludeLexer |
4 | #include "LuaSL_LSL_tree.h" | 4 | #include "LuaSL_LSL_tree.h" |
5 | 5 | ||
6 | int common(YYSTYPE *lval, char *text, LuaSL_yyparseExtra *extra, boolean checkIgnorable, int type); | 6 | int common(YYSTYPE *lval, char *text, LuaSL_yyparseParam *param, boolean checkIgnorable, int type); |
7 | 7 | ||
8 | %} | 8 | %} |
9 | 9 | ||
@@ -12,7 +12,7 @@ int common(YYSTYPE *lval, char *text, LuaSL_yyparseExtra *extra, boolean checkIg | |||
12 | %option noreject noyymore | 12 | %option noreject noyymore |
13 | %option backup debug perf-report perf-report verbose warn | 13 | %option backup debug perf-report perf-report verbose warn |
14 | %option align full | 14 | %option align full |
15 | %option extra-type="LuaSL_yyparseExtra *" | 15 | %option extra-type="LuaSL_yyparseParam *" |
16 | 16 | ||
17 | HEX [[:xdigit:]] | 17 | HEX [[:xdigit:]] |
18 | DECIMAL [[:digit:]] | 18 | DECIMAL [[:digit:]] |
@@ -110,54 +110,49 @@ IDENTIFIER [[:alpha:]](_|[[:alpha:]]|[[:digit:]])* | |||
110 | 110 | ||
111 | %% | 111 | %% |
112 | 112 | ||
113 | int common(YYSTYPE *lval, char *text, LuaSL_yyparseExtra *extra, boolean checkIgnorable, int type) | 113 | int common(YYSTYPE *lval, char *text, LuaSL_yyparseParam *param, boolean checkIgnorable, int type) |
114 | { | 114 | { |
115 | int i; | 115 | int i; |
116 | 116 | ||
117 | for (i = 0; text[i] != '\0'; i++) | 117 | for (i = 0; text[i] != '\0'; i++) |
118 | if (text[i] == '\n') | 118 | if (text[i] == '\n') |
119 | { | 119 | { |
120 | extra->column = 0; | 120 | param->column = 0; |
121 | extra->line++; | 121 | param->line++; |
122 | } | 122 | } |
123 | else if (text[i] == '\t') | 123 | else if (text[i] == '\t') |
124 | extra->column += 8 - (extra->column % 8); | 124 | param->column += 8 - (param->column % 8); |
125 | else | 125 | else |
126 | extra->column++; | 126 | param->column++; |
127 | 127 | ||
128 | lval->token = tokens[type - lowestToken]; | 128 | lval->token = tokens[type - lowestToken]; |
129 | lval->line = extra->line; | 129 | lval->line = param->line; |
130 | lval->column = extra->column; | 130 | lval->column = param->column; |
131 | 131 | ||
132 | if (checkIgnorable) | 132 | if (checkIgnorable) |
133 | { | 133 | { |
134 | lval->ignorableText = extra->ignorableText; | 134 | lval->ignorableText = param->ignorableText; |
135 | extra->ignorableText = NULL; | 135 | param->ignorableText = NULL; |
136 | } | 136 | } |
137 | else | 137 | else |
138 | { | 138 | { |
139 | if (extra->ignorableText) | 139 | if (param->ignorableText) |
140 | { | 140 | { |
141 | int lenI = strlen(extra->ignorableText); | 141 | int lenI = strlen(param->ignorableText); |
142 | int lenT = strlen(text); | 142 | int lenT = strlen(text); |
143 | 143 | ||
144 | extra->ignorableText = realloc(extra->ignorableText, lenI + lenT + 1); | 144 | param->ignorableText = realloc(param->ignorableText, lenI + lenT + 1); |
145 | sprintf(&(extra->ignorableText[lenI]), "%s", text); | 145 | sprintf(&(param->ignorableText[lenI]), "%s", text); |
146 | } | 146 | } |
147 | else | 147 | else |
148 | extra->ignorableText = strdup(text); | 148 | param->ignorableText = strdup(text); |
149 | } | 149 | } |
150 | 150 | ||
151 | return type; | 151 | return type; |
152 | } | 152 | } |
153 | 153 | ||
154 | int yywrap(yyscan_t yyscanner) | 154 | int yywrap(yyscan_t yyscanner) // This as actually useless for our needs, as it is called BEFORE the last token is dealt with. |
155 | { | 155 | { |
156 | #ifdef LUASL_FILES | ||
157 | LuaSL_yyparseExtra *extra = yyget_extra(yyscanner); | ||
158 | #endif | ||
159 | int result = 1; | ||
160 | |||
161 | #ifdef FLEX_SCANNER | 156 | #ifdef FLEX_SCANNER |
162 | #ifndef LL_WINDOWS | 157 | #ifndef LL_WINDOWS |
163 | // Get gcc to stop complaining about lack of use of yyunput and input. | 158 | // Get gcc to stop complaining about lack of use of yyunput and input. |
@@ -166,11 +161,6 @@ int yywrap(yyscan_t yyscanner) | |||
166 | #endif | 161 | #endif |
167 | #endif | 162 | #endif |
168 | 163 | ||
169 | #ifdef LUASL_FILES | 164 | return 1; |
170 | result = nextFile(extra); | ||
171 | if (0 == result) | ||
172 | yyset_in(extra->file, yyscanner); | ||
173 | #endif | ||
174 | return result; | ||
175 | } | 165 | } |
176 | 166 | ||