Lines Matching refs:parser
36 yyerror(YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
39 _define_object_macro(glcpp_parser_t *parser,
45 _define_function_macro(glcpp_parser_t *parser,
52 _string_list_create(glcpp_parser_t *parser);
55 _string_list_append_item(glcpp_parser_t *parser, string_list_t *list,
71 _argument_list_create(glcpp_parser_t *parser);
74 _argument_list_append(glcpp_parser_t *parser, argument_list_t *list,
84 _token_create_str(glcpp_parser_t *parser, int type, char *str);
87 _token_create_ival(glcpp_parser_t *parser, int type, int ival);
90 _token_list_create(glcpp_parser_t *parser);
93 _token_list_append(glcpp_parser_t *parser, token_list_t *list, token_t *token);
102 _parser_active_list_push(glcpp_parser_t *parser, const char *identifier,
106 _parser_active_list_pop(glcpp_parser_t *parser);
109 _parser_active_list_contains(glcpp_parser_t *parser, const char *identifier);
120 _glcpp_parser_expand_and_lex_from(glcpp_parser_t *parser, int head_token_type,
125 _glcpp_parser_expand_token_list(glcpp_parser_t *parser, token_list_t *list,
129 _glcpp_parser_print_expanded_token_list(glcpp_parser_t *parser,
133 _glcpp_parser_skip_stack_push_if(glcpp_parser_t *parser, YYLTYPE *loc,
137 _glcpp_parser_skip_stack_change_if(glcpp_parser_t *parser, YYLTYPE *loc,
141 _glcpp_parser_skip_stack_pop(glcpp_parser_t *parser, YYLTYPE *loc);
144 _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t version,
148 glcpp_parser_lex(YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
151 glcpp_parser_lex_from(glcpp_parser_t *parser, token_list_t *list);
154 add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
158 %pure-parser
170 %parse-param {glcpp_parser_t *parser}
171 %lex-param {glcpp_parser_t *parser}
211 _glcpp_parser_print_expanded_token_list (parser, $1);
212 ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
219 if (parser->is_gles && $2.undefined_macro)
220 …glcpp_error(& @1, parser, "undefined macro %s in expression (illegal in GLES)", $2.undefined_macro…
221 _glcpp_parser_skip_stack_push_if (parser, & @1, $2.value);
224 if (parser->is_gles && $2.undefined_macro)
225 …glcpp_error(& @1, parser, "undefined macro %s in expression (illegal in GLES)", $2.undefined_macro…
226 _glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2.value);
229 parser->has_new_line_number = 1;
230 parser->new_line_number = $2;
231 ralloc_asprintf_rewrite_tail (&parser->output,
232 &parser->output_length,
237 parser->has_new_line_number = 1;
238 parser->new_line_number = $2;
239 parser->has_new_source_number = 1;
240 parser->new_source_number = $3;
241 ralloc_asprintf_rewrite_tail (&parser->output,
242 &parser->output_length,
250 _define_object_macro (parser, & @1, $1, $2);
253 _define_function_macro (parser, & @1, $1, NULL, $4);
256 _define_function_macro (parser, & @1, $1, $3, $5);
262 ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
267 if (parser->skip_stack == NULL ||
268 parser->skip_stack->type == SKIP_NO_SKIP)
270 _glcpp_parser_expand_and_lex_from (parser,
303 if (parser->is_gles &&
304 parser->version >= 300 &&
309 glcpp_error(& @1, parser, "Built-in (pre-defined)"
312 entry = _mesa_hash_table_search (parser->defines, $3);
314 _mesa_hash_table_remove (parser->defines, entry);
325 if (parser->skip_stack == NULL ||
326 parser->skip_stack->type == SKIP_NO_SKIP)
328 _glcpp_parser_expand_and_lex_from (parser,
334 _glcpp_parser_skip_stack_push_if (parser, & @1, 0);
335 parser->skip_stack->type = SKIP_TO_ENDIF;
341 if (parser->skip_stack == NULL ||
342 parser->skip_stack->type == SKIP_NO_SKIP)
344 glcpp_error(& @1, parser, "#if with no expression");
346 _glcpp_parser_skip_stack_push_if (parser, & @1, 0);
350 _mesa_hash_table_search(parser->defines, $3);
352 _glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
356 _mesa_hash_table_search(parser->defines, $3);
358 _glcpp_parser_skip_stack_push_if (parser, & @3, macro == NULL);
368 if (parser->skip_stack &&
369 parser->skip_stack->type == SKIP_TO_ELSE)
371 _glcpp_parser_expand_and_lex_from (parser,
375 else if (parser->skip_stack &&
376 parser->skip_stack->has_else)
378 glcpp_error(& @1, parser, "#elif after #else");
382 _glcpp_parser_skip_stack_change_if (parser, & @1,
389 if (parser->skip_stack &&
390 parser->skip_stack->type == SKIP_TO_ELSE)
392 glcpp_error(& @1, parser, "#elif with no expression");
394 else if (parser->skip_stack &&
395 parser->skip_stack->has_else)
397 glcpp_error(& @1, parser, "#elif after #else");
401 _glcpp_parser_skip_stack_change_if (parser, & @1,
403 glcpp_warning(& @1, parser, "ignoring illegal #elif without expression");
406 | HASH_TOKEN ELSE { parser->lexing_directive = 1; } NEWLINE {
407 if (parser->skip_stack &&
408 parser->skip_stack->has_else)
410 glcpp_error(& @1, parser, "multiple #else");
414 _glcpp_parser_skip_stack_change_if (parser, & @1, "else", 1);
415 if (parser->skip_stack)
416 parser->skip_stack->has_else = true;
420 _glcpp_parser_skip_stack_pop (parser, & @1);
423 if (parser->version_set) {
424 glcpp_error(& @1, parser, "#version must appear on the first line");
426 _glcpp_parser_handle_version_declaration(parser, $3, NULL, true);
429 if (parser->version_set) {
430 glcpp_error(& @1, parser, "#version must appear on the first line");
432 _glcpp_parser_handle_version_declaration(parser, $3, $4, true);
435 glcpp_parser_resolve_implicit_version(parser);
438 ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "#%s", $2);
444 glcpp_error(& @1, parser, "#%s", $2);
447 glcpp_error (& @1, parser, "#define without macro name");
450 glcpp_error (& @1, parser, "Illegal non-directive after #");
472 glcpp_error(&@1, parser, "invalid #version \"%s\" (not a decimal constant)", $1);
486 if (parser->is_gles)
487 $$.undefined_macro = linear_strdup(parser->linalloc, $1);
606 yyerror (& @1, parser,
618 yyerror (& @1, parser,
658 $$ = _string_list_create (parser);
659 _string_list_append_item (parser, $$, $1);
663 _string_list_append_item (parser, $$, $3);
680 glcpp_error(&@1, parser, "extra tokens at end of directive");
686 parser->space_tokens = 1;
687 $$ = _token_list_create (parser);
688 _token_list_append (parser, $$, $1);
692 _token_list_append (parser, $$, $2);
698 $$ = _token_create_str (parser, IDENTIFIER, $1);
702 $$ = _token_create_str (parser, INTEGER_STRING, $1);
706 $$ = _token_create_ival (parser, $1, $1);
710 $$ = _token_create_ival (parser, DEFINED, DEFINED);
714 $$ = _token_create_str (parser, OTHER, $1);
718 $$ = _token_create_ival (parser, SPACE, SPACE);
762 _string_list_create(glcpp_parser_t *parser)
766 list = linear_alloc_child(parser->linalloc, sizeof(string_list_t));
774 _string_list_append_item(glcpp_parser_t *parser, string_list_t *list, in _string_list_append_item() argument
779 node = linear_alloc_child(parser->linalloc, sizeof(string_node_t)); in _string_list_append_item()
780 node->str = linear_strdup(parser->linalloc, str); in _string_list_append_item()
873 _argument_list_create(glcpp_parser_t *parser) in _argument_list_create() argument
877 list = linear_alloc_child(parser->linalloc, sizeof(argument_list_t)); in _argument_list_create()
885 _argument_list_append(glcpp_parser_t *parser, in _argument_list_append() argument
890 node = linear_alloc_child(parser->linalloc, sizeof(argument_node_t)); in _argument_list_append()
942 _token_create_str(glcpp_parser_t *parser, int type, char *str) in _token_create_str() argument
946 token = linear_alloc_child(parser->linalloc, sizeof(token_t)); in _token_create_str()
954 _token_create_ival(glcpp_parser_t *parser, int type, int ival) in _token_create_ival() argument
958 token = linear_alloc_child(parser->linalloc, sizeof(token_t)); in _token_create_ival()
966 _token_list_create(glcpp_parser_t *parser) in _token_list_create() argument
970 list = linear_alloc_child(parser->linalloc, sizeof(token_list_t)); in _token_list_create()
979 _token_list_append(glcpp_parser_t *parser, token_list_t *list, token_t *token) in _token_list_append() argument
983 node = linear_alloc_child(parser->linalloc, sizeof(token_node_t)); in _token_list_append()
1015 _token_list_copy(glcpp_parser_t *parser, token_list_t *other) in _token_list_copy() argument
1023 copy = _token_list_create (parser); in _token_list_copy()
1025 token_t *new_token = linear_alloc_child(parser->linalloc, sizeof(token_t)); in _token_list_copy()
1027 _token_list_append (parser, copy, new_token); in _token_list_copy()
1188 _token_paste(glcpp_parser_t *parser, token_t *token, token_t *other) in _token_paste() argument
1205 combined = _token_create_ival (parser, LEFT_SHIFT, LEFT_SHIFT); in _token_paste()
1207 combined = _token_create_ival (parser, LESS_OR_EQUAL, LESS_OR_EQUAL); in _token_paste()
1211 combined = _token_create_ival (parser, RIGHT_SHIFT, RIGHT_SHIFT); in _token_paste()
1213 combined = _token_create_ival (parser, GREATER_OR_EQUAL, GREATER_OR_EQUAL); in _token_paste()
1217 combined = _token_create_ival (parser, EQUAL, EQUAL); in _token_paste()
1221 combined = _token_create_ival (parser, NOT_EQUAL, NOT_EQUAL); in _token_paste()
1225 combined = _token_create_ival (parser, AND, AND); in _token_paste()
1229 combined = _token_create_ival (parser, OR, OR); in _token_paste()
1273 str = linear_asprintf(parser->linalloc, "%" PRIiMAX, token->value.ival); in _token_paste()
1275 str = linear_strdup(parser->linalloc, token->value.str); in _token_paste()
1278 linear_asprintf_append(parser->linalloc, &str, "%" PRIiMAX, other->value.ival); in _token_paste()
1280 linear_strcat(parser->linalloc, &str, other->value.str); in _token_paste()
1289 combined = _token_create_str (parser, combined_type, str); in _token_paste()
1295 glcpp_error (&token->location, parser, ""); in _token_paste()
1296 ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "Pasting \""); in _token_paste()
1297 _token_print (&parser->info_log, &parser->info_log_length, token); in _token_paste()
1298 ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "\" and \""); in _token_paste()
1299 _token_print (&parser->info_log, &parser->info_log_length, other); in _token_paste()
1300 …ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "\" does not give a val… in _token_paste()
1306 _token_list_print(glcpp_parser_t *parser, token_list_t *list) in _token_list_print() argument
1314 _token_print (&parser->output, &parser->output_length, node->token); in _token_list_print()
1318 yyerror(YYLTYPE *locp, glcpp_parser_t *parser, const char *error) in yyerror() argument
1320 glcpp_error(locp, parser, "%s", error); in yyerror()
1324 add_builtin_define(glcpp_parser_t *parser, const char *name, int value) in add_builtin_define() argument
1329 tok = _token_create_ival (parser, INTEGER, value); in add_builtin_define()
1331 list = _token_list_create(parser); in add_builtin_define()
1332 _token_list_append(parser, list, tok); in add_builtin_define()
1333 _define_object_macro(parser, NULL, name, list); in add_builtin_define()
1339 glcpp_parser_t *parser; in glcpp_parser_create() local
1341 parser = ralloc (NULL, glcpp_parser_t); in glcpp_parser_create()
1343 glcpp_lex_init_extra (parser, &parser->scanner); in glcpp_parser_create()
1344 parser->defines = _mesa_hash_table_create(NULL, _mesa_key_hash_string, in glcpp_parser_create()
1346 parser->linalloc = linear_alloc_parent(parser, 0); in glcpp_parser_create()
1347 parser->active = NULL; in glcpp_parser_create()
1348 parser->lexing_directive = 0; in glcpp_parser_create()
1349 parser->lexing_version_directive = 0; in glcpp_parser_create()
1350 parser->space_tokens = 1; in glcpp_parser_create()
1351 parser->last_token_was_newline = 0; in glcpp_parser_create()
1352 parser->last_token_was_space = 0; in glcpp_parser_create()
1353 parser->first_non_space_token_this_line = 1; in glcpp_parser_create()
1354 parser->newline_as_space = 0; in glcpp_parser_create()
1355 parser->in_control_line = 0; in glcpp_parser_create()
1356 parser->paren_count = 0; in glcpp_parser_create()
1357 parser->commented_newlines = 0; in glcpp_parser_create()
1359 parser->skip_stack = NULL; in glcpp_parser_create()
1360 parser->skipping = 0; in glcpp_parser_create()
1362 parser->lex_from_list = NULL; in glcpp_parser_create()
1363 parser->lex_from_node = NULL; in glcpp_parser_create()
1365 parser->output = ralloc_strdup(parser, ""); in glcpp_parser_create()
1366 parser->output_length = 0; in glcpp_parser_create()
1367 parser->info_log = ralloc_strdup(parser, ""); in glcpp_parser_create()
1368 parser->info_log_length = 0; in glcpp_parser_create()
1369 parser->error = 0; in glcpp_parser_create()
1371 parser->extensions = extensions; in glcpp_parser_create()
1372 parser->state = state; in glcpp_parser_create()
1373 parser->api = api; in glcpp_parser_create()
1374 parser->version = 0; in glcpp_parser_create()
1375 parser->version_set = false; in glcpp_parser_create()
1377 parser->has_new_line_number = 0; in glcpp_parser_create()
1378 parser->new_line_number = 1; in glcpp_parser_create()
1379 parser->has_new_source_number = 0; in glcpp_parser_create()
1380 parser->new_source_number = 0; in glcpp_parser_create()
1382 parser->is_gles = false; in glcpp_parser_create()
1384 return parser; in glcpp_parser_create()
1388 glcpp_parser_destroy(glcpp_parser_t *parser) in glcpp_parser_destroy() argument
1390 glcpp_lex_destroy (parser->scanner); in glcpp_parser_destroy()
1391 _mesa_hash_table_destroy(parser->defines, NULL); in glcpp_parser_destroy()
1392 ralloc_free (parser); in glcpp_parser_destroy()
1426 _arguments_parse(glcpp_parser_t *parser, in _arguments_parse() argument
1444 argument = _token_list_create (parser); in _arguments_parse()
1445 _argument_list_append (parser, arguments, argument); in _arguments_parse()
1458 argument = _token_list_create (parser); in _arguments_parse()
1459 _argument_list_append (parser, arguments, argument); in _arguments_parse()
1466 _token_list_append(parser, argument, node->token); in _arguments_parse()
1479 _token_list_create_with_one_ival(glcpp_parser_t *parser, int type, int ival) in _token_list_create_with_one_ival() argument
1484 list = _token_list_create(parser); in _token_list_create_with_one_ival()
1485 node = _token_create_ival(parser, type, ival); in _token_list_create_with_one_ival()
1486 _token_list_append(parser, list, node); in _token_list_create_with_one_ival()
1492 _token_list_create_with_one_space(glcpp_parser_t *parser) in _token_list_create_with_one_space() argument
1494 return _token_list_create_with_one_ival(parser, SPACE, SPACE); in _token_list_create_with_one_space()
1498 _token_list_create_with_one_integer(glcpp_parser_t *parser, int ival) in _token_list_create_with_one_integer() argument
1500 return _token_list_create_with_one_ival(parser, INTEGER, ival); in _token_list_create_with_one_integer()
1525 _glcpp_parser_evaluate_defined(glcpp_parser_t *parser, token_node_t *node, in _glcpp_parser_evaluate_defined() argument
1571 return _mesa_hash_table_search(parser->defines, in _glcpp_parser_evaluate_defined()
1575 glcpp_error (&defined->token->location, parser, in _glcpp_parser_evaluate_defined()
1583 _glcpp_parser_evaluate_defined_in_list(glcpp_parser_t *parser, in _glcpp_parser_evaluate_defined_in_list() argument
1600 value = _glcpp_parser_evaluate_defined (parser, node, &last); in _glcpp_parser_evaluate_defined_in_list()
1604 replacement = linear_alloc_child(parser->linalloc, sizeof(token_node_t)); in _glcpp_parser_evaluate_defined_in_list()
1605 replacement->token = _token_create_ival (parser, INTEGER, value); in _glcpp_parser_evaluate_defined_in_list()
1634 _glcpp_parser_expand_and_lex_from(glcpp_parser_t *parser, int head_token_type, in _glcpp_parser_expand_and_lex_from() argument
1640 expanded = _token_list_create (parser); in _glcpp_parser_expand_and_lex_from()
1641 token = _token_create_ival (parser, head_token_type, head_token_type); in _glcpp_parser_expand_and_lex_from()
1642 _token_list_append (parser, expanded, token); in _glcpp_parser_expand_and_lex_from()
1643 _glcpp_parser_expand_token_list (parser, list, mode); in _glcpp_parser_expand_and_lex_from()
1645 glcpp_parser_lex_from (parser, expanded); in _glcpp_parser_expand_and_lex_from()
1649 _glcpp_parser_apply_pastes(glcpp_parser_t *parser, token_list_t *list) in _glcpp_parser_apply_pastes() argument
1676 …yyerror(&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n"); in _glcpp_parser_apply_pastes()
1680 node->token = _token_paste(parser, node->token, next_non_space->token); in _glcpp_parser_apply_pastes()
1710 _glcpp_parser_expand_function(glcpp_parser_t *parser, token_node_t *node, in _glcpp_parser_expand_function() argument
1723 entry = _mesa_hash_table_search(parser->defines, identifier); in _glcpp_parser_expand_function()
1728 arguments = _argument_list_create(parser); in _glcpp_parser_expand_function()
1729 status = _arguments_parse(parser, arguments, node, last); in _glcpp_parser_expand_function()
1737 …glcpp_error(&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifi… in _glcpp_parser_expand_function()
1743 return _token_list_create_with_one_space(parser); in _glcpp_parser_expand_function()
1751 glcpp_error(&node->token->location, parser, in _glcpp_parser_expand_function()
1759 substituted = _token_list_create(parser); in _glcpp_parser_expand_function()
1771 expanded_argument = _token_list_copy(parser, argument); in _glcpp_parser_expand_function()
1772 _glcpp_parser_expand_token_list(parser, expanded_argument, mode); in _glcpp_parser_expand_function()
1777 new_token = _token_create_ival(parser, PLACEHOLDER, in _glcpp_parser_expand_function()
1779 _token_list_append(parser, substituted, new_token); in _glcpp_parser_expand_function()
1782 _token_list_append(parser, substituted, node->token); in _glcpp_parser_expand_function()
1791 _glcpp_parser_apply_pastes(parser, substituted); in _glcpp_parser_expand_function()
1815 _glcpp_parser_expand_node(glcpp_parser_t *parser, token_node_t *node, in _glcpp_parser_expand_node() argument
1834 return _token_list_create_with_one_integer(parser, node->token->location.first_line); in _glcpp_parser_expand_node()
1837 return _token_list_create_with_one_integer(parser, node->token->location.source); in _glcpp_parser_expand_node()
1840 entry = _mesa_hash_table_search(parser->defines, identifier); in _glcpp_parser_expand_node()
1849 if (_parser_active_list_contains (parser, identifier)) { in _glcpp_parser_expand_node()
1856 str = linear_strdup(parser->linalloc, token->value.str); in _glcpp_parser_expand_node()
1857 final = _token_create_str(parser, OTHER, str); in _glcpp_parser_expand_node()
1858 expansion = _token_list_create(parser); in _glcpp_parser_expand_node()
1859 _token_list_append(parser, expansion, final); in _glcpp_parser_expand_node()
1868 return _token_list_create_with_one_space(parser); in _glcpp_parser_expand_node()
1870 replacement = _token_list_copy(parser, macro->replacements); in _glcpp_parser_expand_node()
1871 _glcpp_parser_apply_pastes(parser, replacement); in _glcpp_parser_expand_node()
1875 return _glcpp_parser_expand_function(parser, node, last, mode); in _glcpp_parser_expand_node()
1886 _parser_active_list_push(glcpp_parser_t *parser, const char *identifier, in _parser_active_list_push() argument
1891 node = linear_alloc_child(parser->linalloc, sizeof(active_list_t)); in _parser_active_list_push()
1892 node->identifier = linear_strdup(parser->linalloc, identifier); in _parser_active_list_push()
1894 node->next = parser->active; in _parser_active_list_push()
1896 parser->active = node; in _parser_active_list_push()
1900 _parser_active_list_pop(glcpp_parser_t *parser) in _parser_active_list_pop() argument
1902 active_list_t *node = parser->active; in _parser_active_list_pop()
1905 parser->active = NULL; in _parser_active_list_pop()
1909 node = parser->active->next; in _parser_active_list_pop()
1910 parser->active = node; in _parser_active_list_pop()
1914 _parser_active_list_contains(glcpp_parser_t *parser, const char *identifier) in _parser_active_list_contains() argument
1918 if (parser->active == NULL) in _parser_active_list_contains()
1921 for (node = parser->active; node; node = node->next) in _parser_active_list_contains()
1950 _glcpp_parser_expand_token_list(glcpp_parser_t *parser, token_list_t *list, in _glcpp_parser_expand_token_list() argument
1956 active_list_t *active_initial = parser->active; in _glcpp_parser_expand_token_list()
1967 _glcpp_parser_evaluate_defined_in_list (parser, list); in _glcpp_parser_expand_token_list()
1971 while (parser->active && parser->active->marker == node) in _glcpp_parser_expand_token_list()
1972 _parser_active_list_pop (parser); in _glcpp_parser_expand_token_list()
1974 expansion = _glcpp_parser_expand_node (parser, node, &last, mode); in _glcpp_parser_expand_token_list()
1979 _glcpp_parser_evaluate_defined_in_list (parser, expansion); in _glcpp_parser_expand_token_list()
1983 while (parser->active && parser->active->marker == n) { in _glcpp_parser_expand_token_list()
1984 _parser_active_list_pop (parser); in _glcpp_parser_expand_token_list()
1987 _parser_active_list_push(parser, node->token->value.str, last->next); in _glcpp_parser_expand_token_list()
2017 while (parser->active && parser->active != active_initial) in _glcpp_parser_expand_token_list()
2018 _parser_active_list_pop (parser); in _glcpp_parser_expand_token_list()
2024 _glcpp_parser_print_expanded_token_list(glcpp_parser_t *parser, in _glcpp_parser_print_expanded_token_list() argument
2030 _glcpp_parser_expand_token_list (parser, list, EXPANSION_MODE_IGNORE_DEFINED); in _glcpp_parser_print_expanded_token_list()
2034 _token_list_print (parser, list); in _glcpp_parser_print_expanded_token_list()
2038 _check_for_reserved_macro_name(glcpp_parser_t *parser, YYLTYPE *loc, in _check_for_reserved_macro_name() argument
2059 glcpp_warning(loc, parser, "Macro names containing \"__\" are reserved " in _check_for_reserved_macro_name()
2063 glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n"); in _check_for_reserved_macro_name()
2066 glcpp_error (loc, parser, "\"defined\" cannot be used as a macro name"); in _check_for_reserved_macro_name()
2085 _define_object_macro(glcpp_parser_t *parser, YYLTYPE *loc, in _define_object_macro() argument
2095 _check_for_reserved_macro_name(parser, loc, identifier); in _define_object_macro()
2097 macro = linear_alloc_child(parser->linalloc, sizeof(macro_t)); in _define_object_macro()
2101 macro->identifier = linear_strdup(parser->linalloc, identifier); in _define_object_macro()
2104 entry = _mesa_hash_table_search(parser->defines, identifier); in _define_object_macro()
2110 glcpp_error (loc, parser, "Redefinition of macro %s\n", identifier); in _define_object_macro()
2113 _mesa_hash_table_insert (parser->defines, identifier, macro); in _define_object_macro()
2117 _define_function_macro(glcpp_parser_t *parser, YYLTYPE *loc, in _define_function_macro() argument
2125 _check_for_reserved_macro_name(parser, loc, identifier); in _define_function_macro()
2129 glcpp_error (loc, parser, "Duplicate macro parameter \"%s\"", dup); in _define_function_macro()
2132 macro = linear_alloc_child(parser->linalloc, sizeof(macro_t)); in _define_function_macro()
2136 macro->identifier = linear_strdup(parser->linalloc, identifier); in _define_function_macro()
2139 entry = _mesa_hash_table_search(parser->defines, identifier); in _define_function_macro()
2145 glcpp_error (loc, parser, "Redefinition of macro %s\n", identifier); in _define_function_macro()
2148 _mesa_hash_table_insert(parser->defines, identifier, macro); in _define_function_macro()
2152 glcpp_parser_lex(YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser) in glcpp_parser_lex() argument
2157 if (parser->lex_from_list == NULL) { in glcpp_parser_lex()
2158 ret = glcpp_lex(yylval, yylloc, parser->scanner); in glcpp_parser_lex()
2172 if (parser->newline_as_space) { in glcpp_parser_lex()
2174 parser->paren_count++; in glcpp_parser_lex()
2176 parser->paren_count--; in glcpp_parser_lex()
2177 if (parser->paren_count == 0) in glcpp_parser_lex()
2178 parser->newline_as_space = 0; in glcpp_parser_lex()
2182 if (parser->paren_count == 0) in glcpp_parser_lex()
2183 parser->newline_as_space = 0; in glcpp_parser_lex()
2185 } else if (parser->in_control_line) { in glcpp_parser_lex()
2187 parser->in_control_line = 0; in glcpp_parser_lex()
2192 parser->in_control_line = 1; in glcpp_parser_lex()
2194 struct hash_entry *entry = _mesa_hash_table_search(parser->defines, in glcpp_parser_lex()
2198 parser->newline_as_space = 1; in glcpp_parser_lex()
2199 parser->paren_count = 0; in glcpp_parser_lex()
2206 node = parser->lex_from_node; in glcpp_parser_lex()
2209 parser->lex_from_list = NULL; in glcpp_parser_lex()
2216 parser->lex_from_node = node->next; in glcpp_parser_lex()
2222 glcpp_parser_lex_from(glcpp_parser_t *parser, token_list_t *list) in glcpp_parser_lex_from() argument
2226 assert (parser->lex_from_list == NULL); in glcpp_parser_lex_from()
2229 parser->lex_from_list = _token_list_create (parser); in glcpp_parser_lex_from()
2234 _token_list_append (parser, parser->lex_from_list, node->token); in glcpp_parser_lex_from()
2237 parser->lex_from_node = parser->lex_from_list->head; in glcpp_parser_lex_from()
2240 if (parser->lex_from_node == NULL) { in glcpp_parser_lex_from()
2241 parser->lex_from_list = NULL; in glcpp_parser_lex_from()
2246 _glcpp_parser_skip_stack_push_if(glcpp_parser_t *parser, YYLTYPE *loc, in _glcpp_parser_skip_stack_push_if() argument
2252 if (parser->skip_stack) in _glcpp_parser_skip_stack_push_if()
2253 current = parser->skip_stack->type; in _glcpp_parser_skip_stack_push_if()
2255 node = linear_alloc_child(parser->linalloc, sizeof(skip_node_t)); in _glcpp_parser_skip_stack_push_if()
2268 node->next = parser->skip_stack; in _glcpp_parser_skip_stack_push_if()
2269 parser->skip_stack = node; in _glcpp_parser_skip_stack_push_if()
2273 _glcpp_parser_skip_stack_change_if(glcpp_parser_t *parser, YYLTYPE *loc, in _glcpp_parser_skip_stack_change_if() argument
2276 if (parser->skip_stack == NULL) { in _glcpp_parser_skip_stack_change_if()
2277 glcpp_error (loc, parser, "#%s without #if\n", type); in _glcpp_parser_skip_stack_change_if()
2281 if (parser->skip_stack->type == SKIP_TO_ELSE) { in _glcpp_parser_skip_stack_change_if()
2283 parser->skip_stack->type = SKIP_NO_SKIP; in _glcpp_parser_skip_stack_change_if()
2285 parser->skip_stack->type = SKIP_TO_ENDIF; in _glcpp_parser_skip_stack_change_if()
2290 _glcpp_parser_skip_stack_pop(glcpp_parser_t *parser, YYLTYPE *loc) in _glcpp_parser_skip_stack_pop() argument
2294 if (parser->skip_stack == NULL) { in _glcpp_parser_skip_stack_pop()
2295 glcpp_error (loc, parser, "#endif without #if\n"); in _glcpp_parser_skip_stack_pop()
2299 node = parser->skip_stack; in _glcpp_parser_skip_stack_pop()
2300 parser->skip_stack = node->next; in _glcpp_parser_skip_stack_pop()
2304 _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t version, in _glcpp_parser_handle_version_declaration() argument
2308 if (parser->version_set) in _glcpp_parser_handle_version_declaration()
2311 parser->version = version; in _glcpp_parser_handle_version_declaration()
2312 parser->version_set = true; in _glcpp_parser_handle_version_declaration()
2314 add_builtin_define (parser, "__VERSION__", version); in _glcpp_parser_handle_version_declaration()
2316 parser->is_gles = (version == 100) || in _glcpp_parser_handle_version_declaration()
2320 if (parser->is_gles) in _glcpp_parser_handle_version_declaration()
2321 add_builtin_define(parser, "GL_ES", 1); in _glcpp_parser_handle_version_declaration()
2323 add_builtin_define(parser, "GL_core_profile", 1); in _glcpp_parser_handle_version_declaration()
2330 if (version >= 130 || parser->is_gles) in _glcpp_parser_handle_version_declaration()
2331 add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1); in _glcpp_parser_handle_version_declaration()
2334 if (parser->extensions) in _glcpp_parser_handle_version_declaration()
2335 parser->extensions(parser->state, add_builtin_define, parser, in _glcpp_parser_handle_version_declaration()
2336 version, parser->is_gles); in _glcpp_parser_handle_version_declaration()
2339 ralloc_asprintf_rewrite_tail(&parser->output, &parser->output_length, in _glcpp_parser_handle_version_declaration()
2353 glcpp_parser_resolve_implicit_version(glcpp_parser_t *parser) in glcpp_parser_resolve_implicit_version() argument
2355 int language_version = parser->api == API_OPENGLES2 ? in glcpp_parser_resolve_implicit_version()
2358 _glcpp_parser_handle_version_declaration(parser, language_version, in glcpp_parser_resolve_implicit_version()