brendan-duncan/wgsl_reflect

Unable to parse >=

Closed this issue · 8 comments

Before investing in using wgsl_reflect, I tried the test page:

https://brendan-duncan.github.io/wgsl_reflect/example.html

.. with my shader and found it is unable to parse this function:

highlightOverRangeColors.txt

Specifically these lines with >=:

var cEdgeBool : vec3 = c3 >= vec3(1.0);
var modVec : vec2 = floor(pos / checkerSize) % 2;

I'll get it fixed up shortly.

What problem are you seeing?

This is strange. On my work laptop, I simply pasted the code between the comments "//######" into your test page:

https://brendan-duncan.github.io/wgsl_reflect/example.html

And it produced errors. On my home MBP, it's not happening. Let me try again on my other laptop and I'll paste the error.

highlightOverRangeColors.txt
Try pasting the contents of this file into here:

https://brendan-duncan.github.io/wgsl_reflect/example.html

You'll see this error:

"Expected ';' after statement. Line 3. Found: '='."

Thanks, I can repo it now. Very strange, but I'll get it sorted out.

Figured out the issue, just have to find a solution. I have code in the scanner that tries to disambiguate >= between being a greater-equal or closing of a template followed by equals, as in a >= b from vec2<bool> = b.

Your code found the hole in my logic. var cEdgeBool : vec3<bool> = c3 >= vec3<f32>(1.0); makes the scanner think > in >= is a template close and it's getting split into > followed by =.

Back to the drawing board. Just have to make that logic a bit more robust.

The function is parsing now.

I also verified this issue has been resolved, thank you!