From 39f8c46eaa4d1c3b072cd97d256fe973c1791b14 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 9 Jun 2012 16:29:38 -0700 Subject: [PATCH] glsl: glcpp: Rename and document _glcpp_parser_expand_if This function is currently used only in the expansion of #if lines, but we will soon be using it more generally (for the expansion of (_glcpp_parser_expand_and_lex_from) and some more documentation. Signed-off-by: Carl Worth Reviewed-by: Kenneth Graunke --- src/glsl/glcpp/glcpp-parse.y | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y index 78ff8fa..ee00180 100644 --- a/src/glsl/glcpp/glcpp-parse.y +++ b/src/glsl/glcpp/glcpp-parse.y @@ -105,9 +105,15 @@ _parser_active_list_pop (glcpp_parser_t *parser); static int _parser_active_list_contains (glcpp_parser_t *parser, const char *identifier); +/* Expand list, and begin lexing from the result (after first + * prefixing a token of type 'head_token_type'). + */ static void -_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list); +_glcpp_parser_expand_and_lex_from (glcpp_parser_t *parser, + int head_token_type, + token_list_t *list); +/* Perform macro expansion in-place on the given list. */ static void _glcpp_parser_expand_token_list (glcpp_parser_t *parser, token_list_t *list); @@ -233,7 +239,8 @@ control_line: if (parser->skip_stack == NULL || parser->skip_stack->type == SKIP_NO_SKIP) { - _glcpp_parser_expand_if (parser, IF_EXPANDED, $2); + _glcpp_parser_expand_and_lex_from (parser, + IF_EXPANDED, $2); } else { @@ -272,7 +279,8 @@ control_line: if (parser->skip_stack && parser->skip_stack->type == SKIP_TO_ELSE) { - _glcpp_parser_expand_if (parser, ELIF_EXPANDED, $2); + _glcpp_parser_expand_and_lex_from (parser, + ELIF_EXPANDED, $2); } else { @@ -1272,14 +1280,21 @@ _token_list_create_with_one_space (void *ctx) return list; } +/* Perform macro expansion on 'list', placing the resulting tokens + * into a new list which is initialized with a first token of type + * 'head_token_type'. Then begin lexing from the resulting list, + * (return to the current lexing source when this list is exhausted). + */ static void -_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list) +_glcpp_parser_expand_and_lex_from (glcpp_parser_t *parser, + int head_token_type, + token_list_t *list) { token_list_t *expanded; token_t *token; expanded = _token_list_create (parser); - token = _token_create_ival (parser, type, type); + token = _token_create_ival (parser, head_token_type, head_token_type); _token_list_append (expanded, token); _glcpp_parser_expand_token_list (parser, list); _token_list_append_list (expanded, list); -- 2.7.4