Module glsl::syntax[][src]

Expand description

GLSL abstract syntax tree and grammar.

This module exports all the grammar syntax that defines GLSL. You’ll be handling ASTs representing your GLSL source.

The most external form of a GLSL parsed AST is TranslationUnit (a shader). Some parts of the tree are boxed. This is due to two facts:

  • Recursion is used, hence we need a way to give our types a static size.
  • Because of some very deep variants, runtime size would explode if no indirection weren’t in place.

The types are commented so feel free to inspect each of theme. As a starter, you should read the documentation of Expr, FunctionDefinition, Statement and TranslationUnit.

Structs

Dimensionality of an array.

An identifier with an optional array specifier.

A general purpose block, containing fields and possibly a list of declared identifiers. Semantic is given with the storage qualifier.

Compound statement (with no new scope).

For init statement.

Fully specified type.

Function definition.

Function parameter declarator.

Function prototype.

A generic identifier.

Init declarator list.

Layout qualifier.

A non-empty Vec. It has at least one element.

An #else preprocessor directive.

An #error preprocessor directive.

An #extension preprocessor directive.

An #if preprocessor directive.

An #ifdef preprocessor directive.

A #ifndef preprocessor directive.

An #include name annotation.

A #line preprocessor directive.

A #pragma preprocessor directive. Holds compiler-specific command.

A #undef preprocessor directive.

A #version preprocessor directive.

Selection statement.

Single declaration.

A single declaration with implicit, already-defined type.

Struct field specifier. Used to add fields to struct specifiers.

Struct specifier. Used to create new, user-defined types.

Switch statement.

Starting rule.

Any type name.

Type qualifier.

Type specifier.

Enums

One array specifier dimension.

All possible operators for assigning expressions.

All binary operators that exist in GLSL.

Case label statement.

Condition.

A declaration.

The most general form of an expression. As you can see if you read the variant list, in GLSL, an assignment is an expression. This is a bit silly but think of an assignment as a statement first then an expression which evaluates to what the statement “returns”.

External declaration.

For init statement.

Function identifier.

Function parameter declaration.

Error that might occur when creating a new Identifier.

Initializer.

Interpolation qualifier.

Iteration statement.

Jump statement.

Layout qualifier spec.

A path literal.

Precision qualifier.

Some basic preprocessor directives.

A #define preprocessor directive.

An #extension behavior annotation.

An #extension name annotation.

A #version profile annotation.

Selection rest statement.

Simple statement.

Statement.

Storage qualifier.

Type qualifier spec.

Type specifier (non-array).

All unary operators that exist in GLSL.

Type Definitions

Expression statement.

A shader stage.