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 | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 28 | |
Carl Worth | a1e32bc | 2010-05-10 13:17:25 -0700 | [diff] [blame] | 29 | #include "glcpp.h" |
| 30 | |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 31 | #define YYLEX_PARAM parser->scanner |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 32 | |
| 33 | void |
Carl Worth | a1e32bc | 2010-05-10 13:17:25 -0700 | [diff] [blame] | 34 | yyerror (void *scanner, const char *error); |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 35 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 36 | void |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 37 | _define_object_macro (glcpp_parser_t *parser, |
| 38 | const char *macro, |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 39 | const char *replacement); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 40 | |
| 41 | void |
| 42 | _define_function_macro (glcpp_parser_t *parser, |
| 43 | const char *macro, |
Carl Worth | c5e9855 | 2010-05-14 10:12:21 -0700 | [diff] [blame] | 44 | string_list_t *parameters, |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 45 | const char *replacement); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 46 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 47 | void |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 48 | _expand_object_macro (glcpp_parser_t *parser, const char *identifier); |
| 49 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 50 | void |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 51 | _expand_function_macro (glcpp_parser_t *parser, |
| 52 | const char *identifier, |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 53 | argument_list_t *arguments); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 54 | |
| 55 | void |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 56 | _print_string_list (string_list_t *list); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 57 | |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 58 | string_list_t * |
| 59 | _string_list_create (void *ctx); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 60 | |
| 61 | void |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 62 | _string_list_append_item (string_list_t *list, const char *str); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 63 | |
| 64 | void |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 65 | _string_list_append_list (string_list_t *list, string_list_t *tail); |
Carl Worth | c6d5af3 | 2010-05-11 12:30:09 -0700 | [diff] [blame] | 66 | |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 67 | int |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 68 | _string_list_contains (string_list_t *list, const char *member, int *index); |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 69 | |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 70 | int |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 71 | _string_list_length (string_list_t *list); |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 72 | |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 73 | argument_list_t * |
| 74 | _argument_list_create (void *ctx); |
| 75 | |
| 76 | void |
| 77 | _argument_list_append (argument_list_t *list, string_list_t *argument); |
| 78 | |
| 79 | int |
| 80 | _argument_list_length (argument_list_t *list); |
| 81 | |
| 82 | string_list_t * |
| 83 | _argument_list_member_at (argument_list_t *list, int index); |
| 84 | |
Carl Worth | 8f38aff | 2010-05-19 10:01:29 -0700 | [diff] [blame^] | 85 | static int |
| 86 | yylex (yyscan_t scanner); |
| 87 | |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 88 | %} |
| 89 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 90 | %union { |
| 91 | char *str; |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 92 | string_list_t *string_list; |
| 93 | argument_list_t *argument_list; |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 96 | %parse-param {glcpp_parser_t *parser} |
Carl Worth | 38aa835 | 2010-05-10 11:52:29 -0700 | [diff] [blame] | 97 | %lex-param {void *scanner} |
| 98 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 99 | %token DEFINE FUNC_MACRO IDENTIFIER NEWLINE OBJ_MACRO REPLACEMENT TOKEN UNDEF |
Carl Worth | 59ca989 | 2010-05-19 07:49:47 -0700 | [diff] [blame] | 100 | %type <str> argument_word FUNC_MACRO IDENTIFIER OBJ_MACRO REPLACEMENT TOKEN |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 101 | %type <string_list> argument macro parameter_list |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 102 | %type <argument_list> argument_list |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 103 | |
Carl Worth | 796e1f0 | 2010-05-17 12:45:16 -0700 | [diff] [blame] | 104 | /* Hard to remove shift/reduce conflicts documented as follows: |
| 105 | * |
| 106 | * 1. '(' after FUNC_MACRO name which is correctly resolved to shift |
| 107 | * to form macro invocation rather than reducing directly to |
| 108 | * content. |
Carl Worth | 69f390d | 2010-05-19 07:42:42 -0700 | [diff] [blame] | 109 | * |
| 110 | * 2. Similarly, '(' after FUNC_MACRO which is correctly resolved to |
| 111 | * shift to form macro invocation rather than reducing directly to |
| 112 | * argument. |
Carl Worth | 796e1f0 | 2010-05-17 12:45:16 -0700 | [diff] [blame] | 113 | */ |
Carl Worth | 69f390d | 2010-05-19 07:42:42 -0700 | [diff] [blame] | 114 | %expect 2 |
Carl Worth | 796e1f0 | 2010-05-17 12:45:16 -0700 | [diff] [blame] | 115 | |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 116 | %% |
| 117 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 118 | input: |
| 119 | /* empty */ |
Carl Worth | 8bcb6f1 | 2010-05-12 13:21:20 -0700 | [diff] [blame] | 120 | | input content |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 121 | ; |
| 122 | |
Carl Worth | 04af135 | 2010-05-14 10:17:38 -0700 | [diff] [blame] | 123 | /* We do all printing at the content level */ |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 124 | content: |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 125 | IDENTIFIER { |
| 126 | printf ("%s", $1); |
| 127 | talloc_free ($1); |
| 128 | } |
| 129 | | TOKEN { |
| 130 | printf ("%s", $1); |
| 131 | talloc_free ($1); |
| 132 | } |
Carl Worth | acf87bc | 2010-05-17 10:34:29 -0700 | [diff] [blame] | 133 | | FUNC_MACRO { |
| 134 | printf ("%s", $1); |
| 135 | talloc_free ($1); |
| 136 | } |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 137 | | directive { |
| 138 | printf ("\n"); |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 139 | } |
Carl Worth | 0a93cbb | 2010-05-13 10:29:07 -0700 | [diff] [blame] | 140 | | '(' { printf ("("); } |
| 141 | | ')' { printf (")"); } |
| 142 | | ',' { printf (","); } |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 143 | | macro |
Carl Worth | cd27e64 | 2010-05-12 13:11:50 -0700 | [diff] [blame] | 144 | ; |
| 145 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 146 | macro: |
| 147 | FUNC_MACRO '(' argument_list ')' { |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 148 | _expand_function_macro (parser, $1, $3); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 149 | } |
| 150 | | OBJ_MACRO { |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 151 | _expand_object_macro (parser, $1); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 152 | talloc_free ($1); |
| 153 | } |
| 154 | ; |
| 155 | |
| 156 | argument_list: |
Carl Worth | ac070e8 | 2010-05-14 11:33:00 -0700 | [diff] [blame] | 157 | /* empty */ { |
| 158 | $$ = _argument_list_create (parser); |
| 159 | } |
| 160 | | argument { |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 161 | $$ = _argument_list_create (parser); |
| 162 | _argument_list_append ($$, $1); |
| 163 | } |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 164 | | argument_list ',' argument { |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 165 | _argument_list_append ($1, $3); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 166 | $$ = $1; |
| 167 | } |
| 168 | ; |
| 169 | |
| 170 | argument: |
Carl Worth | 59ca989 | 2010-05-19 07:49:47 -0700 | [diff] [blame] | 171 | argument_word { |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 172 | $$ = _string_list_create (parser); |
Carl Worth | ac070e8 | 2010-05-14 11:33:00 -0700 | [diff] [blame] | 173 | _string_list_append_item ($$, $1); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 174 | } |
Carl Worth | 59ca989 | 2010-05-19 07:49:47 -0700 | [diff] [blame] | 175 | | argument argument_word { |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 176 | _string_list_append_item ($1, $2); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 177 | talloc_free ($2); |
Carl Worth | 3596bb1 | 2010-05-14 16:53:52 -0700 | [diff] [blame] | 178 | $$ = $1; |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 179 | } |
Carl Worth | 3596bb1 | 2010-05-14 16:53:52 -0700 | [diff] [blame] | 180 | | argument '(' argument ')' { |
| 181 | _string_list_append_item ($1, "("); |
| 182 | _string_list_append_list ($1, $3); |
| 183 | _string_list_append_item ($1, ")"); |
| 184 | $$ = $1; |
| 185 | } |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 186 | ; |
| 187 | |
Carl Worth | 59ca989 | 2010-05-19 07:49:47 -0700 | [diff] [blame] | 188 | argument_word: |
| 189 | IDENTIFIER { $$ = $1; } |
| 190 | | TOKEN { $$ = $1; } |
| 191 | | FUNC_MACRO { $$ = $1; } |
Carl Worth | 5d21142 | 2010-05-19 07:57:03 -0700 | [diff] [blame] | 192 | | macro { $$ = xtalloc_strdup (parser, ""); } |
Carl Worth | 59ca989 | 2010-05-19 07:49:47 -0700 | [diff] [blame] | 193 | ; |
| 194 | |
| 195 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 196 | directive: |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 197 | DEFINE IDENTIFIER REPLACEMENT { |
| 198 | _define_object_macro (parser, $2, $3); |
Carl Worth | 0a93cbb | 2010-05-13 10:29:07 -0700 | [diff] [blame] | 199 | } |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 200 | | DEFINE IDENTIFIER '(' parameter_list ')' REPLACEMENT { |
Carl Worth | 81f0143 | 2010-05-14 17:08:45 -0700 | [diff] [blame] | 201 | _define_function_macro (parser, $2, $4, $6); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 202 | } |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 203 | | UNDEF IDENTIFIER { |
| 204 | string_list_t *macro = hash_table_find (parser->defines, $2); |
| 205 | if (macro) { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 206 | /* XXX: Need hash table to support a real way |
| 207 | * to remove an element rather than prefixing |
| 208 | * a new node with data of NULL like this. */ |
| 209 | hash_table_insert (parser->defines, NULL, $2); |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 210 | talloc_free (macro); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 211 | } |
| 212 | talloc_free ($2); |
| 213 | } |
Carl Worth | 38bd27b | 2010-05-14 12:05:37 -0700 | [diff] [blame] | 214 | ; |
| 215 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 216 | parameter_list: |
| 217 | /* empty */ { |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 218 | $$ = _string_list_create (parser); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 219 | } |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 220 | | IDENTIFIER { |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 221 | $$ = _string_list_create (parser); |
| 222 | _string_list_append_item ($$, $1); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 223 | talloc_free ($1); |
| 224 | } |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 225 | | parameter_list ',' IDENTIFIER { |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 226 | _string_list_append_item ($1, $3); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 227 | talloc_free ($3); |
| 228 | $$ = $1; |
| 229 | } |
| 230 | ; |
| 231 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 232 | %% |
| 233 | |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 234 | string_list_t * |
| 235 | _string_list_create (void *ctx) |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 236 | { |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 237 | string_list_t *list; |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 238 | |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 239 | list = xtalloc (ctx, string_list_t); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 240 | list->head = NULL; |
| 241 | list->tail = NULL; |
| 242 | |
| 243 | return list; |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 244 | } |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 245 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 246 | void |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 247 | _string_list_append_list (string_list_t *list, string_list_t *tail) |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 248 | { |
| 249 | if (list->head == NULL) { |
| 250 | list->head = tail->head; |
| 251 | } else { |
| 252 | list->tail->next = tail->head; |
| 253 | } |
| 254 | |
| 255 | list->tail = tail->tail; |
| 256 | } |
| 257 | |
| 258 | void |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 259 | _string_list_append_item (string_list_t *list, const char *str) |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 260 | { |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 261 | string_node_t *node; |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 262 | |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 263 | node = xtalloc (list, string_node_t); |
Carl Worth | 5070a20 | 2010-05-12 12:45:33 -0700 | [diff] [blame] | 264 | node->str = xtalloc_strdup (node, str); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 265 | |
| 266 | node->next = NULL; |
| 267 | |
| 268 | if (list->head == NULL) { |
| 269 | list->head = node; |
| 270 | } else { |
| 271 | list->tail->next = node; |
| 272 | } |
| 273 | |
| 274 | list->tail = node; |
| 275 | } |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 276 | |
| 277 | int |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 278 | _string_list_contains (string_list_t *list, const char *member, int *index) |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 279 | { |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 280 | string_node_t *node; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 281 | int i; |
| 282 | |
| 283 | if (list == NULL) |
| 284 | return 0; |
| 285 | |
| 286 | for (i = 0, node = list->head; node; i++, node = node->next) { |
| 287 | if (strcmp (node->str, member) == 0) { |
Carl Worth | 420d05a | 2010-05-17 10:15:23 -0700 | [diff] [blame] | 288 | if (index) |
| 289 | *index = i; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 290 | return 1; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | int |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 298 | _string_list_length (string_list_t *list) |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 299 | { |
| 300 | int length = 0; |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 301 | string_node_t *node; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 302 | |
| 303 | if (list == NULL) |
| 304 | return 0; |
| 305 | |
| 306 | for (node = list->head; node; node = node->next) |
| 307 | length++; |
| 308 | |
| 309 | return length; |
| 310 | } |
| 311 | |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 312 | void |
| 313 | _print_string_list (string_list_t *list) |
| 314 | { |
| 315 | string_node_t *node; |
| 316 | |
| 317 | if (list == NULL) |
| 318 | return; |
| 319 | |
Carl Worth | 81f0143 | 2010-05-14 17:08:45 -0700 | [diff] [blame] | 320 | for (node = list->head; node; node = node->next) { |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 321 | printf ("%s", node->str); |
Carl Worth | 81f0143 | 2010-05-14 17:08:45 -0700 | [diff] [blame] | 322 | if (node->next) |
| 323 | printf (" "); |
| 324 | } |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 325 | } |
| 326 | |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 327 | argument_list_t * |
| 328 | _argument_list_create (void *ctx) |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 329 | { |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 330 | argument_list_t *list; |
| 331 | |
| 332 | list = xtalloc (ctx, argument_list_t); |
| 333 | list->head = NULL; |
| 334 | list->tail = NULL; |
| 335 | |
| 336 | return list; |
| 337 | } |
| 338 | |
| 339 | void |
| 340 | _argument_list_append (argument_list_t *list, string_list_t *argument) |
| 341 | { |
| 342 | argument_node_t *node; |
| 343 | |
| 344 | if (argument == NULL || argument->head == NULL) |
| 345 | return; |
| 346 | |
| 347 | node = xtalloc (list, argument_node_t); |
| 348 | node->argument = argument; |
| 349 | |
| 350 | node->next = NULL; |
| 351 | |
| 352 | if (list->head == NULL) { |
| 353 | list->head = node; |
| 354 | } else { |
| 355 | list->tail->next = node; |
| 356 | } |
| 357 | |
| 358 | list->tail = node; |
| 359 | } |
| 360 | |
| 361 | int |
| 362 | _argument_list_length (argument_list_t *list) |
| 363 | { |
| 364 | int length = 0; |
| 365 | argument_node_t *node; |
| 366 | |
| 367 | if (list == NULL) |
| 368 | return 0; |
| 369 | |
| 370 | for (node = list->head; node; node = node->next) |
| 371 | length++; |
| 372 | |
| 373 | return length; |
| 374 | } |
| 375 | |
| 376 | string_list_t * |
| 377 | _argument_list_member_at (argument_list_t *list, int index) |
| 378 | { |
| 379 | argument_node_t *node; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 380 | int i; |
| 381 | |
| 382 | if (list == NULL) |
| 383 | return NULL; |
| 384 | |
| 385 | node = list->head; |
| 386 | for (i = 0; i < index; i++) { |
| 387 | node = node->next; |
| 388 | if (node == NULL) |
| 389 | break; |
| 390 | } |
| 391 | |
| 392 | if (node) |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 393 | return node->argument; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 394 | |
| 395 | return NULL; |
| 396 | } |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 397 | |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 398 | void |
Carl Worth | a1e32bc | 2010-05-10 13:17:25 -0700 | [diff] [blame] | 399 | yyerror (void *scanner, const char *error) |
Carl Worth | 3a37b87 | 2010-05-10 11:44:09 -0700 | [diff] [blame] | 400 | { |
| 401 | fprintf (stderr, "Parse error: %s\n", error); |
| 402 | } |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 403 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 404 | glcpp_parser_t * |
| 405 | glcpp_parser_create (void) |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 406 | { |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 407 | glcpp_parser_t *parser; |
| 408 | |
Carl Worth | 5070a20 | 2010-05-12 12:45:33 -0700 | [diff] [blame] | 409 | parser = xtalloc (NULL, glcpp_parser_t); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 410 | |
Carl Worth | 8f38aff | 2010-05-19 10:01:29 -0700 | [diff] [blame^] | 411 | glcpp_lex_init_extra (parser, &parser->scanner); |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 412 | parser->defines = hash_table_ctor (32, hash_table_string_hash, |
| 413 | hash_table_string_compare); |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 414 | parser->expansions = NULL; |
| 415 | |
| 416 | parser->lex_stack = xtalloc (parser, glcpp_lex_stack_t); |
| 417 | parser->lex_stack->parser = parser; |
| 418 | parser->lex_stack->head = NULL; |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 419 | |
| 420 | return parser; |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | int |
| 424 | glcpp_parser_parse (glcpp_parser_t *parser) |
| 425 | { |
| 426 | return yyparse (parser); |
| 427 | } |
| 428 | |
| 429 | void |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 430 | glcpp_parser_destroy (glcpp_parser_t *parser) |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 431 | { |
Carl Worth | 8f38aff | 2010-05-19 10:01:29 -0700 | [diff] [blame^] | 432 | glcpp_lex_destroy (parser->scanner); |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 433 | hash_table_dtor (parser->defines); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 434 | talloc_free (parser); |
Carl Worth | 0b27b5f | 2010-05-10 16:16:06 -0700 | [diff] [blame] | 435 | } |
Carl Worth | c6d5af3 | 2010-05-11 12:30:09 -0700 | [diff] [blame] | 436 | |
Carl Worth | be0e2e9 | 2010-05-19 07:29:22 -0700 | [diff] [blame] | 437 | static int |
| 438 | glcpp_parser_is_expanding (glcpp_parser_t *parser, const char *member) |
| 439 | { |
| 440 | expansion_node_t *node; |
| 441 | |
| 442 | for (node = parser->expansions; node; node = node->next) { |
| 443 | if (node->macro && |
| 444 | strcmp (node->macro->identifier, member) == 0) |
| 445 | { |
| 446 | return 1; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | return 0; |
| 451 | } |
| 452 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 453 | token_class_t |
| 454 | glcpp_parser_classify_token (glcpp_parser_t *parser, |
| 455 | const char *identifier, |
| 456 | int *parameter_index) |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 457 | { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 458 | macro_t *macro; |
| 459 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 460 | /* First we check if we are currently expanding a |
| 461 | * function-like macro, and if so, whether the parameter list |
| 462 | * contains a parameter matching this token name. */ |
| 463 | if (parser->expansions && |
| 464 | parser->expansions->macro && |
| 465 | parser->expansions->macro->parameters) |
| 466 | { |
| 467 | string_list_t *list; |
| 468 | |
| 469 | list = parser->expansions->macro->parameters; |
| 470 | |
| 471 | if (_string_list_contains (list, identifier, parameter_index)) |
| 472 | return TOKEN_CLASS_ARGUMENT; |
| 473 | } |
| 474 | |
| 475 | /* If not a function-like macro parameter, we next check if |
| 476 | * this token is a macro itself. */ |
| 477 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 478 | macro = hash_table_find (parser->defines, identifier); |
| 479 | |
| 480 | if (macro == NULL) |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 481 | return TOKEN_CLASS_IDENTIFIER; |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 482 | |
Carl Worth | be0e2e9 | 2010-05-19 07:29:22 -0700 | [diff] [blame] | 483 | /* Don't consider this a macro if we are already actively |
| 484 | * expanding this macro. */ |
| 485 | if (glcpp_parser_is_expanding (parser, identifier)) |
| 486 | return TOKEN_CLASS_IDENTIFIER; |
| 487 | |
| 488 | /* Definitely a macro. Just need to check if it's function-like. */ |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 489 | if (macro->is_function) |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 490 | return TOKEN_CLASS_FUNC_MACRO; |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 491 | else |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 492 | return TOKEN_CLASS_OBJ_MACRO; |
Carl Worth | 9f62a7e | 2010-05-13 07:38:29 -0700 | [diff] [blame] | 493 | } |
| 494 | |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 495 | void |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 496 | _define_object_macro (glcpp_parser_t *parser, |
| 497 | const char *identifier, |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 498 | const char *replacement) |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 499 | { |
| 500 | macro_t *macro; |
| 501 | |
| 502 | macro = xtalloc (parser, macro_t); |
| 503 | |
| 504 | macro->is_function = 0; |
Carl Worth | c5e9855 | 2010-05-14 10:12:21 -0700 | [diff] [blame] | 505 | macro->parameters = NULL; |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 506 | macro->identifier = talloc_strdup (macro, identifier); |
| 507 | macro->replacement = talloc_steal (macro, replacement); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 508 | |
| 509 | hash_table_insert (parser->defines, macro, identifier); |
| 510 | } |
| 511 | |
| 512 | void |
| 513 | _define_function_macro (glcpp_parser_t *parser, |
| 514 | const char *identifier, |
Carl Worth | c5e9855 | 2010-05-14 10:12:21 -0700 | [diff] [blame] | 515 | string_list_t *parameters, |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 516 | const char *replacement) |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 517 | { |
| 518 | macro_t *macro; |
| 519 | |
| 520 | macro = xtalloc (parser, macro_t); |
| 521 | |
| 522 | macro->is_function = 1; |
Carl Worth | c5e9855 | 2010-05-14 10:12:21 -0700 | [diff] [blame] | 523 | macro->parameters = talloc_steal (macro, parameters); |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 524 | macro->identifier = talloc_strdup (macro, identifier); |
| 525 | macro->replacement = talloc_steal (macro, replacement); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 526 | |
| 527 | hash_table_insert (parser->defines, macro, identifier); |
| 528 | } |
| 529 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 530 | static void |
| 531 | _glcpp_parser_push_expansion_internal (glcpp_parser_t *parser, |
| 532 | macro_t *macro, |
| 533 | argument_list_t *arguments, |
| 534 | const char * replacement) |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 535 | { |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 536 | expansion_node_t *node; |
| 537 | |
| 538 | node = xtalloc (parser, expansion_node_t); |
| 539 | |
| 540 | node->macro = macro; |
| 541 | node->arguments = arguments; |
| 542 | |
| 543 | node->next = parser->expansions; |
| 544 | parser->expansions = node; |
| 545 | |
| 546 | glcpp_lex_stack_push (parser->lex_stack, replacement); |
| 547 | } |
| 548 | |
| 549 | void |
| 550 | glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, |
| 551 | macro_t *macro, |
| 552 | argument_list_t *arguments) |
| 553 | { |
| 554 | _glcpp_parser_push_expansion_internal (parser, macro, arguments, |
| 555 | macro->replacement); |
| 556 | } |
| 557 | |
| 558 | void |
| 559 | glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, |
| 560 | int argument_index) |
| 561 | { |
| 562 | argument_list_t *arguments; |
| 563 | string_list_t *argument; |
Carl Worth | 610053b | 2010-05-14 10:05:11 -0700 | [diff] [blame] | 564 | string_node_t *node; |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 565 | char *argument_str, *s; |
| 566 | int length; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 567 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 568 | arguments = parser->expansions->arguments; |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 569 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 570 | argument = _argument_list_member_at (arguments, argument_index); |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 571 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 572 | length = 0; |
| 573 | for (node = argument->head; node; node = node->next) |
| 574 | length += strlen (node->str) + 1; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 575 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 576 | argument_str = xtalloc_size (parser, length); |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 577 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 578 | *argument_str = '\0'; |
| 579 | s = argument_str; |
| 580 | for (node = argument->head; node; node = node->next) { |
| 581 | strcpy (s, node->str); |
| 582 | s += strlen (node->str); |
| 583 | if (node->next) { |
| 584 | *s = ' '; |
| 585 | s++; |
| 586 | *s = '\0'; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 587 | } |
| 588 | } |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 589 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 590 | _glcpp_parser_push_expansion_internal (parser, NULL, NULL, |
| 591 | argument_str); |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 592 | } |
| 593 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 594 | /* The lexer calls this when it exhausts a string. */ |
| 595 | void |
| 596 | glcpp_parser_pop_expansion (glcpp_parser_t *parser) |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 597 | { |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 598 | expansion_node_t *node; |
Carl Worth | 420d05a | 2010-05-17 10:15:23 -0700 | [diff] [blame] | 599 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 600 | node = parser->expansions; |
Carl Worth | 420d05a | 2010-05-17 10:15:23 -0700 | [diff] [blame] | 601 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 602 | if (node == NULL) { |
| 603 | fprintf (stderr, "Internal error: _expansion_list_pop called on an empty list.\n"); |
| 604 | exit (1); |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 605 | } |
| 606 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 607 | parser->expansions = node->next; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 608 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 609 | talloc_free (node); |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 610 | } |
| 611 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 612 | void |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 613 | _expand_object_macro (glcpp_parser_t *parser, const char *identifier) |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 614 | { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 615 | macro_t *macro; |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 616 | |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 617 | macro = hash_table_find (parser->defines, identifier); |
| 618 | assert (! macro->is_function); |
Carl Worth | be0e2e9 | 2010-05-19 07:29:22 -0700 | [diff] [blame] | 619 | assert (! glcpp_parser_is_expanding (parser, identifier)); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 620 | |
Carl Worth | be0e2e9 | 2010-05-19 07:29:22 -0700 | [diff] [blame] | 621 | glcpp_parser_push_expansion_macro (parser, macro, NULL); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 622 | } |
| 623 | |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 624 | void |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 625 | _expand_function_macro (glcpp_parser_t *parser, |
| 626 | const char *identifier, |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 627 | argument_list_t *arguments) |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 628 | { |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 629 | macro_t *macro; |
| 630 | |
| 631 | macro = hash_table_find (parser->defines, identifier); |
| 632 | assert (macro->is_function); |
Carl Worth | be0e2e9 | 2010-05-19 07:29:22 -0700 | [diff] [blame] | 633 | assert (! glcpp_parser_is_expanding (parser, identifier)); |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 634 | |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 635 | if (_argument_list_length (arguments) != |
Carl Worth | 2be8be0 | 2010-05-14 10:31:43 -0700 | [diff] [blame] | 636 | _string_list_length (macro->parameters)) |
| 637 | { |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 638 | fprintf (stderr, |
| 639 | "Error: macro %s invoked with %d arguments (expected %d)\n", |
| 640 | identifier, |
Carl Worth | 8f6a828 | 2010-05-14 10:44:19 -0700 | [diff] [blame] | 641 | _argument_list_length (arguments), |
Carl Worth | c5e9855 | 2010-05-14 10:12:21 -0700 | [diff] [blame] | 642 | _string_list_length (macro->parameters)); |
Carl Worth | a807fb7 | 2010-05-18 22:10:04 -0700 | [diff] [blame] | 643 | return; |
Carl Worth | dcc2ecd | 2010-05-13 12:56:42 -0700 | [diff] [blame] | 644 | } |
Carl Worth | fcbbb46 | 2010-05-13 09:36:23 -0700 | [diff] [blame] | 645 | |
Carl Worth | be0e2e9 | 2010-05-19 07:29:22 -0700 | [diff] [blame] | 646 | glcpp_parser_push_expansion_macro (parser, macro, arguments); |
Carl Worth | 33cc400 | 2010-05-12 12:17:10 -0700 | [diff] [blame] | 647 | } |
Carl Worth | 8f38aff | 2010-05-19 10:01:29 -0700 | [diff] [blame^] | 648 | |
| 649 | static int |
| 650 | yylex (yyscan_t scanner) |
| 651 | { |
| 652 | return glcpp_lex (scanner); |
| 653 | } |