graphitemaster / glsl-parser

A GLSL parser
MIT License
260 stars 30 forks source link

glsl-parser

glsl-parser is an offline GLSL parser which can be used to do many things with GLSL source code.

The straight-forward API allows you to parse GLSL into an abstact-syntax-tree in only a couple lines, for example

glsl::parser parse(sourceCode);
glsl::astTU *translationUnit = parse.parse(astTU::kFragment);
if (translationUnit) {
    // Do something with the AST here
} else {
    // A parse error occured
    fprintf(stderr, "%s\n", parse.error());
}

A test-suite and GLSL source-generator is included to get you started.

Check out the superior diagnostics here

Known limitations

Possible uses

Portable and embeddable