glsl/glcpp: Drop extra, final newline from most output

The glcpp parser is line-based, so it needs to see a NEWLINE token at the end
of each line. This causes a trick for files that end without a final newline.

Previously, the lexer for glcpp punted in this case by unconditionally
returning a NEWLINE token at end-of-file, (causing most files to have an extra
blank line at the end). Here, we refine this by lexing end-of-file as a
NEWLINE token only if the immediately preceding token was not a NEWLINE token.

The patch is a minor change that only looks huge for two reasons:

	1. Almost all glcpp test result ".expected" files are updated to drop
	   the extra newline.

	2. All return statements from the lexer are adjusted to use a new
	   RETURN_TOKEN macro that tracks the last-token-was-a-newline state.

Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
Carl Worth
2014-06-20 14:58:48 -07:00
parent 5dbdc341e8
commit 828686d4eb
130 changed files with 51 additions and 165 deletions
+1
View File
@@ -1308,6 +1308,7 @@ glcpp_parser_create (const struct gl_extensions *extensions, gl_api api)
parser->active = NULL;
parser->lexing_directive = 0;
parser->space_tokens = 1;
parser->last_token_was_newline = 0;
parser->newline_as_space = 0;
parser->in_control_line = 0;
parser->paren_count = 0;