language-glsl icon indicating copy to clipboard operation
language-glsl copied to clipboard

GLSL preprocessor: support for #define, #ifdef etc.

Open kfish opened this issue 10 years ago • 3 comments

The preprocessor is part of the GLSL spec, section 3.4 of https://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf

Is it even possible to handle #define and #ifdef properly in language-glsl?

kfish avatar May 20 '14 20:05 kfish

Being a preprocessor, I thought it could (or even should) be implemented separately from the main parser (provided by language-glsl). But it seems it would be better to include it in language-glsl: for instance error messages have to take the #line directive into account.

I don't think it should be a problem for language-glsl to parse the preprocessor directives and expose them as top-level data types in the resulting parse tree. Or maybe even interpret them and push the result (e.g. optimization hint) into the existing (but then enriched) data types.

Conceptually mixing the line-oriented nature of the preprocessor with the rest of the language is a bit weird but I don't think it would prevent it to be part of the parser.

noteed avatar May 20 '14 21:05 noteed

@noteed @kfish Did anybody get a chance to look into this more? I was blocked by this issue recently, but I am not comfortable enough with Haskell to fix it

nphollon avatar Sep 02 '15 23:09 nphollon

@nphollon I don't think I will have time to work on this but would happily accept a patch.

noteed avatar Sep 03 '15 09:09 noteed