Lines Matching refs:token
103 _token_list_append(glcpp_parser_t *parser, token_list_t *list, token_t *token);
127 * prefixing a token of type 'head_token_type').
196 %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 PATH INCLUDE
197 %token PASTE
202 %type <token> preprocessing_token
1055 token_t *token;
1057 token = linear_alloc_child(parser->linalloc, sizeof(token_t));
1058 token->type = type;
1059 token->value.str = str;
1060 token->expanding = false;
1062 return token;
1068 token_t *token;
1070 token = linear_alloc_child(parser->linalloc, sizeof(token_t));
1071 token->type = type;
1072 token->value.ival = ival;
1073 token->expanding = false;
1075 return token;
1092 _token_list_append(glcpp_parser_t *parser, token_list_t *list, token_t *token)
1097 node->token = token;
1107 if (token->type != SPACE)
1139 *new_token = *node->token;
1164 while (n != NULL && n->token->type == SPACE)
1190 if (node_a == NULL && node_b->token->type == SPACE) {
1191 while (node_b && node_b->token->type == SPACE)
1198 if (node_b == NULL && node_a->token->type == SPACE) {
1199 while (node_a && node_a->token->type == SPACE)
1212 if (node_a->token->type == SPACE && node_b->token->type == SPACE) {
1213 while (node_a && node_a->token->type == SPACE)
1215 while (node_b && node_b->token->type == SPACE)
1220 if (node_a->token->type != node_b->token->type)
1223 switch (node_a->token->type) {
1225 if (node_a->token->value.ival != node_b->token->value.ival) {
1232 if (strcmp(node_a->token->value.str, node_b->token->value.str)) {
1246 _token_print(struct _mesa_string_buffer *out, token_t *token)
1248 if (token->type < 256) {
1249 _mesa_string_buffer_append_char(out, token->type);
1253 switch (token->type) {
1255 _mesa_string_buffer_printf(out, "%" PRIiMAX, token->value.ival);
1261 _mesa_string_buffer_append(out, token->value.str);
1306 assert(!"Error: Don't know how to print token.");
1312 /* Return a new token formed by pasting 'token' and 'other'. Note that this
1313 * function may return 'token' or 'other' directly rather than allocating
1317 * the final result is a valid single token. */
1319 _token_paste(glcpp_parser_t *parser, token_t *token, token_t *other)
1325 return token;
1327 /* When 'token' is a placeholder, just return 'other'. */
1328 if (token->type == PLACEHOLDER)
1333 switch (token->type) {
1365 /* Inherit the location from the first token */
1366 combined->location = token->location;
1374 * There are some exceptions here. Notably, if the first token
1376 * the second token must also be an integer or must be a
1379 if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING || token->type == INTEGER) &&
1388 if (token->type == INTEGER_STRING || token->type == INTEGER) {
1403 if (token->type == INTEGER)
1404 str = linear_asprintf(parser->linalloc, "%" PRIiMAX, token->value.ival);
1406 str = linear_strdup(parser->linalloc, token->value.str);
1413 /* New token is same type as original token, unless we
1416 combined_type = token->type;
1421 combined->location = token->location;
1426 glcpp_error (&token->location, parser, "");
1428 _token_print(parser->info_log, token);
1431 _mesa_string_buffer_append(parser->info_log, "\" does not give a valid preprocessing token.\n");
1433 return token;
1445 _token_print(parser->output, node->token);
1544 * When called, 'node' should be the opening-parenthesis token, (or
1575 while (node && node->token->type == SPACE)
1578 if (node == NULL || node->token->type != '(')
1587 if (node->token->type == '(') {
1589 } else if (node->token->type == ')') {
1595 if (node->token->type == ',' && paren_count == 1) {
1602 if (node->token->type == SPACE)
1605 _token_list_append(parser, argument, node->token);
1642 /* Evaluate a DEFINED token node (based on subsequent tokens in the list).
1644 * Note: This function must only be called when "node" is a DEFINED token,
1647 * If "node" is followed, (ignoring any SPACE tokens), by an IDENTIFIER token
1656 * consumed by the evaluation, (either the token of the identifier or the
1657 * token of the closing parenthesis).
1669 assert(node->token->type == DEFINED);
1673 /* Ignore whitespace after DEFINED token. */
1674 while (node && node->token->type == SPACE)
1680 if (node->token->type == IDENTIFIER || node->token->type == OTHER) {
1682 } else if (node->token->type == '(') {
1685 /* Ignore whitespace after '(' token. */
1686 while (node && node->token->type == SPACE)
1689 if (node == NULL || (node->token->type != IDENTIFIER &&
1690 node->token->type != OTHER)) {
1698 /* Ignore whitespace after identifier, before ')' token. */
1699 while (node && node->token->type == SPACE)
1702 if (node == NULL || node->token->type != ')')
1711 argument->token->value.str) ? 1 : 0;
1714 glcpp_error (&defined->token->location, parser,
1736 if (node->token->type != DEFINED)
1744 replacement->token = _token_create_ival (parser, INTEGER, value);
1765 * into a new list which is initialized with a first token of type
1777 token_t *token;
1780 token = _token_create_ival (parser, head_token_type, head_token_type);
1781 _token_list_append (parser, expanded, token);
1796 /* Look ahead for a PASTE token, skipping space. */
1798 while (next_non_space && next_non_space->token->type == SPACE)
1804 if (next_non_space->token->type != PASTE) {
1809 /* Now find the next non-space token after the PASTE. */
1811 while (next_non_space && next_non_space->token->type == SPACE)
1815 yyerror(&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
1819 node->token = _token_paste(parser, node->token, next_non_space->token);
1832 * Returns NULL if node is a simple token with no expansion, (that is,
1840 * Returns the token list that results from the expansion and sets
1843 * token of the closing right parenthesis.
1860 identifier = node->token->value.str;
1876 glcpp_error(&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
1880 /* Replace a macro defined as empty with a SPACE token. */
1890 glcpp_error(&node->token->location, parser,
1901 if (node->token->type == IDENTIFIER &&
1902 _string_list_contains(macro->parameters, node->token->value.str,
1907 * placeholder token for an empty argument. */
1921 _token_list_append(parser, substituted, node->token);
1926 * below, implement token pasting. */
1939 * Returns NULL if node is a simple token with no expansion.
1941 * Otherwise, returns the token list that results from the expansion
1947 * As the token of the closing right parenthesis in the case of
1958 token_t *token = node->token;
1963 /* If token is already being expanded return to avoid an infinite loop */
1964 if (token->expanding)
1968 if (token->type != IDENTIFIER) {
1973 identifier = token->value.str;
1983 node->token->location.source);
1998 * future expansion of this unexpanded token. */
2003 str = linear_strdup(parser->linalloc, token->value.str);
2004 final = _token_create_str(parser, token->type, str);
2014 /* Replace a macro defined as empty with a SPACE token. */
2028 * Here, 'marker' is the token node that appears in the list after the
2076 /* Walk over the token list replacing nodes with their expansion.
2091 * token is the name of a defined macro. If the DEFINED token is
2112 line = list->tail->token->location.last_line;
2138 _parser_active_list_push(parser, node->token->value.str, last->next);
2312 * purpose of converting a NEWLINE token into a SPACE
2313 * token, but only in the case where we have seen a
2364 *yylval = node->token->value;
2365 ret = node->token->type;
2383 if (node->token->type == SPACE)
2385 _token_list_append (parser, parser->lex_from_list, node->token);