diff options
author | Kenneth Graunke <[email protected]> | 2010-08-04 16:10:03 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2010-08-04 23:37:18 -0700 |
commit | 16b4eed59a07f5e07587f4f9b0cdc304a08a685c (patch) | |
tree | dc6ff6ffb5118b4b89e1b26c57d9a26726f96487 /src/glsl | |
parent | 046bef235744e891e4a48076e1a3ff9a61a63092 (diff) |
glcpp: Refactor HASH_IF and HASH_ELIF expansion to reuse code.
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/glcpp/glcpp-parse.c | 247 | ||||
-rw-r--r-- | src/glsl/glcpp/glcpp-parse.y | 39 |
2 files changed, 142 insertions, 144 deletions
diff --git a/src/glsl/glcpp/glcpp-parse.c b/src/glsl/glcpp/glcpp-parse.c index 5ea07c2555e..df16cabeebd 100644 --- a/src/glsl/glcpp/glcpp-parse.c +++ b/src/glsl/glcpp/glcpp-parse.c @@ -176,6 +176,9 @@ int _active_list_contains (active_list_t *list, const char *identifier); static void +_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list); + +static void _glcpp_parser_expand_token_list (glcpp_parser_t *parser, token_list_t *list); @@ -208,7 +211,7 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value); /* Line 189 of yacc.c */ -#line 212 "glcpp/glcpp-parse.c" +#line 215 "glcpp/glcpp-parse.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -296,7 +299,7 @@ typedef struct YYLTYPE /* Line 264 of yacc.c */ -#line 300 "glcpp/glcpp-parse.c" +#line 303 "glcpp/glcpp-parse.c" #ifdef short # undef short @@ -620,17 +623,17 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 169, 169, 171, 175, 178, 183, 184, 188, 191, - 197, 200, 203, 206, 214, 226, 231, 236, 248, 259, - 262, 265, 274, 278, 287, 292, 293, 296, 299, 302, - 305, 308, 311, 314, 317, 320, 323, 326, 329, 332, - 335, 338, 341, 344, 347, 350, 353, 356, 359, 365, - 370, 378, 379, 383, 389, 390, 393, 395, 402, 406, - 410, 415, 421, 429, 435, 443, 447, 451, 455, 459, - 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, - 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, - 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, - 496 + 0, 172, 172, 174, 178, 181, 186, 187, 191, 194, + 200, 203, 206, 209, 217, 220, 225, 230, 233, 244, + 247, 250, 259, 263, 272, 277, 278, 281, 284, 287, + 290, 293, 296, 299, 302, 305, 308, 311, 314, 317, + 320, 323, 326, 329, 332, 335, 338, 341, 344, 350, + 355, 363, 364, 368, 374, 375, 378, 380, 387, 391, + 395, 400, 406, 414, 420, 428, 432, 436, 440, 444, + 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, + 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, + 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, + 481 }; #endif @@ -1781,7 +1784,7 @@ yyreduce: case 4: /* Line 1464 of yacc.c */ -#line 175 "glcpp/glcpp-parse.y" +#line 178 "glcpp/glcpp-parse.y" { glcpp_print(parser->output, "\n"); ;} @@ -1790,7 +1793,7 @@ yyreduce: case 5: /* Line 1464 of yacc.c */ -#line 178 "glcpp/glcpp-parse.y" +#line 181 "glcpp/glcpp-parse.y" { _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list)); glcpp_print(parser->output, "\n"); @@ -1801,7 +1804,7 @@ yyreduce: case 8: /* Line 1464 of yacc.c */ -#line 188 "glcpp/glcpp-parse.y" +#line 191 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival)); ;} @@ -1810,7 +1813,7 @@ yyreduce: case 9: /* Line 1464 of yacc.c */ -#line 191 "glcpp/glcpp-parse.y" +#line 194 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival)); ;} @@ -1819,7 +1822,7 @@ yyreduce: case 10: /* Line 1464 of yacc.c */ -#line 197 "glcpp/glcpp-parse.y" +#line 200 "glcpp/glcpp-parse.y" { _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list)); ;} @@ -1828,7 +1831,7 @@ yyreduce: case 11: /* Line 1464 of yacc.c */ -#line 200 "glcpp/glcpp-parse.y" +#line 203 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list)); ;} @@ -1837,7 +1840,7 @@ yyreduce: case 12: /* Line 1464 of yacc.c */ -#line 203 "glcpp/glcpp-parse.y" +#line 206 "glcpp/glcpp-parse.y" { _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list)); ;} @@ -1846,7 +1849,7 @@ yyreduce: case 13: /* Line 1464 of yacc.c */ -#line 206 "glcpp/glcpp-parse.y" +#line 209 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str)); if (macro) { @@ -1860,25 +1863,16 @@ yyreduce: case 14: /* Line 1464 of yacc.c */ -#line 214 "glcpp/glcpp-parse.y" +#line 217 "glcpp/glcpp-parse.y" { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, (yyvsp[(2) - (3)].token_list)); - _token_list_append_list (expanded, (yyvsp[(2) - (3)].token_list)); - glcpp_parser_lex_from (parser, expanded); + _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list)); ;} break; case 15: /* Line 1464 of yacc.c */ -#line 226 "glcpp/glcpp-parse.y" +#line 220 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1889,7 +1883,7 @@ yyreduce: case 16: /* Line 1464 of yacc.c */ -#line 231 "glcpp/glcpp-parse.y" +#line 225 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str)); talloc_free ((yyvsp[(2) - (4)].str)); @@ -1900,25 +1894,16 @@ yyreduce: case 17: /* Line 1464 of yacc.c */ -#line 236 "glcpp/glcpp-parse.y" +#line 230 "glcpp/glcpp-parse.y" { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, (yyvsp[(2) - (3)].token_list)); - _token_list_append_list (expanded, (yyvsp[(2) - (3)].token_list)); - glcpp_parser_lex_from (parser, expanded); + _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list)); ;} break; case 18: /* Line 1464 of yacc.c */ -#line 248 "glcpp/glcpp-parse.y" +#line 233 "glcpp/glcpp-parse.y" { /* #elif without an expression results in a warning if the * condition doesn't matter (we just handled #if 1 or such) @@ -1935,7 +1920,7 @@ yyreduce: case 19: /* Line 1464 of yacc.c */ -#line 259 "glcpp/glcpp-parse.y" +#line 244 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1); ;} @@ -1944,7 +1929,7 @@ yyreduce: case 20: /* Line 1464 of yacc.c */ -#line 262 "glcpp/glcpp-parse.y" +#line 247 "glcpp/glcpp-parse.y" { _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)])); ;} @@ -1953,7 +1938,7 @@ yyreduce: case 21: /* Line 1464 of yacc.c */ -#line 265 "glcpp/glcpp-parse.y" +#line 250 "glcpp/glcpp-parse.y" { macro_t *macro = hash_table_find (parser->defines, "__VERSION__"); if (macro) { @@ -1968,7 +1953,7 @@ yyreduce: case 23: /* Line 1464 of yacc.c */ -#line 278 "glcpp/glcpp-parse.y" +#line 263 "glcpp/glcpp-parse.y" { if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) { (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16); @@ -1983,7 +1968,7 @@ yyreduce: case 24: /* Line 1464 of yacc.c */ -#line 287 "glcpp/glcpp-parse.y" +#line 272 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); ;} @@ -1992,7 +1977,7 @@ yyreduce: case 26: /* Line 1464 of yacc.c */ -#line 293 "glcpp/glcpp-parse.y" +#line 278 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival); ;} @@ -2001,7 +1986,7 @@ yyreduce: case 27: /* Line 1464 of yacc.c */ -#line 296 "glcpp/glcpp-parse.y" +#line 281 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival); ;} @@ -2010,7 +1995,7 @@ yyreduce: case 28: /* Line 1464 of yacc.c */ -#line 299 "glcpp/glcpp-parse.y" +#line 284 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival); ;} @@ -2019,7 +2004,7 @@ yyreduce: case 29: /* Line 1464 of yacc.c */ -#line 302 "glcpp/glcpp-parse.y" +#line 287 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival); ;} @@ -2028,7 +2013,7 @@ yyreduce: case 30: /* Line 1464 of yacc.c */ -#line 305 "glcpp/glcpp-parse.y" +#line 290 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival); ;} @@ -2037,7 +2022,7 @@ yyreduce: case 31: /* Line 1464 of yacc.c */ -#line 308 "glcpp/glcpp-parse.y" +#line 293 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival); ;} @@ -2046,7 +2031,7 @@ yyreduce: case 32: /* Line 1464 of yacc.c */ -#line 311 "glcpp/glcpp-parse.y" +#line 296 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival); ;} @@ -2055,7 +2040,7 @@ yyreduce: case 33: /* Line 1464 of yacc.c */ -#line 314 "glcpp/glcpp-parse.y" +#line 299 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival); ;} @@ -2064,7 +2049,7 @@ yyreduce: case 34: /* Line 1464 of yacc.c */ -#line 317 "glcpp/glcpp-parse.y" +#line 302 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival); ;} @@ -2073,7 +2058,7 @@ yyreduce: case 35: /* Line 1464 of yacc.c */ -#line 320 "glcpp/glcpp-parse.y" +#line 305 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival); ;} @@ -2082,7 +2067,7 @@ yyreduce: case 36: /* Line 1464 of yacc.c */ -#line 323 "glcpp/glcpp-parse.y" +#line 308 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival); ;} @@ -2091,7 +2076,7 @@ yyreduce: case 37: /* Line 1464 of yacc.c */ -#line 326 "glcpp/glcpp-parse.y" +#line 311 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival); ;} @@ -2100,7 +2085,7 @@ yyreduce: case 38: /* Line 1464 of yacc.c */ -#line 329 "glcpp/glcpp-parse.y" +#line 314 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival); ;} @@ -2109,7 +2094,7 @@ yyreduce: case 39: /* Line 1464 of yacc.c */ -#line 332 "glcpp/glcpp-parse.y" +#line 317 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival); ;} @@ -2118,7 +2103,7 @@ yyreduce: case 40: /* Line 1464 of yacc.c */ -#line 335 "glcpp/glcpp-parse.y" +#line 320 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival); ;} @@ -2127,7 +2112,7 @@ yyreduce: case 41: /* Line 1464 of yacc.c */ -#line 338 "glcpp/glcpp-parse.y" +#line 323 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival); ;} @@ -2136,7 +2121,7 @@ yyreduce: case 42: /* Line 1464 of yacc.c */ -#line 341 "glcpp/glcpp-parse.y" +#line 326 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival); ;} @@ -2145,7 +2130,7 @@ yyreduce: case 43: /* Line 1464 of yacc.c */ -#line 344 "glcpp/glcpp-parse.y" +#line 329 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival); ;} @@ -2154,7 +2139,7 @@ yyreduce: case 44: /* Line 1464 of yacc.c */ -#line 347 "glcpp/glcpp-parse.y" +#line 332 "glcpp/glcpp-parse.y" { (yyval.ival) = ! (yyvsp[(2) - (2)].ival); ;} @@ -2163,7 +2148,7 @@ yyreduce: case 45: /* Line 1464 of yacc.c */ -#line 350 "glcpp/glcpp-parse.y" +#line 335 "glcpp/glcpp-parse.y" { (yyval.ival) = ~ (yyvsp[(2) - (2)].ival); ;} @@ -2172,7 +2157,7 @@ yyreduce: case 46: /* Line 1464 of yacc.c */ -#line 353 "glcpp/glcpp-parse.y" +#line 338 "glcpp/glcpp-parse.y" { (yyval.ival) = - (yyvsp[(2) - (2)].ival); ;} @@ -2181,7 +2166,7 @@ yyreduce: case 47: /* Line 1464 of yacc.c */ -#line 356 "glcpp/glcpp-parse.y" +#line 341 "glcpp/glcpp-parse.y" { (yyval.ival) = + (yyvsp[(2) - (2)].ival); ;} @@ -2190,7 +2175,7 @@ yyreduce: case 48: /* Line 1464 of yacc.c */ -#line 359 "glcpp/glcpp-parse.y" +#line 344 "glcpp/glcpp-parse.y" { (yyval.ival) = (yyvsp[(2) - (3)].ival); ;} @@ -2199,7 +2184,7 @@ yyreduce: case 49: /* Line 1464 of yacc.c */ -#line 365 "glcpp/glcpp-parse.y" +#line 350 "glcpp/glcpp-parse.y" { (yyval.string_list) = _string_list_create (parser); _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str)); @@ -2210,7 +2195,7 @@ yyreduce: case 50: /* Line 1464 of yacc.c */ -#line 370 "glcpp/glcpp-parse.y" +#line 355 "glcpp/glcpp-parse.y" { (yyval.string_list) = (yyvsp[(1) - (3)].string_list); _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str)); @@ -2221,14 +2206,14 @@ yyreduce: case 51: /* Line 1464 of yacc.c */ -#line 378 "glcpp/glcpp-parse.y" +#line 363 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 53: /* Line 1464 of yacc.c */ -#line 383 "glcpp/glcpp-parse.y" +#line 368 "glcpp/glcpp-parse.y" { yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #"); ;} @@ -2237,14 +2222,14 @@ yyreduce: case 54: /* Line 1464 of yacc.c */ -#line 389 "glcpp/glcpp-parse.y" +#line 374 "glcpp/glcpp-parse.y" { (yyval.token_list) = NULL; ;} break; case 57: /* Line 1464 of yacc.c */ -#line 395 "glcpp/glcpp-parse.y" +#line 380 "glcpp/glcpp-parse.y" { glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive"); ;} @@ -2253,7 +2238,7 @@ yyreduce: case 58: /* Line 1464 of yacc.c */ -#line 402 "glcpp/glcpp-parse.y" +#line 387 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2263,7 +2248,7 @@ yyreduce: case 59: /* Line 1464 of yacc.c */ -#line 406 "glcpp/glcpp-parse.y" +#line 391 "glcpp/glcpp-parse.y" { int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0; (yyval.token) = _token_create_ival (parser, INTEGER, v); @@ -2273,7 +2258,7 @@ yyreduce: case 61: /* Line 1464 of yacc.c */ -#line 415 "glcpp/glcpp-parse.y" +#line 400 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2285,7 +2270,7 @@ yyreduce: case 62: /* Line 1464 of yacc.c */ -#line 421 "glcpp/glcpp-parse.y" +#line 406 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2296,7 +2281,7 @@ yyreduce: case 63: /* Line 1464 of yacc.c */ -#line 429 "glcpp/glcpp-parse.y" +#line 414 "glcpp/glcpp-parse.y" { parser->space_tokens = 1; (yyval.token_list) = _token_list_create (parser); @@ -2308,7 +2293,7 @@ yyreduce: case 64: /* Line 1464 of yacc.c */ -#line 435 "glcpp/glcpp-parse.y" +#line 420 "glcpp/glcpp-parse.y" { (yyval.token_list) = (yyvsp[(1) - (2)].token_list); _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token)); @@ -2319,7 +2304,7 @@ yyreduce: case 65: /* Line 1464 of yacc.c */ -#line 443 "glcpp/glcpp-parse.y" +#line 428 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2329,7 +2314,7 @@ yyreduce: case 66: /* Line 1464 of yacc.c */ -#line 447 "glcpp/glcpp-parse.y" +#line 432 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2339,7 +2324,7 @@ yyreduce: case 67: /* Line 1464 of yacc.c */ -#line 451 "glcpp/glcpp-parse.y" +#line 436 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival)); (yyval.token)->location = yylloc; @@ -2349,7 +2334,7 @@ yyreduce: case 68: /* Line 1464 of yacc.c */ -#line 455 "glcpp/glcpp-parse.y" +#line 440 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str)); (yyval.token)->location = yylloc; @@ -2359,7 +2344,7 @@ yyreduce: case 69: /* Line 1464 of yacc.c */ -#line 459 "glcpp/glcpp-parse.y" +#line 444 "glcpp/glcpp-parse.y" { (yyval.token) = _token_create_ival (parser, SPACE, SPACE); (yyval.token)->location = yylloc; @@ -2369,224 +2354,224 @@ yyreduce: case 70: /* Line 1464 of yacc.c */ -#line 466 "glcpp/glcpp-parse.y" +#line 451 "glcpp/glcpp-parse.y" { (yyval.ival) = '['; ;} break; case 71: /* Line 1464 of yacc.c */ -#line 467 "glcpp/glcpp-parse.y" +#line 452 "glcpp/glcpp-parse.y" { (yyval.ival) = ']'; ;} break; case 72: /* Line 1464 of yacc.c */ -#line 468 "glcpp/glcpp-parse.y" +#line 453 "glcpp/glcpp-parse.y" { (yyval.ival) = '('; ;} break; case 73: /* Line 1464 of yacc.c */ -#line 469 "glcpp/glcpp-parse.y" +#line 454 "glcpp/glcpp-parse.y" { (yyval.ival) = ')'; ;} break; case 74: /* Line 1464 of yacc.c */ -#line 470 "glcpp/glcpp-parse.y" +#line 455 "glcpp/glcpp-parse.y" { (yyval.ival) = '{'; ;} break; case 75: /* Line 1464 of yacc.c */ -#line 471 "glcpp/glcpp-parse.y" +#line 456 "glcpp/glcpp-parse.y" { (yyval.ival) = '}'; ;} break; case 76: /* Line 1464 of yacc.c */ -#line 472 "glcpp/glcpp-parse.y" +#line 457 "glcpp/glcpp-parse.y" { (yyval.ival) = '.'; ;} break; case 77: /* Line 1464 of yacc.c */ -#line 473 "glcpp/glcpp-parse.y" +#line 458 "glcpp/glcpp-parse.y" { (yyval.ival) = '&'; ;} break; case 78: /* Line 1464 of yacc.c */ -#line 474 "glcpp/glcpp-parse.y" +#line 459 "glcpp/glcpp-parse.y" { (yyval.ival) = '*'; ;} break; case 79: /* Line 1464 of yacc.c */ -#line 475 "glcpp/glcpp-parse.y" +#line 460 "glcpp/glcpp-parse.y" { (yyval.ival) = '+'; ;} break; case 80: /* Line 1464 of yacc.c */ -#line 476 "glcpp/glcpp-parse.y" +#line 461 "glcpp/glcpp-parse.y" { (yyval.ival) = '-'; ;} break; case 81: /* Line 1464 of yacc.c */ -#line 477 "glcpp/glcpp-parse.y" +#line 462 "glcpp/glcpp-parse.y" { (yyval.ival) = '~'; ;} break; case 82: /* Line 1464 of yacc.c */ -#line 478 "glcpp/glcpp-parse.y" +#line 463 "glcpp/glcpp-parse.y" { (yyval.ival) = '!'; ;} break; case 83: /* Line 1464 of yacc.c */ -#line 479 "glcpp/glcpp-parse.y" +#line 464 "glcpp/glcpp-parse.y" { (yyval.ival) = '/'; ;} break; case 84: /* Line 1464 of yacc.c */ -#line 480 "glcpp/glcpp-parse.y" +#line 465 "glcpp/glcpp-parse.y" { (yyval.ival) = '%'; ;} break; case 85: /* Line 1464 of yacc.c */ -#line 481 "glcpp/glcpp-parse.y" +#line 466 "glcpp/glcpp-parse.y" { (yyval.ival) = LEFT_SHIFT; ;} break; case 86: /* Line 1464 of yacc.c */ -#line 482 "glcpp/glcpp-parse.y" +#line 467 "glcpp/glcpp-parse.y" { (yyval.ival) = RIGHT_SHIFT; ;} break; case 87: /* Line 1464 of yacc.c */ -#line 483 "glcpp/glcpp-parse.y" +#line 468 "glcpp/glcpp-parse.y" { (yyval.ival) = '<'; ;} break; case 88: /* Line 1464 of yacc.c */ -#line 484 "glcpp/glcpp-parse.y" +#line 469 "glcpp/glcpp-parse.y" { (yyval.ival) = '>'; ;} break; case 89: /* Line 1464 of yacc.c */ -#line 485 "glcpp/glcpp-parse.y" +#line 470 "glcpp/glcpp-parse.y" { (yyval.ival) = LESS_OR_EQUAL; ;} break; case 90: /* Line 1464 of yacc.c */ -#line 486 "glcpp/glcpp-parse.y" +#line 471 "glcpp/glcpp-parse.y" { (yyval.ival) = GREATER_OR_EQUAL; ;} break; case 91: /* Line 1464 of yacc.c */ -#line 487 "glcpp/glcpp-parse.y" +#line 472 "glcpp/glcpp-parse.y" { (yyval.ival) = EQUAL; ;} break; case 92: /* Line 1464 of yacc.c */ -#line 488 "glcpp/glcpp-parse.y" +#line 473 "glcpp/glcpp-parse.y" { (yyval.ival) = NOT_EQUAL; ;} break; case 93: /* Line 1464 of yacc.c */ -#line 489 "glcpp/glcpp-parse.y" +#line 474 "glcpp/glcpp-parse.y" { (yyval.ival) = '^'; ;} break; case 94: /* Line 1464 of yacc.c */ -#line 490 "glcpp/glcpp-parse.y" +#line 475 "glcpp/glcpp-parse.y" { (yyval.ival) = '|'; ;} break; case 95: /* Line 1464 of yacc.c */ -#line 491 "glcpp/glcpp-parse.y" +#line 476 "glcpp/glcpp-parse.y" { (yyval.ival) = AND; ;} break; case 96: /* Line 1464 of yacc.c */ -#line 492 "glcpp/glcpp-parse.y" +#line 477 "glcpp/glcpp-parse.y" { (yyval.ival) = OR; ;} break; case 97: /* Line 1464 of yacc.c */ -#line 493 "glcpp/glcpp-parse.y" +#line 478 "glcpp/glcpp-parse.y" { (yyval.ival) = ';'; ;} break; case 98: /* Line 1464 of yacc.c */ -#line 494 "glcpp/glcpp-parse.y" +#line 479 "glcpp/glcpp-parse.y" { (yyval.ival) = ','; ;} break; case 99: /* Line 1464 of yacc.c */ -#line 495 "glcpp/glcpp-parse.y" +#line 480 "glcpp/glcpp-parse.y" { (yyval.ival) = '='; ;} break; case 100: /* Line 1464 of yacc.c */ -#line 496 "glcpp/glcpp-parse.y" +#line 481 "glcpp/glcpp-parse.y" { (yyval.ival) = PASTE; ;} break; /* Line 1464 of yacc.c */ -#line 2590 "glcpp/glcpp-parse.c" +#line 2575 "glcpp/glcpp-parse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2805,7 +2790,7 @@ yyreturn: /* Line 1684 of yacc.c */ -#line 499 "glcpp/glcpp-parse.y" +#line 484 "glcpp/glcpp-parse.y" string_list_t * @@ -3397,6 +3382,20 @@ _token_list_create_with_one_space (void *ctx) return list; } +static void +_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list) +{ + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, type, type); + _token_list_append (expanded, token); + _glcpp_parser_expand_token_list (parser, list); + _token_list_append_list (expanded, list); + glcpp_parser_lex_from (parser, expanded); +} + /* This is a helper function that's essentially part of the * implementation of _glcpp_parser_expand_node. It shouldn't be called * except for by that function. diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 55a8d1761e6..e19da432eec 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -106,6 +106,9 @@ int _active_list_contains (active_list_t *list, const char *identifier); static void +_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list); + +static void _glcpp_parser_expand_token_list (glcpp_parser_t *parser, token_list_t *list); @@ -212,16 +215,7 @@ control_line: talloc_free ($2); } | HASH_IF conditional_tokens NEWLINE { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, $2); - _token_list_append_list (expanded, $2); - glcpp_parser_lex_from (parser, expanded); + _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); } | HASH_IFDEF IDENTIFIER junk NEWLINE { macro_t *macro = hash_table_find (parser->defines, $2); @@ -234,16 +228,7 @@ control_line: _glcpp_parser_skip_stack_push_if (parser, & @1, macro == NULL); } | HASH_ELIF conditional_tokens NEWLINE { - token_list_t *expanded; - token_t *token; - - expanded = _token_list_create (parser); - token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED); - _token_list_append (expanded, token); - talloc_unlink (parser, token); - _glcpp_parser_expand_token_list (parser, $2); - _token_list_append_list (expanded, $2); - glcpp_parser_lex_from (parser, expanded); + _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2); } | HASH_ELIF NEWLINE { /* #elif without an expression results in a warning if the @@ -1087,6 +1072,20 @@ _token_list_create_with_one_space (void *ctx) return list; } +static void +_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list) +{ + token_list_t *expanded; + token_t *token; + + expanded = _token_list_create (parser); + token = _token_create_ival (parser, type, type); + _token_list_append (expanded, token); + _glcpp_parser_expand_token_list (parser, list); + _token_list_append_list (expanded, list); + glcpp_parser_lex_from (parser, expanded); +} + /* This is a helper function that's essentially part of the * implementation of _glcpp_parser_expand_node. It shouldn't be called * except for by that function. |