KhronosGroup / glslang

Khronos-reference front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator.
Other
2.99k stars 827 forks source link

Describe Unexpected Indentifier In Error #2261

Open areidmeyer opened 4 years ago

areidmeyer commented 4 years ago
#version 460
#extension GL_ARB_shading_language_420pack : enable

#define MYLIB_INT3 int3

struct Params
{
    MYLIB_INT3  x;
};

layout(std140, binding = 0) uniform gParams_t
{
    Params gParams;
};

layout(local_size_x = 128, local_size_y = 1, local_size_z = 1) in;
void main(void)
{

}

Currently, if I make this sort of mistake, I get this sort of error:

ERROR: 0:8: '' :  syntax error, unexpected IDENTIFIER
ERROR: 1 compilation errors.  No code generated.</code>

This example is oversimplified, for more complex cases it would be really useful if it could include the IDENTIFIER it couldn't resolve in the error. Something like:

ERROR: 0:6: '' :  syntax error, unexpected IDENTIFIER 'int3'

In particular, the post preprocessor identifier is helpful here for debugging.

johnkslang commented 4 years ago

This is actually part of the bison grammar recognition, not part of the semantics glslang implements and has full control over.

It used to say just "syntax error", and not give any clues at all. By adding %define parse.error verbose we get more.

If there are ideas how to improve this, please contribute.