34 releases (12 breaking)

0.13.5 Dec 8, 2018
0.13.4 Nov 25, 2018
0.12.0 Nov 11, 2018
0.9.1 Jul 6, 2018
0.3.0 Jul 31, 2017

#82 in Parser tooling

Download history 50/week @ 2018-12-14 276/week @ 2018-12-21 5/week @ 2018-12-28 51/week @ 2019-01-04 12/week @ 2019-01-11 21/week @ 2019-01-18 8/week @ 2019-01-25 2/week @ 2019-02-01 1/week @ 2019-02-08 3/week @ 2019-02-15 1/week @ 2019-02-22 75/week @ 2019-03-01 11/week @ 2019-03-08 35/week @ 2019-03-15 618/week @ 2019-03-22

641 downloads per month
Used in 3 crates (2 directly)


5.5K SLoC

GLSL 450 parser


This is a GLSL450 parser which aims is to parse a GLSL450-formatted source into an in-memory representation (AST). It strictly follows the grammar rules defined in the official GLSL 450 specifications.

Currently, the parser expects the input source to be &[u8], which provides a pretty poor experience in error reporting. This is a serious issue and is being worked on.

The crate provides several features. Feel free to have a look at the official documentation for further information and tutorials.


GLSL compiler

This crate is a GLSL450 compiler. It’s able to parse valid GLSL450 formatted source into an abstract syntax tree (AST). That AST can then be transformed into SPIR-V, your own format or even folded back to a raw GLSL [String] (think of a minifier, for instance).

You’ll find several modules:

  • [parser], which exports the parsing interface.
  • [syntax], which exports the AST and language definitions.
  • [transpiler], which provides you with GLSL transpilers.
  • visitor, which gives you a way to visit AST nodes and mutate them, both with inner and outer mutation.

Feel free to inspect those modules for further information.

Parsing architecture

Basically, the Parse trait gives you all you need to start parsing. This crate is designed around the concept of type-driven parsing: parsers are hidden and you just have to state what result type you expect.

The most common type you want to parse to is TranslationUnit, which represents a set of ExternalDeclarations. An ExternalDeclaration is just a declaration at the top-most level of a shader. It can be a global, uniform declarations, vertex attributes, a function, a structure, etc.

The crate is also getting more and more combinators and functions to transform the AST or create nodes with regular Rust. The Visitor trait will be a great friend of yours when you will want to cope with deep mutation, filtering and validation.


~15K SLoC