o3de / o3de-azslc

Amazon Shader Language (AZSL) Compiler
Other
23 stars 14 forks source link

[ATOM-4800] Unclear Error Message for Function Inside Struct #6

Closed galibzon closed 3 years ago

galibzon commented 3 years ago

In order to catch the error of function inside struct it was necessary to modify the grammar to allow function definitions and declarations inside "struct" definitions (just like classes, interfaces and ShaderResourceGroups), this way the ANTLR parser would let it pass, giving the chance for AZSLc to provide a meaningful error message.

ANTLR Syntax Error message: "no viable alternative at input structParallaxMapping{Texture2Dm_depthMap;floatm_depthFactor;boolm_isHeightmap;floatm_parallaxShadowFactor;float2GetParallaxUV("

New AZSLc produced Error message: "function_declared_in_struct.azsl(14,4) : Syntax error #516: structs cannot have member functions; consider using a class."

Signed-off-by: garrieta garrieta@amazon.com