diff options
author | David Walter Seikel | 2012-01-17 12:36:03 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-17 12:36:03 +1000 |
commit | d3541b3ac5f56ba399fd8bcd155b9e0120cf9916 (patch) | |
tree | 82d5bf84550aea4dbf33f0a63c8180b18fb005d3 /LuaSL/src/LuaSL_LSL_lexer.l | |
parent | Better error message. (diff) | |
download | SledjHamr-d3541b3ac5f56ba399fd8bcd155b9e0120cf9916.zip SledjHamr-d3541b3ac5f56ba399fd8bcd155b9e0120cf9916.tar.gz SledjHamr-d3541b3ac5f56ba399fd8bcd155b9e0120cf9916.tar.bz2 SledjHamr-d3541b3ac5f56ba399fd8bcd155b9e0120cf9916.tar.xz |
Merge the compiler into the test harness. Remove excess files.
Diffstat (limited to 'LuaSL/src/LuaSL_LSL_lexer.l')
-rw-r--r-- | LuaSL/src/LuaSL_LSL_lexer.l | 281 |
1 files changed, 0 insertions, 281 deletions
diff --git a/LuaSL/src/LuaSL_LSL_lexer.l b/LuaSL/src/LuaSL_LSL_lexer.l deleted file mode 100644 index 473a427..0000000 --- a/LuaSL/src/LuaSL_LSL_lexer.l +++ /dev/null | |||
@@ -1,281 +0,0 @@ | |||
1 | |||
2 | N [0-9] | ||
3 | L [a-zA-Z_] | ||
4 | H [a-fA-F0-9] | ||
5 | E [Ee][+-]?{N}+ | ||
6 | FS (f|F) | ||
7 | %e 10000 | ||
8 | %n 4000 | ||
9 | %p 5000 | ||
10 | |||
11 | %{ | ||
12 | |||
13 | #define excludeLexer | ||
14 | #include "LuaSL_LSL_tree.h" | ||
15 | #include "LuaSL_LSLS_yaccer.tab.h" | ||
16 | |||
17 | |||
18 | // Deal with the fact that lex/yacc generates unreachable code | ||
19 | #ifdef LL_WINDOWS | ||
20 | #pragma warning (disable : 4018) // warning C4018: signed/unsigned mismatch | ||
21 | #pragma warning (disable : 4702) // warning C4702: unreachable code | ||
22 | #endif // LL_WINDOWS | ||
23 | |||
24 | void count(); | ||
25 | void line_comment(); | ||
26 | void block_comment(); | ||
27 | void parse_string(); | ||
28 | |||
29 | #define YYLMAX 16384 | ||
30 | #define YY_NEVER_INTERACTIVE 1 /* stops flex from calling isatty() */ | ||
31 | #ifdef LL_WINDOWS | ||
32 | #define isatty(x) 0 /* hack for bug in cygwin flex 2.5.35 */ | ||
33 | #endif | ||
34 | |||
35 | #ifdef ECHO | ||
36 | #undef ECHO | ||
37 | #endif | ||
38 | |||
39 | #define ECHO do { } while (0) | ||
40 | |||
41 | %} | ||
42 | |||
43 | %option reentrant noyywrap never-interactive nounistd | ||
44 | %option bison-bridge | ||
45 | |||
46 | %% | ||
47 | "//" { gInternalLine++; gInternalColumn = 0; line_comment(); } | ||
48 | "/*" { block_comment(); } | ||
49 | |||
50 | "integer" { count(); return(INTEGER); } | ||
51 | "float" { count(); return(FLOAT_TYPE); } | ||
52 | "string" { count(); return(STRING); } | ||
53 | "key" { count(); return(LLKEY); } | ||
54 | "vector" { count(); return(VECTOR); } | ||
55 | "quaternion" { count(); return(QUATERNION); } | ||
56 | "rotation" { count(); return(QUATERNION); } | ||
57 | "list" { count(); return(LIST); } | ||
58 | |||
59 | "default" { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(STATE_DEFAULT); } | ||
60 | "state" { count(); return(STATE); } | ||
61 | "event" { count(); return(EVENT); } | ||
62 | "jump" { count(); return(JUMP); } | ||
63 | "return" { count(); return(RETURN); } | ||
64 | "if" { count(); return(IF); } | ||
65 | "else" { count(); return(ELSE); } | ||
66 | "for" { count(); return(FOR); } | ||
67 | "do" { count(); return(DO); } | ||
68 | "while" { count(); return(WHILE); } | ||
69 | |||
70 | "state_entry" { count(); return(STATE_ENTRY); } | ||
71 | "state_exit" { count(); return(STATE_EXIT); } | ||
72 | "touch_start" { count(); return(TOUCH_START); } | ||
73 | "touch" { count(); return(TOUCH); } | ||
74 | "touch_end" { count(); return(TOUCH_END); } | ||
75 | "collision_start" { count(); return(COLLISION_START); } | ||
76 | "collision" { count(); return(COLLISION); } | ||
77 | "collision_end" { count(); return(COLLISION_END); } | ||
78 | "land_collision_start" { count(); return(LAND_COLLISION_START); } | ||
79 | "land_collision" { count(); return(LAND_COLLISION); } | ||
80 | "land_collision_end" { count(); return(LAND_COLLISION_END); } | ||
81 | "timer" { count(); return(TIMER); } | ||
82 | "listen" { count(); return(CHAT); } | ||
83 | "sensor" { count(); return(SENSOR); } | ||
84 | "no_sensor" { count(); return(NO_SENSOR); } | ||
85 | "control" { count(); return(CONTROL); } | ||
86 | "print" { count(); return(PRINT); } | ||
87 | "at_target" { count(); return(AT_TARGET); } | ||
88 | "not_at_target" { count(); return(NOT_AT_TARGET); } | ||
89 | "at_rot_target" { count(); return(AT_ROT_TARGET); } | ||
90 | "not_at_rot_target" { count(); return(NOT_AT_ROT_TARGET); } | ||
91 | "money" { count(); return(MONEY); } | ||
92 | "email" { count(); return(EMAIL); } | ||
93 | "run_time_permissions" { count(); return(RUN_TIME_PERMISSIONS); } | ||
94 | "changed" { count(); return(INVENTORY); } | ||
95 | "attach" { count(); return(ATTACH); } | ||
96 | "dataserver" { count(); return(DATASERVER); } | ||
97 | "moving_start" { count(); return(MOVING_START); } | ||
98 | "moving_end" { count(); return(MOVING_END); } | ||
99 | "link_message" { count(); return(LINK_MESSAGE); } | ||
100 | "on_rez" { count(); return(REZ); } | ||
101 | "object_rez" { count(); return(OBJECT_REZ); } | ||
102 | "remote_data" { count(); return(REMOTE_DATA); } | ||
103 | "http_response" { count(); return(HTTP_RESPONSE); } | ||
104 | "http_request" { count(); return(HTTP_REQUEST); } | ||
105 | "." { count(); return(PERIOD); } | ||
106 | |||
107 | 0[xX]{H}+ { count(); yylval.ival = strtoul(yytext, NULL, 0); return(INTEGER_CONSTANT); } | ||
108 | {N}+ { count(); yylval.ival = strtoul(yytext, NULL, 10); return(INTEGER_CONSTANT); } | ||
109 | "TRUE" { count(); yylval.ival = 1; return(INTEGER_TRUE); } | ||
110 | "FALSE" { count(); yylval.ival = 0; return(INTEGER_FALSE); } | ||
111 | |||
112 | "TOUCH_INVALID_FACE" { count(); yylval.ival = -1; return(INTEGER_CONSTANT); } | ||
113 | "TOUCH_INVALID_VECTOR" { count(); return(TOUCH_INVALID_VECTOR); } | ||
114 | "TOUCH_INVALID_TEXCOORD" { count(); return(TOUCH_INVALID_TEXCOORD); } | ||
115 | |||
116 | {L}({L}|{N})* { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(IDENTIFIER); } | ||
117 | |||
118 | {N}+{E} { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } | ||
119 | {N}*"."{N}+({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } | ||
120 | {N}+"."{N}*({E})?{FS}? { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } | ||
121 | |||
122 | L?\"(\\.|[^\\"])*\" { parse_string(); count(); return(STRING_CONSTANT); } | ||
123 | |||
124 | "++" { count(); return(INC_OP); } | ||
125 | "--" { count(); return(DEC_OP); } | ||
126 | "+=" { count(); return(ADD_ASSIGN); } | ||
127 | "-=" { count(); return(SUB_ASSIGN); } | ||
128 | "*=" { count(); return(MUL_ASSIGN); } | ||
129 | "/=" { count(); return(DIV_ASSIGN); } | ||
130 | "%=" { count(); return(MOD_ASSIGN); } | ||
131 | ";" { count(); return(';'); } | ||
132 | "{" { count(); return('{'); } | ||
133 | "}" { count(); return('}'); } | ||
134 | "," { count(); return(','); } | ||
135 | "=" { count(); return('='); } | ||
136 | "(" { count(); return('('); } | ||
137 | ")" { count(); return(')'); } | ||
138 | "-" { count(); return('-'); } | ||
139 | "+" { count(); return('+'); } | ||
140 | "*" { count(); return('*'); } | ||
141 | "/" { count(); return('/'); } | ||
142 | "%" { count(); return('%'); } | ||
143 | "@" { count(); return('@'); } | ||
144 | ":" { count(); return(':'); } | ||
145 | ">" { count(); return('>'); } | ||
146 | "<" { count(); return('<'); } | ||
147 | "]" { count(); return(']'); } | ||
148 | "[" { count(); return('['); } | ||
149 | "==" { count(); return(EQ); } | ||
150 | "!=" { count(); return(NEQ); } | ||
151 | ">=" { count(); return(GEQ); } | ||
152 | "<=" { count(); return(LEQ); } | ||
153 | "&" { count(); return('&'); } | ||
154 | "|" { count(); return('|'); } | ||
155 | "^" { count(); return('^'); } | ||
156 | "~" { count(); return('~'); } | ||
157 | "!" { count(); return('!'); } | ||
158 | "&&" { count(); return(BOOLEAN_AND); } | ||
159 | "||" { count(); return(BOOLEAN_OR); } | ||
160 | "<<" { count(); return(SHIFT_LEFT); } | ||
161 | ">>" { count(); return(SHIFT_RIGHT); } | ||
162 | |||
163 | [ \t\v\n\f] { count(); } | ||
164 | . { /* ignore bad characters */ } | ||
165 | |||
166 | %% | ||
167 | |||
168 | |||
169 | // Prototype for the yacc parser entry point | ||
170 | int yyparse(void); | ||
171 | |||
172 | |||
173 | S32 yywrap() | ||
174 | { | ||
175 | #if defined(FLEX_SCANNER) && !defined(LL_WINDOWS) | ||
176 | // get gcc to stop complaining about lack of use of yyunput | ||
177 | (void) yyunput; | ||
178 | #endif | ||
179 | return(1); | ||
180 | } | ||
181 | |||
182 | void line_comment() | ||
183 | { | ||
184 | char c; | ||
185 | |||
186 | while ((c = yyinput()) != '\n' && c != 0 && c != EOF) | ||
187 | ; | ||
188 | } | ||
189 | |||
190 | void block_comment() | ||
191 | { | ||
192 | char c1 = 0; | ||
193 | char c2 = yyinput(); | ||
194 | while (c2 != 0 && c2 != EOF && !(c1 == '*' && c2 == '/')) { | ||
195 | if (c2 == '\n') | ||
196 | { | ||
197 | gInternalLine++; | ||
198 | gInternalColumn = 0; | ||
199 | } | ||
200 | else if (c2 == '\t') | ||
201 | gInternalColumn += 4 - (gInternalColumn % 8); | ||
202 | else | ||
203 | gInternalColumn++; | ||
204 | c1 = c2; | ||
205 | c2 = yyinput(); | ||
206 | } | ||
207 | } | ||
208 | |||
209 | void count() | ||
210 | { | ||
211 | S32 i; | ||
212 | |||
213 | gColumn = gInternalColumn; | ||
214 | gLine = gInternalLine; | ||
215 | |||
216 | for (i = 0; yytext[i] != '\0'; i++) | ||
217 | if (yytext[i] == '\n') | ||
218 | { | ||
219 | gInternalLine++; | ||
220 | gInternalColumn = 0; | ||
221 | } | ||
222 | else if (yytext[i] == '\t') | ||
223 | gInternalColumn += 4 - (gInternalColumn % 8); | ||
224 | else | ||
225 | gInternalColumn++; | ||
226 | } | ||
227 | |||
228 | void parse_string() | ||
229 | { | ||
230 | S32 length = (S32)strlen(yytext); | ||
231 | length = length - 2; | ||
232 | char *temp = yytext + 1; | ||
233 | |||
234 | S32 i; | ||
235 | S32 escapes = 0; | ||
236 | S32 tabs = 0; | ||
237 | for (i = 0; i < length; i++) | ||
238 | { | ||
239 | if (temp[i] == '\\') | ||
240 | { | ||
241 | escapes++; | ||
242 | i++; | ||
243 | if (temp[i] == 't') | ||
244 | tabs++; | ||
245 | } | ||
246 | } | ||
247 | |||
248 | S32 newlength = length - escapes + tabs*3; | ||
249 | yylval.sval = new char[newlength + 1]; | ||
250 | |||
251 | char *dest = yylval.sval; | ||
252 | |||
253 | for (i = 0; i < length; i++) | ||
254 | { | ||
255 | if (temp[i] == '\\') | ||
256 | { | ||
257 | i++; | ||
258 | // linefeed | ||
259 | if (temp[i] == 'n') | ||
260 | { | ||
261 | *dest++ = 10; | ||
262 | } | ||
263 | else if (temp[i] == 't') | ||
264 | { | ||
265 | *dest++ = ' '; | ||
266 | *dest++ = ' '; | ||
267 | *dest++ = ' '; | ||
268 | *dest++ = ' '; | ||
269 | } | ||
270 | else | ||
271 | { | ||
272 | *dest++ = temp[i]; | ||
273 | } | ||
274 | } | ||
275 | else | ||
276 | { | ||
277 | *dest++ = temp[i]; | ||
278 | } | ||
279 | } | ||
280 | yylval.sval[newlength] = 0; | ||
281 | } | ||