diff options
author | Carl Worth <cworth@cworth.org> | 2010-05-19 13:28:24 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-05-19 13:28:24 -0700 |
commit | aaa9acbf10b7a8e7dac061885ef95823ad27f80e (patch) | |
tree | a3985624833631924cbb1a3505ddc92928267e69 /glcpp.h | |
parent | 71c59ec66bc258be6a641b26f793060f6d9522c8 (diff) |
Perform "re lexing" on string list values rathern than on text.
Previously, we would pass original strings back to the original lexer
whenever we needed to re-lex something, (such as an expanded macro or
a macro argument). Now, we instead parse the macro or argument
originally to a string list, and then re-lex by simply returning each
string from this list in turn.
We do this in the recently added glcpp_parser_lex function that sits
on top of the lower-level glcpp_lex that only deals with text.
This doesn't change any behavior (at least according to the existing
test suite which all still passes) but it brings us much closer to
being able to "finalize" an unexpanded macro as required by the
specification.
Diffstat (limited to 'glcpp.h')
-rw-r--r-- | glcpp.h | 38 |
1 files changed, 6 insertions, 32 deletions
@@ -54,24 +54,6 @@ typedef struct argument_list { typedef struct glcpp_parser glcpp_parser_t; -/* Support for temporarily lexing/parsing tokens from a string. */ - -typedef struct glcpp_lex_node { - void *buffer; - struct glcpp_lex_node *next; -} glcpp_lex_node_t; - -typedef struct { - glcpp_parser_t *parser; - glcpp_lex_node_t *head; -} glcpp_lex_stack_t; - -void -glcpp_lex_stack_push (glcpp_lex_stack_t *stack, const char *string); - -int -glcpp_lex_stack_pop (glcpp_lex_stack_t *stack); - typedef enum { TOKEN_CLASS_ARGUMENT, TOKEN_CLASS_IDENTIFIER, @@ -88,12 +70,13 @@ typedef struct { int is_function; string_list_t *parameters; const char *identifier; - const char *replacement; + string_list_t *replacements; } macro_t; typedef struct expansion_node { macro_t *macro; argument_list_t *arguments; + string_node_t *replacements; struct expansion_node *next; } expansion_node_t; @@ -101,9 +84,12 @@ struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; expansion_node_t *expansions; - glcpp_lex_stack_t *lex_stack; }; +void +glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, + int argument_index); + glcpp_parser_t * glcpp_parser_create (void); @@ -113,18 +99,6 @@ glcpp_parser_parse (glcpp_parser_t *parser); void glcpp_parser_destroy (glcpp_parser_t *parser); -void -glcpp_parser_push_expansion_macro (glcpp_parser_t *parser, - macro_t *macro, - argument_list_t *arguments); - -void -glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, - int argument_index); - -void -glcpp_parser_pop_expansion (glcpp_parser_t *parser); - /* Generated by glcpp-lex.l to glcpp-lex.c */ int |