Home | History | Annotate | Download | only in glcpp

Lines Matching refs:parser

1 /* A Bison parser, made by GNU Bison 2.4.3.  */
22 part or all of the Bison parser skeleton and distribute that work
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
110 yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
113 _define_object_macro (glcpp_parser_t *parser,
119 _define_function_macro (glcpp_parser_t *parser,
187 _glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list);
190 _glcpp_parser_expand_token_list (glcpp_parser_t *parser,
194 _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
198 _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
202 _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
206 _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
211 glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
214 glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
217 add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
398 /* The parser invokes alloca or malloc; define the necessary symbols. */
975 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
1032 # define YYLEX yylex (&yylval, &yylloc, parser)
1055 Type, Value, Location, parser); \
1069 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1072 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1077 glcpp_parser_t *parser;
1083 YYUSE (parser);
1105 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1108 yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1113 glcpp_parser_t *parser;
1123 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser);
1166 yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser)
1169 yy_reduce_print (yyvsp, yylsp, yyrule, parser)
1173 glcpp_parser_t *parser;
1187 , &(yylsp[(yyi + 1) - (yynrhs)]) , parser);
1195 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1209 /* YYINITDEPTH -- initial size of the parser's stacks. */
1448 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser)
1451 yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser)
1456 glcpp_parser_t *parser;
1461 YYUSE (parser);
1484 int yyparse (glcpp_parser_t *parser);
1512 yyparse (glcpp_parser_t *parser)
1515 yyparse (parser)
1516 glcpp_parser_t *parser;
1802 unconditionally makes the parser a bit smaller, and it avoids a
1816 glcpp_print(parser->output, "\n");
1825 _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
1826 glcpp_print(parser->output, "\n");
1836 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
1845 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
1854 _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
1863 _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
1872 _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
1881 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
1883 hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
1902 if (parser->skip_stack == NULL ||
1903 parser->skip_stack->type == SKIP_NO_SKIP)
1905 _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list));
1909 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0);
1910 parser->skip_stack->type = SKIP_TO_ENDIF;
1922 if (parser->skip_stack == NULL ||
1923 parser->skip_stack->type == SKIP_NO_SKIP)
1925 glcpp_error(& (yylsp[(1) - (2)]), parser, "#if with no expression");
1927 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (2)]), 0);
1936 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1938 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
1947 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1949 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
1965 if (parser->skip_stack &&
1966 parser->skip_stack->type == SKIP_TO_ELSE)
1968 _glcpp_parser_expand_if (parser
1972 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]),
1985 if (parser->skip_stack &&
1986 parser->skip_stack->type == SKIP_TO_ELSE)
1988 glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif with no expression");
1992 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]),
1994 glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression");
2004 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1);
2013 _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)]));
2022 macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
2024 hash_table_remove (parser->defines, "__VERSION__");
2027 add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
2030 add_builtin_define (parser, "GL_ES", 1);
2038 add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
2040 glcpp_printf(parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival));
2280 (yyval.string_list) = _string_list_create (parser);
2309 yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
2325 glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
2334 int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
2335 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2344 int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
2345 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2354 (yyval.token_list) = _token_list_create (parser);
2356 hieralloc_unlink (parser, (yyvsp[(1) - (1)].token));
2367 hieralloc_unlink (parser, (yyvsp[(2) - (2)].token));
2376 parser->space_tokens = 1;
2377 (yyval.token_list) = _token_list_create (parser);
2379 hieralloc_unlink (parser, (yyvsp[(1) - (1)].token));
2390 hieralloc_unlink (parser, (yyvsp[(2) - (2)].token));
2399 (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
2409 (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
2419 (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
2429 (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
2439 (yyval.token) = _token_create_ival (parser, SPACE, SPACE);
2700 yyerror (&yylloc, parser, YY_("syntax error"));
2724 yyerror (&yylloc, parser, yymsg);
2728 yyerror (&yylloc, parser, YY_("syntax error"));
2752 yytoken, &yylval, &yylloc, parser);
2809 yystos[yystate], yyvsp, yylsp, parser);
2849 yyerror (&yylloc, parser, YY_("memory exhausted"));
2857 yytoken, &yylval, &yylloc, parser);
2865 yystos[*yyssp], yyvsp, yylsp, parser);
3275 _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
3346 glcpp_error (&token->location, parser, "");
3347 glcpp_print (parser->info_log, "Pasting \"");
3348 _token_print (&parser->info_log, token);
3349 glcpp_print (parser->info_log, "\" and \"");
3350 _token_print (&parser->info_log, other);
3351 glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
3357 _token_list_print (glcpp_parser_t *parser, token_list_t *list)
3365 _token_print (&parser->output, node->token);
3369 yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
3371 glcpp_error(locp, parser, "%s", error);
3374 static void add_builtin_define(glcpp_parser_t *parser,
3380 tok = _token_create_ival (parser, INTEGER, value);
3382 list = _token_list_create(parser);
3384 _define_object_macro(parser, NULL, name, list);
3386 hieralloc_unlink(parser, tok);
3392 glcpp_parser_t *parser;
3395 parser = hieralloc (NULL, glcpp_parser_t);
3397 glcpp_lex_init_extra (parser, &parser->scanner);
3398 parser->defines = hash_table_ctor (32, hash_table_string_hash,
3400 parser->active = NULL;
3401 parser->lexing_if = 0;
3402 parser->space_tokens = 1;
3403 parser->newline_as_space = 0;
3404 parser->in_control_line = 0;
3405 parser->paren_count = 0;
3407 parser->skip_stack = NULL;
3409 parser->lex_from_list = NULL;
3410 parser->lex_from_node = NULL;
3412 parser->output = hieralloc_strdup(parser, "");
3413 parser->info_log = hieralloc_strdup(parser, "");
3414 parser->error = 0;
3417 add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
3418 add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
3421 add_builtin_define(parser, "GL_ES", 1);
3425 add_builtin_define(parser, "GL_EXT_texture_array", 1);
3429 add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
3433 add_builtin_define(parser, "GL_ARB_explicit_attrib_location", 1);
3437 add_builtin_define(parser, "__VERSION__", language_version);
3439 return parser;
3443 glcpp_parser_parse (glcpp_parser_t *parser)
3445 return yyparse (parser);
3449 glcpp_parser_destroy (glcpp_parser_t *parser)
3451 glcpp_lex_destroy (parser->scanner);
3452 hash_table_dtor (parser->defines);
3453 hieralloc_free (parser);
3560 parser, int type, token_list_t *list)
3565 expanded = _token_list_create (parser);
3566 token = _token_create_ival (parser, type, type);
3568 _glcpp_parser_expand_token_list (parser, list);
3570 glcpp_parser_lex_from (parser, expanded);
3591 _glcpp_parser_expand_function (glcpp_parser_t *parser,
3605 macro = hash_table_find (parser->defines, identifier);
3609 arguments = _argument_list_create (parser);
3618 glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
3625 return _token_list_create_with_one_space (parser);
3634 glcpp_error (&node->token->location, parser,
3660 expanded_argument = _token_list_copy (parser,
3662 _glcpp_parser_expand_token_list (parser,
3708 yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
3712 node->token = _token_paste (parser, node->token, next_non_space->token);
3741 _glcpp_parser_expand_node (glcpp_parser_t *parser,
3764 macro = hash_table_find (parser->defines, identifier);
3772 if (_active_list_contains (parser->active, identifier)) {
3780 str = hieralloc_strdup (parser, token->value.str);
3781 final = _token_create_str (parser, OTHER, str);
3782 expansion = _token_list_create (parser);
3794 return _token_list_create_with_one_space (parser);
3796 return _token_list_copy (parser, macro->replacements);
3799 return _glcpp_parser_expand_function (parser, node, last);
3859 _glcpp_parser_expand_token_list (glcpp_parser_t *parser,
3876 while (parser->active && parser->active->marker == node)
3877 parser->active = _active_list_pop (parser->active);
3881 expansion = _glcpp_parser_expand_node (parser, node, &last);
3886 while (parser->active &&
3887 parser->active->marker == n)
3889 parser->active = _active_list_pop (parser->active);
3892 parser->active = _active_list_push (parser->active,
3921 while (parser->active)
3922 parser->active = _active_list_pop (parser->active);
3928 _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
3934 _glcpp_parser_expand_token_list (parser, list);
3938 _token_list_print (parser, list);
3942 _check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
3949 glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
3952 glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
3972 _define_object_macro (glcpp_parser_t *parser,
3980 _check_for_reserved_macro_name(parser, loc, identifier);
3982 macro = hieralloc (parser, macro_t);
3989 previous = hash_table_find (parser->defines, identifier);
3995 glcpp_error (loc, parser, "Redefinition of macro %s\n",
3999 hash_table_insert (parser->defines, macro, identifier);
4003 _define_function_macro (glcpp_parser_t *parser,
4011 _check_for_reserved_macro_name(parser, loc, identifier);
4013 macro = hieralloc (parser, macro_t);
4020 previous = hash_table_find (parser->defines, identifier);
4026 glcpp_error (loc, parser, "Redefinition of macro %s\n",
4030 hash_table_insert (parser->defines, macro, identifier);
4034 glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
4039 if (parser->lex_from_list == NULL) {
4040 ret = glcpp_lex (yylval, yylloc, parser->scanner);
4054 if (parser->newline_as_space)
4057 parser->paren_count++;
4059 parser->paren_count--;
4060 if (parser->paren_count == 0)
4061 parser->newline_as_space = 0;
4065 if (parser->paren_count == 0)
4066 parser->newline_as_space = 0;
4069 else if (parser->in_control_line)
4072 parser->in_control_line = 0;
4080 parser->in_control_line = 1;
4085 macro = hash_table_find (parser->defines,
4088 parser->newline_as_space = 1;
4089 parser->paren_count = 0;
4096 node = parser->lex_from_node;
4099 hieralloc_free (parser->lex_from_list);
4100 parser->lex_from_list = NULL;
4107 parser->lex_from_node = node->next;
4113 glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
4117 assert (parser->lex_from_list == NULL);
4120 parser->lex_from_list = _token_list_create (parser);
4125 _token_list_append (parser->lex_from_list, node->token);
4130 parser->lex_from_node = parser->lex_from_list->head;
4133 if (parser->lex_from_node == NULL) {
4134 hieralloc_free (parser->lex_from_list);
4135 parser->lex_from_list = NULL;
4140 _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
4146 if (parser->skip_stack)
4147 current = parser->skip_stack->type;
4149 node = hieralloc (parser, skip_node_t);
4161 node->next = parser->skip_stack;
4162 parser->skip_stack = node;
4166 _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
4169 if (parser->skip_stack == NULL) {
4170 glcpp_error (loc, parser, "%s without #if\n", type);
4174 if (parser->skip_stack->type == SKIP_TO_ELSE) {
4176 parser->skip_stack->type = SKIP_NO_SKIP;
4178 parser->skip_stack->type = SKIP_TO_ENDIF;
4183 _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
4187 if (parser->skip_stack == NULL) {
4188 glcpp_error (loc, parser, "#endif without #if\n");
4192 node = parser->skip_stack;
4193 parser