haxiomic / haxe-glsl-parser

GLSL ES 1.0 parser in Haxe
MIT License
26 stars 7 forks source link

Error parsing expressing using macro #11

Closed deanm closed 7 years ago

deanm commented 7 years ago

Possibly related to issue #5 ?

Some code like:

#define test(x) x
...
float r = test(sqrt(5.0));

Leads to Parser Warning: syntax error, '.0',

haxiomic commented 7 years ago

Hey thanks for reporting this one, it's fixed now :). Turned out to be an error when parsing macro calls: It was counting opening and closing parenthesis when collecting macro call arguments, but when counting it was skipping the character, doh!

5 is quite minor, if you have an expression in an #if macro, like #if 3 * 4 == 12, then it will leave the macro branch untouched because it can't evaluate the expression. This has to be done anyway for macros that are impossible to resolve at compiletime, ie #if GL_OES_standard_derivatives. But it will resolve all resolvable #ifdef branches