Aeva / m.grl

Midnight Graphics & Recreation Library
http://mgrl.midnightsisters.org
GNU Lesser General Public License v3.0
44 stars 3 forks source link

Some parse problem in glsl parser #264

Open jiazheng opened 6 years ago

jiazheng commented 6 years ago

I am using glsl parser in this project to do some glsl compression work for webgl. I found some problems in the result ast.

case 1: int i, j = 42;

the ast only provide some strings but no structured data but the following can:

int i1, j1 = 42;

but another problem occur: in this case i1 is not initialized, but the structured data tell me that both i1 and j1 are initialized with value of 42.

Aeva commented 6 years ago

Are these being defined as global variables or in the body of a function?

Aeva commented 6 years ago

Also a word of caution, if memory serves, the glsl->glsl transpiler doesn't produce a full AST. Rather, it produces just enough to recognize whatever high level language features I wanted to add and transform them into (hopefully) valid glsl. So whatever parts of the source it decides are fine as-is are just string tokens.

The behavior of the parser is just based on what syntax I happened to use at the time, and is not based on any formal standards documents.

I mainly used the compiler to make the interface between shaders and the engine a bit nicer and to fix work around various implementation specific compiler bugs.