Gliss
A GLSL Lexer and Parser
Dependencies
None! You can easily copy and paste this code into another build system without much hassle.
Building
-
Install ib
-
Install clang
-
Run the build. To build on osx, use osx-debug config
# Use default debug config
ib gliss/test/lexer-test
# Use osx-debug config
ib gliss/test/lexer-test --cfg osx-debug.cfg
- If you modify the grammar file
docs/glsl.biglr
be sure to regenerate the parser using the provided script.
./regenerate_parser.sh
Building the NodeJS Module
Requires nodejs and emscripten
./build_js_binding.sh
View Language Docs
./view_parser_doc.sh
Getting Started
int
Use the NodeJS Binding!
npm install gliss
Generate an AST from GLSL source code
const gliss = require('gliss');
const ast = gliss.parse_glsl(`
#ifdef GL_ES
precision mediump float;
#endif
#extension GL_OES_standard_derivatives : enable
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;
void main( void ) {
vec2 pos = gl_FragCoord.xy/resolution.xy;
vec2 dif = pos - mouse;
float dist = 1.0-length(dif);
float power = pow(dist, 10.0);
float pulse = sin(time*20.0);
gl_FragColor = vec4(pos*dist, pulse*power, 1.0);
}
`);
console.log(ast);