mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
Finish cleaning up whitespace differences.
The last remaining thing here was that when a line ended with a macro, and the parser looked ahead to the newline token, the lexer was printing that newline before the parser printed the expansion of the macro. The fix is simple, just make the lexer tell the parser that a newline is needed, and the parser can wait until reducing a production to print that newline. With this, we now pass the entire test suite with simply "diff -u", so we no longer have any diff options hiding whitespace bugs from us. Hurrah!
This commit is contained in:
parent
5a6b9a27fd
commit
876e510bda
3 changed files with 11 additions and 6 deletions
|
|
@ -173,12 +173,7 @@ TOKEN [^[:space:](),]+
|
|||
}
|
||||
|
||||
\n {
|
||||
/* XXX: Printing here (rather than in a parser production)
|
||||
* *and* frobbing a bit of the parser state here are both ugly
|
||||
* things. But all my attempts to avoid this by returning a
|
||||
* NEWLINE token here have led to even more ugly things. */
|
||||
printf ("\n");
|
||||
yyextra->just_printed_separator = 1;
|
||||
yyextra->need_newline = 1;
|
||||
}
|
||||
|
||||
{HSPACE}+
|
||||
|
|
|
|||
|
|
@ -171,6 +171,12 @@ input:
|
|||
|
||||
if ($2)
|
||||
talloc_free ($2);
|
||||
|
||||
if (parser->need_newline) {
|
||||
printf ("\n");
|
||||
parser->just_printed_separator = 1;
|
||||
parser->need_newline = 0;
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -564,6 +570,7 @@ glcpp_parser_create (void)
|
|||
parser->expansions = NULL;
|
||||
|
||||
parser->just_printed_separator = 1;
|
||||
parser->need_newline = 0;
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
|
@ -577,6 +584,8 @@ glcpp_parser_parse (glcpp_parser_t *parser)
|
|||
void
|
||||
glcpp_parser_destroy (glcpp_parser_t *parser)
|
||||
{
|
||||
if (parser->need_newline)
|
||||
printf ("\n");
|
||||
glcpp_lex_destroy (parser->scanner);
|
||||
hash_table_dtor (parser->defines);
|
||||
talloc_free (parser);
|
||||
|
|
|
|||
1
glcpp.h
1
glcpp.h
|
|
@ -102,6 +102,7 @@ struct glcpp_parser {
|
|||
struct hash_table *defines;
|
||||
expansion_node_t *expansions;
|
||||
int just_printed_separator;
|
||||
int need_newline;
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue