guida-lang/glsl/1.0.0

Language.GLSL.Syntax

This module is part of an Elm implementation of a GLSL parser, inspired by the Haskell GLSL parser.

Reference: https://hackage.haskell.org/package/language-glsl-0.3.0/docs/src/Language.GLSL.Syntax.html

This implementation attempts to adapt the concepts and structure from the Haskell parser into the Elm ecosystem.

Abstract syntax tree

= TranslationUnit (List ExternalDeclaration)

Represents the top-level structure of a parsed GLSL shader.

A TranslationUnit is the root of the Abstract Syntax Tree (AST) for a GLSL shader.

= FunctionDeclaration FunctionPrototype
| FunctionDefinition FunctionPrototype Compound
| Declaration Declaration
= InitDeclaration InvariantOrType (List InitDeclarator)
| Block
String
(List Field)
(Maybe ( String, Maybe (Maybe Expr) ))
= InitDecl String (Maybe (Maybe Expr)) (Maybe Expr)
= InvariantDeclarator
| TypeDeclarator FullType
= FuncProt FullType String (List ParameterDeclaration)
= ParameterDeclaration
(Maybe ( String, Maybe Expr ))
= FullType (Maybe TypeQualifier) TypeSpecifier
= Invariant
= Smooth
| Flat
| NoPerspective
= Layout (List LayoutQualifierId)
= LayoutQualId String (Maybe Expr)
= DeclarationStatement Declaration
| Continue
| Break
| Return (Maybe Expr)
| Discard
| CompoundStatement Compound
| ExpressionStatement (Maybe Expr)
| SelectionStatement Expr Statement (Maybe Statement)
| SwitchStatement Expr (List Statement)
| CaseLabel CaseLabel
| DoWhile Statement Expr
| For
(Result (Maybe Expr) Declaration)
(Maybe Condition)
(Maybe Expr)
= Compound (List Statement)
= Condition Expr
| InitializedCondition FullType String Expr
= Case Expr
| Default
= Const
| Attribute
| Varying
| CentroidVarying
| In
| Out
| CentroidIn
| CentroidOut
| Uniform
= TypeSpecNoPrecision TypeSpecifierNonArray (Maybe (Maybe Expr))
= Void
| Float
| Int
| UInt
| Bool
| Vec2
| Vec3
| Vec4
| BVec2
| BVec3
| BVec4
| IVec2
| IVec3
| IVec4
| UVec2
| UVec3
| UVec4
| Mat2
| Mat3
| Mat4
| Mat2x2
| Mat2x3
| Mat2x4
| Mat3x2
| Mat3x3
| Mat3x4
| Mat4x2
| Mat4x3
| Mat4x4
| Sampler1D
| Sampler2D
| Sampler3D
| SamplerCube
| Sampler1DShadow
| Sampler2DShadow
| SamplerCubeShadow
| Sampler1DArray
| Sampler2DArray
| Sampler1DArrayShadow
| Sampler2DArrayShadow
| ISampler1D
| ISampler2D
| ISampler3D
| ISamplerCube
| ISampler1DArray
| ISampler2DArray
| USampler1D
| USampler2D
| USampler3D
| USamplerCube
| USampler1DArray
| USampler2DArray
| Sampler2DRect
| Sampler2DRectShadow
| ISampler2DRect
| USampler2DRect
| SamplerBuffer
| ISamplerBuffer
| USamplerBuffer
| Sampler2DMS
| ISampler2DMS
| USampler2DMS
| Sampler2DMSArray
| ISampler2DMSArray
| USampler2DMSArray
| StructSpecifier (Maybe String) (List Field)
| TypeName String
= HighP
| MediumP
| LowP
= StructDeclarator String (Maybe (Maybe Expr))
type Expr
= Variable String
| IntConstant IntConstantKind Int
| FloatConstant Float
| BoolConstant Bool
| Bracket Expr Expr
| FieldSelection Expr String
| PostInc Expr
| PostDec Expr
| PreInc Expr
| PreDec Expr
| UnaryPlus Expr
| UnaryNegate Expr
| UnaryNot Expr
| UnaryOneComplement Expr
| Mul Expr Expr
| Div Expr Expr
| Mod Expr Expr
| Add Expr Expr
| Sub Expr Expr
| LeftShift Expr Expr
| RightShift Expr Expr
| Lt Expr Expr
| Gt Expr Expr
| Lte Expr Expr
| Gte Expr Expr
| Equ Expr Expr
| Neq Expr Expr
| BitAnd Expr Expr
| BitXor Expr Expr
| BitOr Expr Expr
| And Expr Expr
| Or Expr Expr
| Selection Expr Expr Expr
| Equal Expr Expr
| MulAssign Expr Expr
| DivAssign Expr Expr
| ModAssign Expr Expr
| AddAssign Expr Expr
| SubAssign Expr Expr
| LeftAssign Expr Expr
| RightAssign Expr Expr
| AndAssign Expr Expr
| XorAssign Expr Expr
| OrAssign Expr Expr
| Sequence Expr Expr
= Hexadecimal
| Octal
| Decimal
= ParamVoid
| Params (List Expr)
= InParameter
| OutParameter
| InOutParameter
= ConstParameter
= FuncIdTypeSpec TypeSpecifier
| FuncId String