Eliminate some recursion from children of _expand_token_list
Previously, both _expand_node and _expand_function would always make mutually recursive calls into _expand_token_list. This was unnecessary since these functions can simply return unexpanded results, after which the outer iteration will next attempt expansion of the results. The only trick in doing this is to arrange so that the active list is popped at the appropriate time. To do this, we add a new token_node_t marker to the active stack. When pushing onto the active list, we set marker to last->next, and when the marker is seen by the token list iteration, we pop from the active stack.
This commit is contained in:
@@ -123,10 +123,16 @@ typedef struct skip_node {
|
||||
struct skip_node *next;
|
||||
} skip_node_t;
|
||||
|
||||
typedef struct active_list {
|
||||
const char *identifier;
|
||||
token_node_t *marker;
|
||||
struct active_list *next;
|
||||
} active_list_t;
|
||||
|
||||
struct glcpp_parser {
|
||||
yyscan_t scanner;
|
||||
struct hash_table *defines;
|
||||
string_list_t *active;
|
||||
active_list_t *active;
|
||||
int lexing_if;
|
||||
int space_tokens;
|
||||
int newline_as_space;
|
||||
|
||||
Reference in New Issue
Block a user