Scanning: 1) rationalize end-of-input everywhere, 2) prevent infinite loop at end-of-input, 3) use positive chars.

Fixes issue #25. (char 255 aliased to -1 and missing tests for end of input).

1) All layers of input scanning now share a single EndOfInput value.
This avoids translation of it across layers of encapsulation.

2) Some places looking for end of line were not stopping on EndOfInput.

3) Use of "char" for the input made char values > 127 be negative numbers.
This allowed for aliasing of 255 to -1, etc.  This is fixed by using
unsigned char.
This commit is contained in:
John Kessenich
2015-07-27 09:37:55 -06:00
parent 91b977e172
commit c777fc2c4c
15 changed files with 134 additions and 112 deletions

6
Test/badChars.frag Normal file
View File

@@ -0,0 +1,6 @@
#if<69>
#endif
#error A<>B
#if
#endif
int a<EFBFBD>

View File

@@ -0,0 +1,26 @@
badChars.frag
ERROR: 0:1: 'preprocessor evaluation' : bad expression
ERROR: 0:1: '#if' : unexpected tokens following directive
ERROR: 0:3: '#error' : A <bad token> B
ERROR: 0:4: 'preprocessor evaluation' : bad expression
ERROR: 0:4: '#if' : unexpected tokens following directive
ERROR: 0:6: '<27>' : unexpected token
ERROR: 0:7: '' : syntax error
ERROR: 7 compilation errors. No code generated.
Shader version: 100
ERROR: node is still EOpNull!
0:? Linker Objects
0:? 'a' (global mediump int)
Linked fragment stage:
ERROR: Linking fragment stage: Missing entry point: Each stage requires one "void main()" entry point
Shader version: 100
ERROR: node is still EOpNull!
0:? Linker Objects
0:? 'a' (global mediump int)

View File

@@ -5,19 +5,19 @@ ERROR: 0:66: '#define' : Macro redefined; different substitutions: BIG
ERROR: 0:81: 'preprocessor evaluation' : bad expression
ERROR: 0:81: '#if' : unexpected tokens following directive
ERROR: 0:82: '#error' : good macro
ERROR: 0:87: 'macro expansion' : end of line in macro substitution: foobar
ERROR: 0:87: 'macro expansion' : End of line in macro substitution: foobar
ERROR: 0:88: 'preprocessor evaluation' : can't evaluate expression
ERROR: 0:88: 'preprocessor evaluation' : bad expression
ERROR: 0:88: '#if' : unexpected tokens following directive
ERROR: 0:92: 'macro expansion' : end of line in macro substitution: foobar
ERROR: 0:92: 'macro expansion' : End of line in macro substitution: foobar
ERROR: 0:93: 'preprocessor evaluation' : can't evaluate expression
ERROR: 0:93: 'preprocessor evaluation' : bad expression
ERROR: 0:93: '#if' : unexpected tokens following directive
ERROR: 0:99: 'macro expansion' : end of line in macro substitution: foobar
ERROR: 0:99: 'macro expansion' : End of line in macro substitution: foobar
ERROR: 0:100: 'preprocessor evaluation' : can't evaluate expression
ERROR: 0:100: 'preprocessor evaluation' : bad expression
ERROR: 0:100: '#if' : unexpected tokens following directive
ERROR: 0:101: 'macro expansion' : end of line in macro substitution: foobar
ERROR: 0:101: 'macro expansion' : End of line in macro substitution: foobar
ERROR: 0:102: 'preprocessor evaluation' : can't evaluate expression
ERROR: 0:102: 'preprocessor evaluation' : bad expression
ERROR: 0:102: '#if' : unexpected tokens following directive

View File

@@ -3,7 +3,7 @@ ERROR: 0:144: '#elif' : #elif after #else
ERROR: 0:152: '#else' : #else after #else
ERROR: 0:161: '#elif' : #elif after #else
ERROR: 0:169: '#else' : #else after #else
ERROR: 0:177: 'macro expansion' : EOF in macro FUNC
ERROR: 0:177: 'macro expansion' : End of input in macro FUNC
ERROR: 0:178: '' : syntax error
ERROR: 6 compilation errors. No code generated.

View File

@@ -13,10 +13,10 @@ ERROR: 0:49: '$' : unexpected token
ERROR: 0:50: '@' : unexpected token
ERROR: 0:55: '#error' : good continuation
WARNING: 0:62: 'line continuation' : used at end of comment; the following line is still part of the comment
ERROR: 0:111: 'macro expansion' : end of line in macro substitution: FOOM
ERROR: 0:111: 'macro expansion' : End of line in macro substitution: FOOM
ERROR: 0:112: 'preprocessor evaluation' : can't evaluate expression
ERROR: 0:112: '#if' : unexpected tokens following directive
ERROR: 0:117: 'macro expansion' : end of line in macro substitution: FOOM
ERROR: 0:117: 'macro expansion' : End of line in macro substitution: FOOM
ERROR: 0:118: 'preprocessor evaluation' : can't evaluate expression
ERROR: 0:118: '#if' : unexpected tokens following directive
ERROR: 0:150: '' : syntax error

View File

@@ -25,6 +25,7 @@ cppSimple.vert
cppIndent.vert
cppNest.vert
cppComplexExpr.vert
badChars.frag
pointCoord.frag
array.frag
array100.frag