diff options
author | Carl Worth <cworth@cworth.org> | 2010-05-29 06:03:32 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-05-29 06:03:40 -0700 |
commit | 96d3994881832201db7edd8a0a6f4b34655649d3 (patch) | |
tree | 2f599ca455e3fa16e0488516708e9871f07bbdb9 /glcpp.h | |
parent | ae3fb09cd20fc189d68f0c2a63cc74dd584d7ee1 (diff) | |
parent | 75ef1c75dd47a0b4054a767fd94f7c3cf68d2331 (diff) |
Merge branch 'take-2'
The take-2 branch started over with a new grammar based directly on
the grammar from the C99 specification. It doesn't try to capture
things like balanced sets of parentheses for macro arguments in the
grammar. Instead, it merely captures things as token lists and then
performs operations like parsing arguments and expanding macros on
those lists.
We merge it here since it's currently behaving better, (passing the
entire test suite). But the code base has proven quite fragile
really. Several of the recently added test cases required additional
special cases in the take-2 branch while working trivially on master.
So this merge point may be useful in the future, since we might have a
cleaner code base by coming back to the state before this merge and
fixing it, rather than accepting all the fragile
imperative/list-munging code from the take-2 branch.
Diffstat (limited to 'glcpp.h')
-rw-r--r-- | glcpp.h | 49 |
1 files changed, 35 insertions, 14 deletions
@@ -44,21 +44,36 @@ typedef struct string_list { string_node_t *tail; } string_list_t; -typedef struct token { +typedef struct token token_t; +typedef struct token_list token_list_t; + +typedef union YYSTYPE +{ + intmax_t ival; + char *str; + string_list_t *string_list; + token_t *token; + token_list_t *token_list; +} YYSTYPE; + +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 + +struct token { int type; - char *value; -} token_t; + YYSTYPE value; +}; typedef struct token_node { - int type; - const char *value; + token_t *token; struct token_node *next; } token_node_t; -typedef struct token_list { +struct token_list { token_node_t *head; token_node_t *tail; -} token_list_t; + token_node_t *non_space_tail; +}; typedef struct argument_node { token_list_t *argument; @@ -111,16 +126,16 @@ typedef struct skip_node { struct glcpp_parser { yyscan_t scanner; struct hash_table *defines; - expansion_node_t *expansions; - int just_printed_separator; - int need_newline; + string_list_t *active; + int space_tokens; + int newline_as_space; + int in_control_line; + int paren_count; skip_node_t *skip_stack; + token_list_t *lex_from_list; + token_node_t *lex_from_node; }; -void -glcpp_parser_push_expansion_argument (glcpp_parser_t *parser, - int argument_index); - glcpp_parser_t * glcpp_parser_create (void); @@ -164,4 +179,10 @@ xtalloc_strndup (const void *t, const char *p, size_t n); char * xtalloc_asprintf (const void *t, const char *fmt, ...); +void * +_xtalloc_reference_loc (const void *context, + const void *ptr, const char *location); + +#define xtalloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_xtalloc_reference_loc((ctx),(ptr), __location__) + #endif |