Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 1 | %{ |
| 2 | /* |
| 3 | * Copyright © 2010 Intel Corporation |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 27 | #include <assert.h> |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 28 | #include <talloc.h> |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 29 | |
Carl Worth | a1e32bc | 2010-05-10 13:17:25 -0700 | [diff] [blame] | 30 | #include "glcpp.h" |
| 31 | |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 32 | #define YYLEX_PARAM parser->scanner |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 33 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 34 | typedef struct { |
| 35 | int is_function; |
| 36 | list_t *parameter_list; |
| 37 | list_t *replacement_list; |
| 38 | } macro_t; |
| 39 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 40 | struct glcpp_parser { |
| 41 | yyscan_t scanner; |
| 42 | struct hash_table *defines; |
| 43 | }; |
| 44 | |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 45 | void |
Carl Worth | a1e32bc | 2010-05-10 13:17:25 -0700 | [diff] [blame] | 46 | yyerror (void *scanner, const char *error); |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 47 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 48 | void |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 49 | _define_object_macro (glcpp_parser_t *parser, |
| 50 | const char *macro, |
| 51 | list_t *replacement_list); |
| 52 | |
| 53 | void |
| 54 | _define_function_macro (glcpp_parser_t *parser, |
| 55 | const char *macro, |
| 56 | list_t *parameter_list, |
| 57 | list_t *replacement_list); |
| 58 | |
| 59 | void |
| 60 | _print_expanded_object_macro (glcpp_parser_t *parser, const char *macro); |
| 61 | |
| 62 | void |
| 63 | _print_expanded_function_macro (glcpp_parser_t *parser, |
| 64 | const char *macro, |
| 65 | list_t *arguments); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 66 | |
| 67 | list_t * |
| 68 | _list_create (void *ctx); |
| 69 | |
| 70 | void |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 71 | _list_append_item (list_t *list, const char *str); |
| 72 | |
| 73 | void |
| 74 | _list_append_list (list_t *list, list_t *tail); |
Carl Worth | c6d5af3 | 2010-05-11 12:30:09 -0700 | [diff] [blame] | 75 | |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 76 | %} |
| 77 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 78 | %union { |
| 79 | char *str; |
| 80 | list_t *list; |
| 81 | } |
| 82 | |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 83 | %parse-param {glcpp_parser_t *parser} |
Carl Worth | 38aa835 | 2010-05-10 11:52:29 -0700 | [diff] [blame] | 84 | %lex-param {void *scanner} |
| 85 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 86 | %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO TOKEN UNDEF |
| 87 | %type <str> FUNC_MACRO IDENTIFIER OBJ_MACRO TOKEN string |
| 88 | %type <list> argument argument_list parameter_list replacement_list |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 89 | |
| 90 | %% |
| 91 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 92 | input: |
| 93 | /* empty */ |
Carl Worth | 8bcb6f1 | 2010-05-12 13:21:20 -0700 | [diff] [blame] | 94 | | input content |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 95 | ; |
| 96 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 97 | content: |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 98 | IDENTIFIER { |
| 99 | printf ("%s", $1); |
| 100 | talloc_free ($1); |
| 101 | } |
| 102 | | TOKEN { |
| 103 | printf ("%s", $1); |
| 104 | talloc_free ($1); |
| 105 | } |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 106 | | macro |
Carl Worth | cd27e64 | 2010-05-12 13:11:50 -0700 | [diff] [blame] | 107 | | directive_with_newline |
Carl Worth | 012295f | 2010-05-12 13:19:23 -0700 | [diff] [blame] | 108 | | NEWLINE { |
| 109 | printf ("\n"); |
| 110 | } |
Carl Worth | cd27e64 | 2010-05-12 13:11:50 -0700 | [diff] [blame] | 111 | ; |
| 112 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 113 | macro: |
| 114 | FUNC_MACRO '(' argument_list ')' { |
| 115 | _print_expanded_function_macro (parser, $1, $3); |
| 116 | } |
| 117 | | OBJ_MACRO { |
| 118 | _print_expanded_object_macro (parser, $1); |
| 119 | talloc_free ($1); |
| 120 | } |
| 121 | ; |
| 122 | |
| 123 | argument_list: |
Carl Worth | db35d55 | 2010-05-14 08:47:32 -0700 | [diff] [blame^] | 124 | argument { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 125 | $$ = _list_create (parser); |
| 126 | _list_append_list ($$, $1); |
| 127 | } |
| 128 | | argument_list ',' argument { |
| 129 | _list_append_list ($1, $3); |
| 130 | $$ = $1; |
| 131 | } |
| 132 | ; |
| 133 | |
| 134 | argument: |
| 135 | /* empty */ { |
| 136 | $$ = _list_create (parser); |
| 137 | } |
| 138 | | argument string { |
| 139 | _list_append_item ($1, $2); |
| 140 | talloc_free ($2); |
| 141 | } |
| 142 | | argument '(' argument ')' |
| 143 | ; |
| 144 | |
Carl Worth | cd27e64 | 2010-05-12 13:11:50 -0700 | [diff] [blame] | 145 | directive_with_newline: |
| 146 | directive NEWLINE { |
| 147 | printf ("\n"); |
| 148 | } |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 149 | ; |
| 150 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 151 | directive: |
Carl Worth | cd27e64 | 2010-05-12 13:11:50 -0700 | [diff] [blame] | 152 | DEFINE IDENTIFIER replacement_list { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 153 | _define_object_macro (parser, $2, $3); |
Carl Worth | cd27e64 | 2010-05-12 13:11:50 -0700 | [diff] [blame] | 154 | } |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 155 | | DEFINE IDENTIFIER '(' parameter_list ')' replacement_list { |
| 156 | _define_function_macro (parser, $2, $4, $6); |
| 157 | } |
| 158 | | UNDEF FUNC_MACRO { |
| 159 | list_t *replacement = hash_table_find (parser->defines, $2); |
| 160 | if (replacement) { |
| 161 | /* XXX: Need hash table to support a real way |
| 162 | * to remove an element rather than prefixing |
| 163 | * a new node with data of NULL like this. */ |
| 164 | hash_table_insert (parser->defines, NULL, $2); |
| 165 | talloc_free (replacement); |
| 166 | } |
| 167 | talloc_free ($2); |
| 168 | } |
| 169 | | UNDEF OBJ_MACRO { |
Carl Worth | cd27e64 | 2010-05-12 13:11:50 -0700 | [diff] [blame] | 170 | list_t *replacement = hash_table_find (parser->defines, $2); |
| 171 | if (replacement) { |
| 172 | /* XXX: Need hash table to support a real way |
| 173 | * to remove an element rather than prefixing |
| 174 | * a new node with data of NULL like this. */ |
| 175 | hash_table_insert (parser->defines, NULL, $2); |
| 176 | talloc_free (replacement); |
| 177 | } |
| 178 | talloc_free ($2); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 179 | } |
| 180 | ; |
| 181 | |
| 182 | replacement_list: |
| 183 | /* empty */ { |
| 184 | $$ = _list_create (parser); |
| 185 | } |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 186 | | replacement_list string { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 187 | _list_append_item ($1, $2); |
Carl Worth | 5070a20 | 2010-05-12 12:45:33 -0700 | [diff] [blame] | 188 | talloc_free ($2); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 189 | $$ = $1; |
| 190 | } |
| 191 | ; |
| 192 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 193 | parameter_list: |
| 194 | /* empty */ { |
| 195 | $$ = _list_create (parser); |
| 196 | } |
| 197 | | IDENTIFIER { |
| 198 | $$ = _list_create (parser); |
| 199 | _list_append_item ($$, $1); |
| 200 | talloc_free ($1); |
| 201 | } |
| 202 | | parameter_list ',' IDENTIFIER { |
| 203 | _list_append_item ($1, $3); |
| 204 | talloc_free ($3); |
| 205 | $$ = $1; |
| 206 | } |
| 207 | ; |
| 208 | |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 209 | string: |
| 210 | IDENTIFIER { $$ = $1; } |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 211 | | FUNC_MACRO { $$ = $1; } |
| 212 | | OBJ_MACRO { $$ = $1; } |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 213 | | TOKEN { $$ = $1; } |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 214 | ; |
| 215 | |
| 216 | %% |
| 217 | |
| 218 | list_t * |
| 219 | _list_create (void *ctx) |
| 220 | { |
| 221 | list_t *list; |
| 222 | |
Carl Worth | 5070a20 | 2010-05-12 12:45:33 -0700 | [diff] [blame] | 223 | list = xtalloc (ctx, list_t); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 224 | list->head = NULL; |
| 225 | list->tail = NULL; |
| 226 | |
| 227 | return list; |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 228 | } |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 229 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 230 | void |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 231 | _list_append_list (list_t *list, list_t *tail) |
| 232 | { |
| 233 | if (list->head == NULL) { |
| 234 | list->head = tail->head; |
| 235 | } else { |
| 236 | list->tail->next = tail->head; |
| 237 | } |
| 238 | |
| 239 | list->tail = tail->tail; |
| 240 | } |
| 241 | |
| 242 | void |
| 243 | _list_append_item (list_t *list, const char *str) |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 244 | { |
| 245 | node_t *node; |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 246 | |
Carl Worth | 5070a20 | 2010-05-12 12:45:33 -0700 | [diff] [blame] | 247 | node = xtalloc (list, node_t); |
| 248 | node->str = xtalloc_strdup (node, str); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 249 | |
| 250 | node->next = NULL; |
| 251 | |
| 252 | if (list->head == NULL) { |
| 253 | list->head = node; |
| 254 | } else { |
| 255 | list->tail->next = node; |
| 256 | } |
| 257 | |
| 258 | list->tail = node; |
| 259 | } |
| 260 | |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 261 | void |
Carl Worth | a1e32bc | 2010-05-10 13:17:25 -0700 | [diff] [blame] | 262 | yyerror (void *scanner, const char *error) |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 263 | { |
| 264 | fprintf (stderr, "Parse error: %s\n", error); |
| 265 | } |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 266 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 267 | glcpp_parser_t * |
| 268 | glcpp_parser_create (void) |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 269 | { |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 270 | glcpp_parser_t *parser; |
| 271 | |
Carl Worth | 5070a20 | 2010-05-12 12:45:33 -0700 | [diff] [blame] | 272 | parser = xtalloc (NULL, glcpp_parser_t); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 273 | |
Carl Worth | 5070a20 | 2010-05-12 12:45:33 -0700 | [diff] [blame] | 274 | yylex_init_extra (parser, &parser->scanner); |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 275 | parser->defines = hash_table_ctor (32, hash_table_string_hash, |
| 276 | hash_table_string_compare); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 277 | |
| 278 | return parser; |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | int |
| 282 | glcpp_parser_parse (glcpp_parser_t *parser) |
| 283 | { |
| 284 | return yyparse (parser); |
| 285 | } |
| 286 | |
| 287 | void |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 288 | glcpp_parser_destroy (glcpp_parser_t *parser) |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 289 | { |
| 290 | yylex_destroy (parser->scanner); |
| 291 | hash_table_dtor (parser->defines); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 292 | talloc_free (parser); |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 293 | } |
Carl Worth | c6d5af3 | 2010-05-11 12:30:09 -0700 | [diff] [blame] | 294 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 295 | macro_type_t |
| 296 | glcpp_parser_macro_type (glcpp_parser_t *parser, const char *identifier) |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 297 | { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 298 | macro_t *macro; |
| 299 | |
| 300 | macro = hash_table_find (parser->defines, identifier); |
| 301 | |
| 302 | if (macro == NULL) |
| 303 | return MACRO_TYPE_UNDEFINED; |
| 304 | |
| 305 | if (macro->is_function) |
| 306 | return MACRO_TYPE_FUNCTION; |
| 307 | else |
| 308 | return MACRO_TYPE_OBJECT; |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 311 | static void |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 312 | _print_expanded_macro_recursive (glcpp_parser_t *parser, |
| 313 | const char *token, |
| 314 | const char *orig, |
| 315 | int *first) |
Carl Worth | c6d5af3 | 2010-05-11 12:30:09 -0700 | [diff] [blame] | 316 | { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 317 | macro_t *macro; |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 318 | node_t *node; |
Carl Worth | c6d5af3 | 2010-05-11 12:30:09 -0700 | [diff] [blame] | 319 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 320 | macro = hash_table_find (parser->defines, token); |
| 321 | if (macro == NULL) { |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 322 | printf ("%s%s", *first ? "" : " ", token); |
| 323 | *first = 0; |
| 324 | } else { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 325 | list_t *replacement_list = macro->replacement_list; |
| 326 | |
| 327 | for (node = replacement_list->head ; node ; node = node->next) { |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 328 | token = node->str; |
| 329 | if (strcmp (token, orig) == 0) { |
| 330 | printf ("%s%s", *first ? "" : " ", token); |
| 331 | *first = 0; |
| 332 | } else { |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 333 | _print_expanded_macro_recursive (parser, |
| 334 | token, orig, |
| 335 | first); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 336 | } |
| 337 | } |
Carl Worth | c6d5af3 | 2010-05-11 12:30:09 -0700 | [diff] [blame] | 338 | } |
Carl Worth | c6d5af3 | 2010-05-11 12:30:09 -0700 | [diff] [blame] | 339 | } |
| 340 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 341 | void |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 342 | _define_object_macro (glcpp_parser_t *parser, |
| 343 | const char *identifier, |
| 344 | list_t *replacement_list) |
| 345 | { |
| 346 | macro_t *macro; |
| 347 | |
| 348 | macro = xtalloc (parser, macro_t); |
| 349 | |
| 350 | macro->is_function = 0; |
| 351 | macro->parameter_list = NULL; |
| 352 | macro->replacement_list = talloc_steal (macro, replacement_list); |
| 353 | |
| 354 | hash_table_insert (parser->defines, macro, identifier); |
| 355 | } |
| 356 | |
| 357 | void |
| 358 | _define_function_macro (glcpp_parser_t *parser, |
| 359 | const char *identifier, |
| 360 | list_t *parameter_list, |
| 361 | list_t *replacement_list) |
| 362 | { |
| 363 | macro_t *macro; |
| 364 | |
| 365 | macro = xtalloc (parser, macro_t); |
| 366 | |
| 367 | macro->is_function = 1; |
| 368 | macro->parameter_list = talloc_steal (macro, parameter_list); |
| 369 | macro->replacement_list = talloc_steal (macro, replacement_list); |
| 370 | |
| 371 | hash_table_insert (parser->defines, macro, identifier); |
| 372 | } |
| 373 | |
| 374 | void |
| 375 | _print_expanded_object_macro (glcpp_parser_t *parser, const char *identifier) |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 376 | { |
| 377 | int first = 1; |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 378 | macro_t *macro; |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 379 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 380 | macro = hash_table_find (parser->defines, identifier); |
| 381 | assert (! macro->is_function); |
| 382 | |
| 383 | _print_expanded_macro_recursive (parser, identifier, identifier, &first); |
| 384 | } |
| 385 | |
| 386 | void |
| 387 | _print_expanded_function_macro (glcpp_parser_t *parser, |
| 388 | const char *identifier, |
| 389 | list_t *arguments) |
| 390 | { |
| 391 | int first = 1; |
| 392 | macro_t *macro; |
| 393 | |
| 394 | macro = hash_table_find (parser->defines, identifier); |
| 395 | assert (macro->is_function); |
| 396 | |
| 397 | /* XXX: Need to use argument list here in the expansion. */ |
| 398 | |
| 399 | _print_expanded_macro_recursive (parser, identifier, identifier, &first); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 400 | } |