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,2 +1 @@
this is four tokens with spaces
@@ -1,3 +1,2 @@
1
@@ -1,4 +1,3 @@
1
@@ -1,4 +1,3 @@
1
@@ -4,4 +4,3 @@
foo
bar
baz
@@ -1,4 +1,3 @@
a 1
@@ -1,4 +1,3 @@
a 1
@@ -4,4 +4,3 @@
a b c foo
b c a bar
c a b baz
@@ -1,3 +1,2 @@
@@ -2,4 +2,3 @@
1
foo
@@ -4,4 +4,3 @@
foo
2
@@ -1,3 +1,2 @@
@@ -1,3 +1,2 @@
bar
@@ -1,3 +1,2 @@
1
@@ -1,3 +1,2 @@
1
@@ -2,4 +2,3 @@
()1()
()2()
@@ -1,3 +1,2 @@
((bar)+1)
@@ -1,3 +1,2 @@
((bar)*(baz))
@@ -1,4 +1,3 @@
1
@@ -1,3 +1,2 @@
(this is more than one word)
@@ -1,3 +1,2 @@
one fish,two fish,red fish,blue fish
@@ -1,4 +1,3 @@
(2*((1+(3))))
@@ -1,3 +1,2 @@
(argument(including parens)for the win)
@@ -6,4 +6,3 @@
2
3 4
5 6 7
@@ -1,4 +1,3 @@
foo
@@ -1,3 +1,2 @@
foo bar
@@ -1,4 +1,3 @@
bar
@@ -1,4 +1,3 @@
success
@@ -1,4 +1,3 @@
success
@@ -1,4 +1,3 @@
success
@@ -2,4 +2,3 @@
success
@@ -2,4 +2,3 @@
success
@@ -1,3 +1,2 @@
foo(2*(3))
@@ -1,3 +1,2 @@
foo(2*(foo(2*(3))))
@@ -1,3 +1,2 @@
foo
@@ -1,4 +1,3 @@
more success
@@ -1,4 +1,3 @@
expand(just once)
@@ -1,3 +1,2 @@
success
@@ -1,4 +1,3 @@
(two,words)
@@ -1,3 +1,2 @@
onetoken
-1
View File
@@ -3,4 +3,3 @@ success_1
success_2
-1
View File
@@ -3,4 +3,3 @@ success_1
success_2
success_3
@@ -5,4 +5,3 @@ success_1
success_2
success_3
@@ -5,4 +5,3 @@ success_2
success_3
@@ -9,4 +9,3 @@ success_3
success_4
@@ -9,4 +9,3 @@ success_2
success_3
@@ -9,4 +9,3 @@ success_1
success_2
success_3
@@ -9,4 +9,3 @@ success_1
success_2
@@ -3,4 +3,3 @@
success
@@ -15,4 +15,3 @@ success_2
success_3
@@ -33,4 +33,3 @@ success_5
@@ -18,4 +18,3 @@ success_4
@@ -13,4 +13,3 @@ success_2
success_3
@@ -32,4 +32,3 @@ success_6
@@ -1,4 +1,3 @@
success
@@ -2,4 +2,3 @@
success
@@ -4,4 +4,3 @@ success
success
success
@@ -3,4 +3,3 @@ ab
a
b
@@ -2,4 +2,3 @@
12
1000
identifier2
@@ -3,4 +3,3 @@
success
@@ -3,4 +3,3 @@
@@ -18,4 +18,3 @@ more code here
are not treated like comments.
@@ -1,3 +1,2 @@
#version 130
@@ -15,4 +15,3 @@ success_2
success_3
@@ -1,4 +1,3 @@
success
@@ -38,4 +38,3 @@ success
success
@@ -9,4 +9,3 @@
| |
+ +
- -
@@ -1,3 +1,2 @@
1 1
@@ -3,4 +3,3 @@
Success
@@ -1,2 +1 @@
a = b
@@ -1,3 +1,2 @@
success_1 success_2 success_3
@@ -2,4 +2,3 @@
@@ -1,4 +1,3 @@
@@ -2,4 +2,3 @@
@@ -3,4 +3,3 @@
@@ -1,4 +1,3 @@
0:1(2): preprocessor error: else without #if
@@ -1,4 +1,3 @@
0:1(2): preprocessor error: elif without #if
@@ -1,4 +1,3 @@
0:1(2): preprocessor error: #endif without #if
@@ -3,4 +3,3 @@
@@ -2,4 +2,3 @@
@@ -17,4 +17,3 @@ Pasting "4" and "+" does not give a valid preprocessing token.
2
34
45.2
@@ -2,4 +2,3 @@
@@ -9,4 +9,3 @@ MULT()
MULT(1)
MULT(1,2,3)
@@ -7,4 +7,3 @@
@@ -3,4 +3,3 @@
win
@@ -3,4 +3,3 @@
@@ -27,4 +27,3 @@
@@ -1,3 +1,2 @@
0:1(2): preprocessor error: #error human error
@@ -16,4 +16,3 @@
#line 90 2
#line 180 2
@@ -7,4 +7,3 @@
@@ -1,4 +1,3 @@
0:1(13): preprocessor error: division by 0 in preprocessor directive
@@ -12,4 +12,3 @@
@@ -1,4 +1,3 @@
B(0, C)
@@ -1,4 +1,3 @@
justonetoken
@@ -1,4 +1,3 @@
onetoken
@@ -5,4 +5,3 @@
Yes, this.
@@ -14,4 +14,3 @@
f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1);
f(2 * (2 +(3,4)-0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^m(0,1);
int i[] = { 1, 23, 4, 5, };
@@ -5,4 +5,3 @@ switch (1) {
case 1 + 2:
break;
}

Some files were not shown because too many files have changed in this diff Show More