haxiomic / haxe-glsl-parser

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

feature: Support GLSL ES 3.00 (WebGL 2) #14

Open deanm opened 7 years ago

deanm commented 7 years ago

I don't think the differences are too massive, you could probably parse it just as a superset of what is there now. It would then be really great to have printers to more or less go back and forth between the two versions.

deanm commented 7 years ago

As a starting point, I would really happy just to have layout qualifiers on attributes : )

haxiomic commented 7 years ago

GLSL ES 3.0 -> 1.0 transpilation would be pretty awesome :)

Parsing 3.0 is not a massively difficult undertaking but it is time consuming. The parser generator was designed to use the grammar from the specification: GLES-100_v4.txt is the grammar copied out of the spec with some haxe code added to turn the rules to nodes (and some special additional rules help track parsing scope and accept preprocessor lines as nodes).

The 3.0 spec says

In general the above grammar describes a super set of the GLSL ES language

So by doing a diff between the new grammar (section 9) and the old one (section 9) you could determine which new rules, tokens and nodes need to be added.

The modified grammar would then be used to automatically generate new parser code. There's some detail on how this is done here.

My workload is pretty steep at my day job so although I plan to revisit this repo for new features and refactoring, it's unlikely to happen until the summer