1) Allow '\' before a non-newline as a token in the preprocessor, and 2) localize line-continuation to just the pp scanner.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24530 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
27151efa71
commit
bd95819123
Binary file not shown.
@ -3,7 +3,16 @@ WARNING: 0:3: 'line continuation' : used at end of comment; the following line i
|
|||||||
ERROR: 0:6: '#error' : e1
|
ERROR: 0:6: '#error' : e1
|
||||||
ERROR: 0:11: '#error' : e2
|
ERROR: 0:11: '#error' : e2
|
||||||
ERROR: 0:18: '#error' : e3
|
ERROR: 0:18: '#error' : e3
|
||||||
ERROR: 3 compilation errors. No code generated.
|
ERROR: 0:42: '\' : illegal use of escape character
|
||||||
|
ERROR: 0:43: '@' : unexpected token
|
||||||
|
ERROR: 0:44: '$' : unexpected token
|
||||||
|
ERROR: 0:45: '\' : illegal use of escape character
|
||||||
|
ERROR: 0:47: '\' : illegal use of escape character
|
||||||
|
ERROR: 0:48: '\' : illegal use of escape character
|
||||||
|
ERROR: 0:49: '$' : unexpected token
|
||||||
|
ERROR: 0:50: '@' : unexpected token
|
||||||
|
ERROR: 0:55: '#error' : good continuation
|
||||||
|
ERROR: 12 compilation errors. No code generated.
|
||||||
|
|
||||||
|
|
||||||
ERROR: node is still EOpNull!
|
ERROR: node is still EOpNull!
|
||||||
@ -24,9 +33,56 @@ ERROR: node is still EOpNull!
|
|||||||
0:24 'a' (in highp 4-component vector of float)
|
0:24 'a' (in highp 4-component vector of float)
|
||||||
0:25 Branch: Return with expression
|
0:25 Branch: Return with expression
|
||||||
0:25 'b' (highp 4-component vector of float)
|
0:25 'b' (highp 4-component vector of float)
|
||||||
|
0:42 Sequence
|
||||||
|
0:42 move second child to first child (highp int)
|
||||||
|
0:42 'a1' (highp int)
|
||||||
|
0:42 Constant:
|
||||||
|
0:42 4 (const int)
|
||||||
|
0:43 Sequence
|
||||||
|
0:43 move second child to first child (highp int)
|
||||||
|
0:43 'a2' (highp int)
|
||||||
|
0:43 Constant:
|
||||||
|
0:43 3 (const int)
|
||||||
|
0:44 Sequence
|
||||||
|
0:44 move second child to first child (highp int)
|
||||||
|
0:44 'a3' (highp int)
|
||||||
|
0:44 Constant:
|
||||||
|
0:44 4 (const int)
|
||||||
|
0:45 Sequence
|
||||||
|
0:45 move second child to first child (highp int)
|
||||||
|
0:45 'a4' (highp int)
|
||||||
|
0:45 'a2' (highp int)
|
||||||
|
0:47 Sequence
|
||||||
|
0:47 move second child to first child (highp int)
|
||||||
|
0:47 'q1' (highp int)
|
||||||
|
0:47 Constant:
|
||||||
|
0:47 1 (const int)
|
||||||
|
0:48 Sequence
|
||||||
|
0:48 move second child to first child (highp int)
|
||||||
|
0:48 'q2' (highp int)
|
||||||
|
0:48 Constant:
|
||||||
|
0:48 1 (const int)
|
||||||
|
0:49 Sequence
|
||||||
|
0:49 move second child to first child (highp int)
|
||||||
|
0:49 'q3' (highp int)
|
||||||
|
0:49 Constant:
|
||||||
|
0:49 1 (const int)
|
||||||
|
0:50 Sequence
|
||||||
|
0:50 move second child to first child (highp int)
|
||||||
|
0:50 'q4' (highp int)
|
||||||
|
0:50 Constant:
|
||||||
|
0:50 1 (const int)
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
0:? 'foo' (highp float)
|
0:? 'foo' (highp float)
|
||||||
0:? 'goodDecl' (highp int)
|
0:? 'goodDecl' (highp int)
|
||||||
|
0:? 'a1' (highp int)
|
||||||
|
0:? 'a2' (highp int)
|
||||||
|
0:? 'a3' (highp int)
|
||||||
|
0:? 'a4' (highp int)
|
||||||
|
0:? 'q1' (highp int)
|
||||||
|
0:? 'q2' (highp int)
|
||||||
|
0:? 'q3' (highp int)
|
||||||
|
0:? 'q4' (highp int)
|
||||||
0:? 'gl_VertexID' (gl_VertexId highp int)
|
0:? 'gl_VertexID' (gl_VertexId highp int)
|
||||||
0:? 'gl_InstanceID' (gl_InstanceId highp int)
|
0:? 'gl_InstanceID' (gl_InstanceId highp int)
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,18 @@ ERROR: 0:14: 'line continuation' : not supported for this version or the enabled
|
|||||||
ERROR: 0:15: 'line continuation' : not supported for this version or the enabled extensions
|
ERROR: 0:15: 'line continuation' : not supported for this version or the enabled extensions
|
||||||
ERROR: 0:18: '#error' : e3
|
ERROR: 0:18: '#error' : e3
|
||||||
ERROR: 0:24: 'line continuation' : not supported for this version or the enabled extensions
|
ERROR: 0:24: 'line continuation' : not supported for this version or the enabled extensions
|
||||||
ERROR: 8 compilation errors. No code generated.
|
ERROR: 0:40: '\' : illegal use of escape character
|
||||||
|
ERROR: 0:41: '@' : unexpected token
|
||||||
|
ERROR: 0:42: '$' : unexpected token
|
||||||
|
ERROR: 0:43: '\' : illegal use of escape character
|
||||||
|
ERROR: 0:45: '\' : illegal use of escape character
|
||||||
|
ERROR: 0:46: '\' : illegal use of escape character
|
||||||
|
ERROR: 0:47: '$' : unexpected token
|
||||||
|
ERROR: 0:48: '@' : unexpected token
|
||||||
|
ERROR: 0:50: 'line continuation' : not supported for this version or the enabled extensions
|
||||||
|
ERROR: 0:52: 'line continuation' : not supported for this version or the enabled extensions
|
||||||
|
ERROR: 0:53: '#error' : bad continuation
|
||||||
|
ERROR: 19 compilation errors. No code generated.
|
||||||
|
|
||||||
|
|
||||||
ERROR: node is still EOpNull!
|
ERROR: node is still EOpNull!
|
||||||
@ -29,8 +40,55 @@ ERROR: node is still EOpNull!
|
|||||||
0:24 'a' (in highp 4-component vector of float)
|
0:24 'a' (in highp 4-component vector of float)
|
||||||
0:25 Branch: Return with expression
|
0:25 Branch: Return with expression
|
||||||
0:25 'b' (highp 4-component vector of float)
|
0:25 'b' (highp 4-component vector of float)
|
||||||
|
0:40 Sequence
|
||||||
|
0:40 move second child to first child (highp int)
|
||||||
|
0:40 'a1' (highp int)
|
||||||
|
0:40 Constant:
|
||||||
|
0:40 4 (const int)
|
||||||
|
0:41 Sequence
|
||||||
|
0:41 move second child to first child (highp int)
|
||||||
|
0:41 'a2' (highp int)
|
||||||
|
0:41 Constant:
|
||||||
|
0:41 3 (const int)
|
||||||
|
0:42 Sequence
|
||||||
|
0:42 move second child to first child (highp int)
|
||||||
|
0:42 'a3' (highp int)
|
||||||
|
0:42 Constant:
|
||||||
|
0:42 4 (const int)
|
||||||
|
0:43 Sequence
|
||||||
|
0:43 move second child to first child (highp int)
|
||||||
|
0:43 'a4' (highp int)
|
||||||
|
0:43 'a2' (highp int)
|
||||||
|
0:45 Sequence
|
||||||
|
0:45 move second child to first child (highp int)
|
||||||
|
0:45 'q1' (highp int)
|
||||||
|
0:45 Constant:
|
||||||
|
0:45 1 (const int)
|
||||||
|
0:46 Sequence
|
||||||
|
0:46 move second child to first child (highp int)
|
||||||
|
0:46 'q2' (highp int)
|
||||||
|
0:46 Constant:
|
||||||
|
0:46 1 (const int)
|
||||||
|
0:47 Sequence
|
||||||
|
0:47 move second child to first child (highp int)
|
||||||
|
0:47 'q3' (highp int)
|
||||||
|
0:47 Constant:
|
||||||
|
0:47 1 (const int)
|
||||||
|
0:48 Sequence
|
||||||
|
0:48 move second child to first child (highp int)
|
||||||
|
0:48 'q4' (highp int)
|
||||||
|
0:48 Constant:
|
||||||
|
0:48 1 (const int)
|
||||||
0:? Linker Objects
|
0:? Linker Objects
|
||||||
0:? 'foo' (highp float)
|
0:? 'foo' (highp float)
|
||||||
|
0:? 'a1' (highp int)
|
||||||
|
0:? 'a2' (highp int)
|
||||||
|
0:? 'a3' (highp int)
|
||||||
|
0:? 'a4' (highp int)
|
||||||
|
0:? 'q1' (highp int)
|
||||||
|
0:? 'q2' (highp int)
|
||||||
|
0:? 'q3' (highp int)
|
||||||
|
0:? 'q4' (highp int)
|
||||||
|
|
||||||
|
|
||||||
Linked vertex stage:
|
Linked vertex stage:
|
||||||
|
|||||||
@ -34,3 +34,24 @@ vec4 foo2(vec4 a)
|
|||||||
|
|
||||||
FOO
|
FOO
|
||||||
|
|
||||||
|
#define A int q1 = \ 1
|
||||||
|
#define B int q2 = \1
|
||||||
|
#define C int q3 = $ 1
|
||||||
|
#define D int q4 = @ 1
|
||||||
|
|
||||||
|
int a1 = \ 4; // ERROR
|
||||||
|
int a2 = @ 3; // ERROR
|
||||||
|
int a3 = $4; // ERROR
|
||||||
|
int a4 = a2\; // ERROR
|
||||||
|
|
||||||
|
A;
|
||||||
|
B;
|
||||||
|
C;
|
||||||
|
D;
|
||||||
|
|
||||||
|
# \
|
||||||
|
|
||||||
|
# \
|
||||||
|
error good continuation
|
||||||
|
|
||||||
|
#define AA a \ b
|
||||||
|
|||||||
@ -31,3 +31,23 @@ vec4 foo2(vec4 a)
|
|||||||
/*@*/
|
/*@*/
|
||||||
/* *@/*/
|
/* *@/*/
|
||||||
//@
|
//@
|
||||||
|
|
||||||
|
#define A int q1 = \ 1
|
||||||
|
#define B int q2 = \1
|
||||||
|
#define C int q3 = $ 1
|
||||||
|
#define D int q4 = @ 1
|
||||||
|
|
||||||
|
int a1 = \ 4; // ERROR
|
||||||
|
int a2 = @ 3; // ERROR
|
||||||
|
int a3 = $4; // ERROR
|
||||||
|
int a4 = a2\; // ERROR
|
||||||
|
|
||||||
|
A;
|
||||||
|
B;
|
||||||
|
C;
|
||||||
|
D;
|
||||||
|
|
||||||
|
# \
|
||||||
|
|
||||||
|
# \
|
||||||
|
error bad continuation
|
||||||
@ -9,5 +9,5 @@
|
|||||||
// source have to figure out how to create revision.h just to get a build
|
// source have to figure out how to create revision.h just to get a build
|
||||||
// going. However, if it is not updated, it can be a version behind.
|
// going. However, if it is not updated, it can be a version behind.
|
||||||
|
|
||||||
#define GLSLANG_REVISION "24518"
|
#define GLSLANG_REVISION "24522"
|
||||||
#define GLSLANG_DATE "2013/12/13 11:38:43"
|
#define GLSLANG_DATE "2013/12/13 12:26:54"
|
||||||
|
|||||||
@ -1484,6 +1484,7 @@ bool TParseContext::lineContinuationCheck(TSourceLoc loc, bool endOfComment)
|
|||||||
|
|
||||||
if (messages & EShMsgRelaxedErrors) {
|
if (messages & EShMsgRelaxedErrors) {
|
||||||
warn(loc, "not allowed in this version", message, "");
|
warn(loc, "not allowed in this version", message, "");
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, message);
|
requireProfile(loc, EEsProfile | ECoreProfile | ECompatibilityProfile, message);
|
||||||
profileRequires(loc, EEsProfile, 300, 0, message);
|
profileRequires(loc, EEsProfile, 300, 0, message);
|
||||||
|
|||||||
@ -478,6 +478,7 @@ void TScanContext::fillInKeywordMap()
|
|||||||
|
|
||||||
int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
|
int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
|
||||||
{
|
{
|
||||||
|
do {
|
||||||
parserToken = &token;
|
parserToken = &token;
|
||||||
TPpToken ppToken;
|
TPpToken ppToken;
|
||||||
tokenText = pp->tokenize(&ppToken);
|
tokenText = pp->tokenize(&ppToken);
|
||||||
@ -511,6 +512,9 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
|
|||||||
case ']': return RIGHT_BRACKET;
|
case ']': return RIGHT_BRACKET;
|
||||||
case '{': return LEFT_BRACE;
|
case '{': return LEFT_BRACE;
|
||||||
case '}': return RIGHT_BRACE;
|
case '}': return RIGHT_BRACE;
|
||||||
|
case '\\':
|
||||||
|
parseContext.error(loc, "illegal use of escape character", "\\", "");
|
||||||
|
break;
|
||||||
|
|
||||||
case CPP_AND_OP: return AND_OP;
|
case CPP_AND_OP: return AND_OP;
|
||||||
case CPP_SUB_ASSIGN: return SUB_ASSIGN;
|
case CPP_SUB_ASSIGN: return SUB_ASSIGN;
|
||||||
@ -543,9 +547,13 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
|
|||||||
case EOF: return 0;
|
case EOF: return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
parseContext.infoSink.info.message(EPrefixInternalError, "Unknown PP token", loc);
|
char buf[2];
|
||||||
return 0;
|
buf[0] = ppToken.token;
|
||||||
|
buf[1] = 0;
|
||||||
|
parseContext.error(loc, "unexpected token", buf, "");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TScanContext::tokenizeIdentifier()
|
int TScanContext::tokenizeIdentifier()
|
||||||
|
|||||||
@ -190,12 +190,6 @@ int TPpContext::CPPdefine(TPpToken* ppToken)
|
|||||||
TSourceLoc defineLoc = ppToken->loc; // because ppToken is going to go to the next line before we report errors
|
TSourceLoc defineLoc = ppToken->loc; // because ppToken is going to go to the next line before we report errors
|
||||||
mac.body = new TokenStream;
|
mac.body = new TokenStream;
|
||||||
while (token != '\n') {
|
while (token != '\n') {
|
||||||
if (token == '\\') {
|
|
||||||
parseContext.lineContinuationCheck(ppToken->loc, false);
|
|
||||||
token = currentInput->scan(this, currentInput, ppToken);
|
|
||||||
if (token == '\n' || token == '\r')
|
|
||||||
token = currentInput->scan(this, currentInput, ppToken);
|
|
||||||
}
|
|
||||||
RecordToken(mac.body, token, ppToken);
|
RecordToken(mac.body, token, ppToken);
|
||||||
token = currentInput->scan(this, currentInput, ppToken);
|
token = currentInput->scan(this, currentInput, ppToken);
|
||||||
if (token != '\n' && ppToken->space)
|
if (token != '\n' && ppToken->space)
|
||||||
|
|||||||
@ -281,20 +281,29 @@ int TPpContext::sourceScan(TPpContext* pp, InputSrc*, TPpToken* ppToken)
|
|||||||
case 'k': case 'l': case 'm': case 'n': case 'o':
|
case 'k': case 'l': case 'm': case 'n': case 'o':
|
||||||
case 'p': case 'q': case 'r': case 's': case 't':
|
case 'p': case 'q': case 'r': case 's': case 't':
|
||||||
case 'u': case 'v': case 'w': case 'x': case 'y':
|
case 'u': case 'v': case 'w': case 'x': case 'y':
|
||||||
case 'z': case '\\' :
|
case 'z': case '\\':
|
||||||
do {
|
do {
|
||||||
if (ch == '\\') {
|
if (ch == '\\') {
|
||||||
// escaped character
|
// escaped character
|
||||||
pp->parseContext.lineContinuationCheck(ppToken->loc, false);
|
|
||||||
ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
|
ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
|
||||||
if (ch == '\r' || ch == '\n') {
|
if (ch == '\r' || ch == '\n') {
|
||||||
|
pp->parseContext.lineContinuationCheck(ppToken->loc, false);
|
||||||
int nextch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
|
int nextch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
|
||||||
if (ch == '\r' && nextch == '\n')
|
if (ch == '\r' && nextch == '\n')
|
||||||
ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
|
ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
|
||||||
else
|
else
|
||||||
ch = nextch;
|
ch = nextch;
|
||||||
} else
|
} else {
|
||||||
pp->parseContext.error(ppToken->loc, "can only escape newlines", "\\", "");
|
// Not an escaped newline.
|
||||||
|
// Put back whatever it was
|
||||||
|
pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
|
||||||
|
// If not in the middle of an identifier, the \ is our token
|
||||||
|
if (len == 0)
|
||||||
|
return '\\';
|
||||||
|
// Otherwise, put back the \ character, leave it for the next call
|
||||||
|
ch = '\\'; // for the upcoming unget(...ch...);
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else if (len < TPpToken::maxTokenLength) {
|
} else if (len < TPpToken::maxTokenLength) {
|
||||||
tokenText[len++] = ch;
|
tokenText[len++] = ch;
|
||||||
ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
|
ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user