Collapse multiple spaces in input down to a single space.
This is what gcc does, and it's actually less work to do
this. Previously we were having to save the contents of space tokens
as a string, but we don't need to do that now.
We extend test #0 to exercise this feature here.
diff --git a/glcpp-parse.y b/glcpp-parse.y
index a198199..0460f71 100644
--- a/glcpp-parse.y
+++ b/glcpp-parse.y
@@ -132,8 +132,8 @@
%token HASH HASH_DEFINE_FUNC HASH_DEFINE_OBJ HASH_UNDEF IDENTIFIER NEWLINE OTHER SPACE
%token LEFT_SHIFT RIGHT_SHIFT LESS_OR_EQUAL GREATER_OR_EQUAL EQUAL NOT_EQUAL AND OR PASTE
-%type <ival> punctuator
-%type <str> IDENTIFIER OTHER SPACE
+%type <ival> punctuator SPACE
+%type <str> IDENTIFIER OTHER
%type <string_list> identifier_list
%type <token> preprocessing_token
%type <token_list> pp_tokens replacement_list text_line
@@ -235,7 +235,7 @@
$$ = _token_create_str (parser, OTHER, $1);
}
| SPACE {
- $$ = _token_create_str (parser, SPACE, $1);
+ $$ = _token_create_ival (parser, SPACE, SPACE);
}
;
@@ -495,9 +495,11 @@
switch (token->type) {
case IDENTIFIER:
case OTHER:
- case SPACE:
printf ("%s", token->value.str);
break;
+ case SPACE:
+ printf (" ");
+ break;
case LEFT_SHIFT:
printf ("<<");
break;