summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-05-14 12:05:37 -0700
committerCarl Worth <cworth@cworth.org>2010-05-14 12:05:37 -0700
commit38bd27b444f610904320b5aa9d37e43be9164697 (patch)
treea8514b93b0f4ed90706541bcae41c2a554802de8
parent92e7bf0f50ff673b7441b2f2be9ef99a4af8cae4 (diff)
Fix expansion of composited macros.
This is a case such as "foo(bar(x))". The recently added test for this now passes.
-rw-r--r--glcpp-parse.y29
1 files changed, 16 insertions, 13 deletions
diff --git a/glcpp-parse.y b/glcpp-parse.y
index e70b3298d8..f972ec372b 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 <str> FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO TOKEN word word_or_symbol
+%type <str> FUNC_MACRO IDENTIFIER identifier_perhaps_macro OBJ_MACRO replacement_word TOKEN word
%type <string_list> argument macro parameter_list replacement_list
%type <argument_list> 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; }
;