Lines Matching refs:token
92 _token_list_append(glcpp_parser_t *parser, token_list_t *list, token_t *token);
116 * prefixing a token of type 'head_token_type').
177 %token DEFINED ELIF_EXPANDED HASH_TOKEN DEFINE_TOKEN FUNC_IDENTIFIER OBJ_IDENTIFIER ELIF ELSE ENDIF ERROR_TOKEN IF IFDEF IFNDEF LINE PRAGMA UNDEF VERSION_TOKEN GARBAGE IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE PLUS_PLUS MINUS_MINUS
178 %token PASTE
183 %type <token> preprocessing_token
948 token_t *token;
950 token = linear_alloc_child(parser->linalloc, sizeof(token_t));
951 token->type = type;
952 token->value.str = str;
954 return token;
960 token_t *token;
962 token = linear_alloc_child(parser->linalloc, sizeof(token_t));
963 token->type = type;
964 token->value.ival = ival;
966 return token;
983 _token_list_append(glcpp_parser_t *parser, token_list_t *list, token_t *token)
988 node->token = token;
998 if (token->type != SPACE)
1030 *new_token = *node->token;
1055 while (n != NULL && n->token->type == SPACE)
1081 if (node_a == NULL && node_b->token->type == SPACE) {
1082 while (node_b && node_b->token->type == SPACE)
1086 if (node_b == NULL && node_a->token->type == SPACE) {
1087 while (node_a && node_a->token->type == SPACE)
1100 if (node_a->token->type == SPACE && node_b->token->type == SPACE) {
1101 while (node_a && node_a->token->type == SPACE)
1103 while (node_b && node_b->token->type == SPACE)
1108 if (node_a->token->type != node_b->token->type)
1111 switch (node_a->token->type) {
1113 if (node_a->token->value.ival != node_b->token->value.ival) {
1120 if (strcmp(node_a->token->value.str, node_b->token->value.str)) {
1134 _token_print(struct _mesa_string_buffer *out, token_t *token)
1136 if (token->type < 256) {
1137 _mesa_string_buffer_append_char(out, token->type);
1141 switch (token->type) {
1143 _mesa_string_buffer_printf(out, "%" PRIiMAX, token->value.ival);
1148 _mesa_string_buffer_append(out, token->value.str);
1193 assert(!"Error: Don't know how to print token.");
1199 /* Return a new token formed by pasting 'token' and 'other'. Note that this
1200 * function may return 'token' or 'other' directly rather than allocating
1204 * the final result is a valid single token. */
1206 _token_paste(glcpp_parser_t *parser, token_t *token, token_t *other)
1212 return token;
1214 /* When 'token' is a placeholder, just return 'other'. */
1215 if (token->type == PLACEHOLDER)
1220 switch (token->type) {
1252 /* Inherit the location from the first token */
1253 combined->location = token->location;
1261 * There are some exceptions here. Notably, if the first token
1263 * the second token must also be an integer or must be a
1266 if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING || token->type == INTEGER) &&
1275 if (token->type == INTEGER_STRING || token->type == INTEGER) {
1290 if (token->type == INTEGER)
1291 str = linear_asprintf(parser->linalloc, "%" PRIiMAX, token->value.ival);
1293 str = linear_strdup(parser->linalloc, token->value.str);
1300 /* New token is same type as original token, unless we
1303 combined_type = token->type;
1308 combined->location = token->location;
1313 glcpp_error (&token->location, parser, "");
1315 _token_print(parser->info_log, token);
1318 _mesa_string_buffer_append(parser->info_log, "\" does not give a valid preprocessing token.\n");
1320 return token;
1332 _token_print(parser->output, node->token);
1430 * When called, 'node' should be the opening-parenthesis token, (or
1461 while (node && node->token->type == SPACE)
1464 if (node == NULL || node->token->type != '(')
1473 if (node->token->type == '(') {
1475 } else if (node->token->type == ')') {
1481 if (node->token->type == ',' && paren_count == 1) {
1488 if (node->token->type == SPACE)
1491 _token_list_append(parser, argument, node->token);
1528 /* Evaluate a DEFINED token node (based on subsequent tokens in the list).
1530 * Note: This function must only be called when "node" is a DEFINED token,
1533 * If "node" is followed, (ignoring any SPACE tokens), by an IDENTIFIER token
1542 * consumed by the evaluation, (either the token of the identifier or the
1543 * token of the closing parenthesis).
1555 assert(node->token->type == DEFINED);
1559 /* Ignore whitespace after DEFINED token. */
1560 while (node && node->token->type == SPACE)
1566 if (node->token->type == IDENTIFIER || node->token->type == OTHER) {
1568 } else if (node->token->type == '(') {
1571 /* Ignore whitespace after '(' token. */
1572 while (node && node->token->type == SPACE)
1575 if (node == NULL || (node->token->type != IDENTIFIER &&
1576 node->token->type != OTHER)) {
1584 /* Ignore whitespace after identifier, before ')' token. */
1585 while (node && node->token->type == SPACE)
1588 if (node == NULL || node->token->type != ')')
1597 argument->token->value.str) ? 1 : 0;
1600 glcpp_error (&defined->token->location, parser,
1622 if (node->token->type != DEFINED)
1630 replacement->token = _token_create_ival (parser, INTEGER, value);
1651 * into a new list which is initialized with a first token of type
1663 token_t *token;
1666 token = _token_create_ival (parser, head_token_type, head_token_type);
1667 _token_list_append (parser, expanded, token);
1682 /* Look ahead for a PASTE token, skipping space. */
1684 while (next_non_space && next_non_space->token->type == SPACE)
1690 if (next_non_space->token->type != PASTE) {
1695 /* Now find the next non-space token after the PASTE. */
1697 while (next_non_space && next_non_space->token->type == SPACE)
1701 yyerror(&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
1705 node->token = _token_paste(parser, node->token, next_non_space->token);
1718 * Returns NULL if node is a simple token with no expansion, (that is,
1726 * Returns the token list that results from the expansion and sets
1729 * token of the closing right parenthesis.
1746 identifier = node->token->value.str;
1762 glcpp_error(&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
1766 /* Replace a macro defined as empty with a SPACE token. */
1776 glcpp_error(&node->token->location, parser,
1787 if (node->token->type == IDENTIFIER &&
1788 _string_list_contains(macro->parameters, node->token->value.str,
1793 * placeholder token for an empty argument. */
1807 _token_list_append(parser, substituted, node->token);
1812 * below, implement token pasting. */
1825 * Returns NULL if node is a simple token with no expansion.
1827 * Otherwise, returns the token list that results from the expansion
1833 * As the token of the closing right parenthesis in the case of
1843 token_t *token = node->token;
1849 if (token->type != IDENTIFIER) {
1854 identifier = token->value.str;
1861 node->token->location.first_line);
1865 node->token->location.source);
1879 /* We change the token type here from IDENTIFIER to OTHER to prevent any
1880 * future expansion of this unexpanded token. */
1885 str = linear_strdup(parser->linalloc, token->value.str);
1895 /* Replace a macro defined as empty with a SPACE token. */
1909 * Here, 'marker' is the token node that appears in the list after the
1957 /* Walk over the token list replacing nodes with their expansion.
1972 * token is the name of a defined macro. If the DEFINED token is
2016 _parser_active_list_push(parser, node->token->value.str, last->next);
2190 * purpose of converting a NEWLINE token into a SPACE
2191 * token, but only in the case where we have seen a
2242 *yylval = node->token->value;
2243 ret = node->token->type;
2261 if (node->token->type == SPACE)
2263 _token_list_append (parser, parser->lex_from_list, node->token);