OLD | NEW |
1 %{ | 1 %{ |
2 /* | 2 /* |
3 * Copyright © 2008, 2009 Intel Corporation | 3 * Copyright © 2008, 2009 Intel Corporation |
4 * | 4 * |
5 * Permission is hereby granted, free of charge, to any person obtaining a | 5 * Permission is hereby granted, free of charge, to any person obtaining a |
6 * copy of this software and associated documentation files (the "Software"), | 6 * copy of this software and associated documentation files (the "Software"), |
7 * to deal in the Software without restriction, including without limitation | 7 * to deal in the Software without restriction, including without limitation |
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
9 * and/or sell copies of the Software, and to permit persons to whom the | 9 * and/or sell copies of the Software, and to permit persons to whom the |
10 * Software is furnished to do so, subject to the following conditions: | 10 * Software is furnished to do so, subject to the following conditions: |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 */ | 59 */ |
60 #define KEYWORD(reserved_version, allowed_version, token) \ | 60 #define KEYWORD(reserved_version, allowed_version, token) \ |
61 do { \ | 61 do { \ |
62 if (yyextra->language_version >= allowed_version) { \ | 62 if (yyextra->language_version >= allowed_version) { \ |
63 return token; \ | 63 return token; \ |
64 } else if (yyextra->language_version >= reserved_version) { \ | 64 } else if (yyextra->language_version >= reserved_version) { \ |
65 _mesa_glsl_error(yylloc, yyextra, \ | 65 _mesa_glsl_error(yylloc, yyextra, \ |
66 "Illegal use of reserved word `%s'", yytext); \ | 66 "Illegal use of reserved word `%s'", yytext); \ |
67 return ERROR_TOK; \ | 67 return ERROR_TOK; \ |
68 } else { \ | 68 } else { \ |
69 » yylval->identifier = strdup(yytext);» » » » \ | 69 » void *mem_ctx = yyextra;» » » » » \ |
| 70 » yylval->identifier = ralloc_strdup(mem_ctx, yytext);» » \ |
70 return classify_identifier(yyextra, yytext); \ | 71 return classify_identifier(yyextra, yytext); \ |
71 } \ | 72 } \ |
72 } while (0) | 73 } while (0) |
73 | 74 |
74 /* The ES macro can be used in KEYWORD checks: | 75 /* The ES macro can be used in KEYWORD checks: |
75 * | 76 * |
76 * word KEYWORD(110 || ES, 400, TOKEN) | 77 * word KEYWORD(110 || ES, 400, TOKEN) |
77 * ...means the word is reserved in GLSL ES 1.00, while | 78 * ...means the word is reserved in GLSL ES 1.00, while |
78 * | 79 * |
79 * word KEYWORD(110, 130 || ES, TOKEN) | 80 * word KEYWORD(110, 130 || ES, TOKEN) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 202 } |
202 ^{SPC}#{SPC}pragma{SPCP} { BEGIN PRAGMA; } | 203 ^{SPC}#{SPC}pragma{SPCP} { BEGIN PRAGMA; } |
203 | 204 |
204 <PRAGMA>\n { BEGIN 0; yylineno++; yycolumn = 0; } | 205 <PRAGMA>\n { BEGIN 0; yylineno++; yycolumn = 0; } |
205 <PRAGMA>. { } | 206 <PRAGMA>. { } |
206 | 207 |
207 <PP>\/\/[^\n]* { } | 208 <PP>\/\/[^\n]* { } |
208 <PP>[ \t\r]* { } | 209 <PP>[ \t\r]* { } |
209 <PP>: return COLON; | 210 <PP>: return COLON; |
210 <PP>[_a-zA-Z][_a-zA-Z0-9]* { | 211 <PP>[_a-zA-Z][_a-zA-Z0-9]* { |
211 » » » » yylval->identifier = strdup(yytext); | 212 » » » » void *mem_ctx = yyextra; |
| 213 » » » » yylval->identifier = ralloc_strdup(mem_ctx, y
ytext); |
212 return IDENTIFIER; | 214 return IDENTIFIER; |
213 } | 215 } |
214 <PP>[1-9][0-9]* { | 216 <PP>[1-9][0-9]* { |
215 yylval->n = strtol(yytext, NULL, 10); | 217 yylval->n = strtol(yytext, NULL, 10); |
216 return INTCONSTANT; | 218 return INTCONSTANT; |
217 } | 219 } |
218 <PP>\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL;
} | 220 <PP>\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL;
} |
219 | 221 |
220 \n { yylineno++; yycolumn = 0; } | 222 \n { yylineno++; yycolumn = 0; } |
221 | 223 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 311 |
310 layout { | 312 layout { |
311 if ((yyextra->language_version >= 140) | 313 if ((yyextra->language_version >= 140) |
312 || yyextra->AMD_conservative_depth_enable | 314 || yyextra->AMD_conservative_depth_enable |
313 || yyextra->ARB_conservative_depth_enable | 315 || yyextra->ARB_conservative_depth_enable |
314 || yyextra->ARB_explicit_attrib_location_enable | 316 || yyextra->ARB_explicit_attrib_location_enable |
315 || yyextra->ARB_uniform_buffer_object_enable | 317 || yyextra->ARB_uniform_buffer_object_enable |
316 || yyextra->ARB_fragment_coord_conventions_enable) { | 318 || yyextra->ARB_fragment_coord_conventions_enable) { |
317 return LAYOUT_TOK; | 319 return LAYOUT_TOK; |
318 } else { | 320 } else { |
319 » » yylval->identifier = strdup(yytext); | 321 » » void *mem_ctx = yyextra; |
| 322 » » yylval->identifier = ralloc_strdup(mem_ctx, yytext); |
320 return IDENTIFIER; | 323 return IDENTIFIER; |
321 } | 324 } |
322 } | 325 } |
323 | 326 |
324 \+\+ return INC_OP; | 327 \+\+ return INC_OP; |
325 -- return DEC_OP; | 328 -- return DEC_OP; |
326 \<= return LE_OP; | 329 \<= return LE_OP; |
327 >= return GE_OP; | 330 >= return GE_OP; |
328 == return EQ_OP; | 331 == return EQ_OP; |
329 != return NE_OP; | 332 != return NE_OP; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 { | 507 { |
505 yylex_init_extra(state, & state->scanner); | 508 yylex_init_extra(state, & state->scanner); |
506 yy_scan_string(string, state->scanner); | 509 yy_scan_string(string, state->scanner); |
507 } | 510 } |
508 | 511 |
509 void | 512 void |
510 _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) | 513 _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state) |
511 { | 514 { |
512 yylex_destroy(state->scanner); | 515 yylex_destroy(state->scanner); |
513 } | 516 } |
OLD | NEW |