From: Carl Worth Date: Fri, 14 May 2010 19:05:37 +0000 (-0700) Subject: Fix expansion of composited macros. X-Git-Tag: 062012170305~10660^2~625^2~100^2~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=38bd27b444f610904320b5aa9d37e43be9164697;p=profile%2Fivi%2Fmesa.git Fix expansion of composited macros. This is a case such as "foo(bar(x))". The recently added test for this now passes. --- diff --git a/glcpp-parse.y b/glcpp-parse.y index e70b329..f972ec3 100644 --- a/glcpp-parse.y +++ b/glcpp-parse.y @@ -106,7 +106,7 @@ _argument_list_member_at (argument_list_t *list, int index); %lex-param {void *scanner} %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO SPACE TOKEN UNDEF -%type FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO TOKEN word word_or_symbol +%type FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO replacement_word TOKEN word %type argument macro parameter_list replacement_list %type argument_list @@ -171,6 +171,9 @@ argument: $$ = _string_list_create (parser); _string_list_append_item ($$, $1); } +| macro { + $$ = $1; + } | argument word { _string_list_append_item ($1, $2); talloc_free ($2); @@ -227,18 +230,28 @@ directive: ; replacement_list: - word_or_symbol { + replacement_word { $$ = _string_list_create (parser); _string_list_append_item ($$, $1); talloc_free ($1); } -| replacement_list word_or_symbol { +| replacement_list replacement_word { _string_list_append_item ($1, $2); talloc_free ($2); $$ = $1; } ; +replacement_word: + word { $$ = $1; } +| FUNC_MACRO { $$ = $1; } +| OBJ_MACRO { $$ = $1; } +| '(' { $$ = xtalloc_strdup (parser, "("); } +| ')' { $$ = xtalloc_strdup (parser, ")"); } +| ',' { $$ = xtalloc_strdup (parser, ","); } +| SPACE { $$ = xtalloc_strdup (parser, " "); } +; + parameter_list: /* empty */ { $$ = _string_list_create (parser); @@ -261,18 +274,8 @@ identifier_perhaps_macro: | OBJ_MACRO { $$ = $1; } ; -word_or_symbol: - word { $$ = $1; } -| '(' { $$ = xtalloc_strdup (parser, "("); } -| ')' { $$ = xtalloc_strdup (parser, ")"); } -| ',' { $$ = xtalloc_strdup (parser, ","); } -| SPACE { $$ = xtalloc_strdup (parser, " "); } -; - word: IDENTIFIER { $$ = $1; } -| FUNC_MACRO { $$ = $1; } -| OBJ_MACRO { $$ = $1; } | TOKEN { $$ = $1; } ;