danielscherzer / GLSL

VSIX Project that provides GLSL language integration.
257 stars 28 forks source link

Using @ in preprocessor constants #96

Closed vtastek closed 2 years ago

vtastek commented 2 years ago

Installed product versions

Description

Using @ in preprocessor constants breaks syntax highlighting for the rest of the file.

Steps to recreate

#if @useGPUShader4
    #extension GL_EXT_gpu_shader4: require
#endif

uniform mat4 projectionMatrix;

Current behavior

#if @useGPUShader4
    #extension GL_EXT_gpu_shader4: require
#endif

uniform mat4 projectionMatrix;

Expected behavior

(highlighted)

#if @useGPUShader4
    #extension GL_EXT_gpu_shader4: require
#endif

uniform mat4 projectionMatrix;
danielscherzer commented 2 years ago

Thanks for your error report! Have you any justification that an "@" is allowed inside a preprocessor constant? I found only that the glsl spec says look at the c++ preprocessor specs and there they only talk of an identifier, which is defined here https://docs.microsoft.com/en-us/cpp/cpp/identifiers-cpp?view=msvc-170

vtastek commented 2 years ago

I am not a C++ dev, so I can't really comment. But the parse code that added "@" was committed 5 years ago as a "shader manager", mentioning "shader templates".

danielscherzer commented 2 years ago

I published a new version that should allow you to use "@" in identifiers. Hope this helps!

vtastek commented 2 years ago

Thanks for the update, it works as expected now.

AnyOldName3 commented 2 years ago

Just for context in case this makes someone break things, the @ is an OpenMW-specific extension to GLSL as we run it through our own preprocessor before the GLSL preprocessor, and we wanted a way to make it clear when that was happening, so picked an otherwise-illegal character. Obviously, it's a bit better if having a rogue character only breaks the immediate area around it rather than the whole file, but it's probably sensible to still leave a red squiggle under the symbol containing the @.