summaryrefslogtreecommitdiff
path: root/glcpp-parse.y
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2010-05-25 16:59:02 -0700
committerCarl Worth <cworth@cworth.org>2010-05-25 17:06:08 -0700
commitf34a0009dd07dbca4de5491744bd3618eae9458e (patch)
treec96275b2c2abf42482717e5daaa685838003d344 /glcpp-parse.y
parentb1854fdfb6b567fa61d544d8080e2acb4cc78dc1 (diff)
Pass through literal space values from replacement lists.
This makes test 15 pass and also dramatically simplifies the lexer. We were previously using a CONTROL state in the lexer to only emit SPACE tokens when on text lines. But that's not actually what we want. We need SPACE tokens in the replacement lists as well. Instead of a lexer state for this, we now simply set a "space_tokens" flag whenever we start constructing a pp_tokens list and clear the flag whenever we see a '#' introducing a directive. Much cleaner this way.
Diffstat (limited to 'glcpp-parse.y')
-rw-r--r--glcpp-parse.y10
1 files changed, 5 insertions, 5 deletions
diff --git a/glcpp-parse.y b/glcpp-parse.y
index 60b414e..a198199 100644
--- a/glcpp-parse.y
+++ b/glcpp-parse.y
@@ -160,7 +160,7 @@ line:
;
control_line:
- HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE {
+ HASH_DEFINE_OBJ IDENTIFIER replacement_list NEWLINE {
_define_object_macro (parser, $2, $3);
}
| HASH_DEFINE_FUNC IDENTIFIER '(' ')' replacement_list NEWLINE {
@@ -212,6 +212,7 @@ replacement_list:
pp_tokens:
preprocessing_token {
+ parser->space_tokens = 1;
$$ = _token_list_create (parser);
_token_list_append ($$, $1);
talloc_unlink (parser, $1);
@@ -234,7 +235,7 @@ preprocessing_token:
$$ = _token_create_str (parser, OTHER, $1);
}
| SPACE {
- $$ = _token_create_str (parser, OTHER, $1);
+ $$ = _token_create_str (parser, SPACE, $1);
}
;
@@ -494,6 +495,7 @@ _token_print (token_t *token)
switch (token->type) {
case IDENTIFIER:
case OTHER:
+ case SPACE:
printf ("%s", token->value.str);
break;
case LEFT_SHIFT:
@@ -589,6 +591,7 @@ glcpp_parser_create (void)
parser->defines = hash_table_ctor (32, hash_table_string_hash,
hash_table_string_compare);
parser->active = _string_list_create (parser);
+ parser->space_tokens = 1;
parser->expansions = NULL;
parser->just_printed_separator = 1;
@@ -835,9 +838,6 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
for (node = list->head; node; node = node->next) {
if (_glcpp_parser_print_expanded_token (parser, node->token))
_glcpp_parser_print_expanded_function (parser, &node);
-
- if (node->next)
- printf (" ");
}
}