Home | History | Annotate | Download | only in glcpp

Lines Matching refs:token

162 /* Note: This function adds a hieralloc_reference() to token.
167 _token_list_append (token_list_t *list, token_t *token);
237 /* Enabling the token table. */
671 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
672 token YYLEX-NUM. */
779 positive, shift that token. If negative, reduce the rule which
963 #define YYBACKUP(Token, Value) \
967 yychar = (Token); \
1117 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1329 /* Copy into YYRESULT an error message about the unexpected token
1566 /* Lookahead token as an internal (translated) token number. */
1597 yychar = YYEMPTY; /* Cause a token to be read. */
1721 lookahead token if we need one and don't already have one. */
1723 /* First try to decide what to do without reference to lookahead token. */
1728 /* Not known => get a lookahead token if don't already have one. */
1733 YYDPRINTF ((stderr, "Reading a token: "));
1745 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1748 /* If the proper action on seeing token YYTOKEN is to reduce or to
1767 /* Shift the lookahead token. */
1770 /* Discard the shifted token. */
2335 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2345 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2355 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2356 hieralloc_unlink (parser, (yyvsp[(1) - (1)].token));
2366 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2367 hieralloc_unlink (parser, (yyvsp[(2) - (2)].token));
2378 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2379 hieralloc_unlink (parser, (yyvsp[(1) - (1)].token));
2389 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2390 hieralloc_unlink (parser, (yyvsp[(2) - (2)].token));
2399 (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
2400 (yyval.token)->location = yylloc;
2409 (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
2410 (yyval.token)->location = yylloc;
2419 (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
2420 (yyval.token)->location = yylloc;
2429 (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
2430 (yyval.token)->location = yylloc;
2439 (yyval.token) = _token_create_ival (parser, SPACE, SPACE);
2440 (yyval.token)->location = yylloc;
2740 /* If just tried and failed to reuse lookahead token after an
2757 /* Else will try to reuse lookahead token after shifting the error
2758 token. */
2787 yyerrstatus = 3; /* Each real token shifted decrements this. */
2803 /* Pop the current state because it cannot handle the error token. */
2823 /* Shift the error token. */
3049 token_t *token;
3051 token = hieralloc (ctx, token_t);
3052 token->type = type;
3053 token->value.str = hieralloc_steal (token, str);
3055 return token;
3061 token_t *token;
3063 token = hieralloc (ctx, token_t);
3064 token->type = type;
3065 token->value.ival = ival;
3067 return token;
3084 _token_list_append (token_list_t *list, token_t *token)
3089 node->token = hieralloc_reference (list, token);
3100 if (token->type != SPACE)
3131 _token_list_append (copy, node->token);
3170 if (node_a->token->type == SPACE) {
3175 if (node_b->token->type == SPACE) {
3180 if (node_a->token->type != node_b->token->type)
3183 switch (node_a->token->type) {
3185 if (node_a->token->value.ival !=
3186 node_b->token->value.ival)
3194 if (strcmp (node_a->token->value.str,
3195 node_b->token->value.str))
3210 _token_print (char **out, token_t *token)
3212 if (token->type < 256) {
3213 glcpp_printf (*out, "%c", token->type);
3217 switch (token->type) {
3219 glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
3224 glcpp_print (*out, token->value.str);
3263 assert(!"Error: Don't know how to print token.");
3268 /* Return a new token (hieralloc()ed off of 'token') formed by pasting
3269 * 'token' and 'other'. Note that this function may return 'token' or
3273 * the final result is a valid single token. */
3275 _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
3281 return token;
3283 /* When 'token' is a placeholder, just return 'other'. */
3284 if (token->type == PLACEHOLDER)
3289 switch (token->type) {
3292 combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
3294 combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
3298 combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
3300 combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
3304 combined = _token_create_ival (token, EQUAL, EQUAL);
3308 combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
3312 combined = _token_create_ival (token, AND, AND);
3316 combined = _token_create_ival (token, OR, OR);
3321 /* Inherit the location from the first token */
3322 combined->location = token->location;
3331 * valid, single pre-processing token. For example, pasting
3334 if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) &&
3339 str = hieralloc_asprintf (token, "%s%s", token->value.str,
3341 combined = _token_create_str (token, token->type, str);
3342 combined->location = token->location;
3346 glcpp_error (&token->location, parser, "");
3348 _token_print (&parser->info_log, token);
3351 glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
3353 return token;
3365 _token_print (&parser->output, node->token);
3466 * When called, 'node' should be the opening-parenthesis token, (or
3497 while (node && node->token->type == SPACE)
3500 if (node == NULL || node->token->type != '(')
3509 if (node->token->type == '(')
3513 else if (node->token->type == ')')
3520 if (node->token->type == ',' &&
3531 if (node->token->type == SPACE)
3534 _token_list_append (argument, node->token);
3563 token_t *token;
3566 token = _token_create_ival (parser, type, type);
3567 _token_list_append (expanded, token);
3577 * Returns NULL if node is a simple token with no expansion, (that is,
3585 * Returns the token list that results from the expansion and sets
3588 * token of the closing right parenthesis.
3603 identifier = node->token->value.str;
3618 glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
3622 /* Replace a macro defined as empty with a SPACE token. */
3634 glcpp_error (&node->token->location, parser,
3647 if (node->token->type == IDENTIFIER &&
3649 node->token->value.str,
3656 * tokens, or append a placeholder token for
3675 _token_list_append (substituted, node->token);
3680 * below, implement token pasting. */
3689 /* Look ahead for a PASTE token, skipping space. */
3691 while (next_non_space && next_non_space->token->type == SPACE)
3697 if (next_non_space->token->type != PASTE) {
3702 /* Now find the next non-space token after the PASTE. */
3704 while (next_non_space && next_non_space->token->type == SPACE)
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);
3729 * Returns NULL if node is a simple token with no expansion.
3731 * Otherwise, returns the token list that results from the expansion
3737 * As the token of the closing right parenthesis in the case of
3745 token_t *token = node->token;
3750 if (token->type != IDENTIFIER) {
3754 if (token->type == ',') {
3755 token->type = COMMA_FINAL;
3756 token->value.ival = COMMA_FINAL;
3763 identifier = token->value.str;
3773 /* We change the token type here from IDENTIFIER to
3775 * unexpanded token. */
3780 str = hieralloc_strdup (parser, token->value.str);
3792 /* Replace a macro defined as empty with a SPACE token. */
3804 * Here, 'marker' is the token node that appears in the list after the
3853 /* Walk over the token list replacing nodes with their expansion.
3893 node->token->value.str,
4043 * purpose of converting a NEWLINE token into a SPACE
4044 * token, but only in the case where we have seen a
4104 *yylval = node->token->value;
4105 ret = node->token->type;
4123 if (node->token->type == SPACE)
4125 _token_list_append (parser->lex_from_list, node->token);