+++ /dev/null
-#ifndef MSP_GL_PROGRAMSYNTAX_H_
-#define MSP_GL_PROGRAMSYNTAX_H_
-
-#include <map>
-#include <string>
-#include <vector>
-
-namespace Msp {
-namespace GL {
-namespace ProgramSyntax {
-
-struct NodeVisitor;
-
-struct Node
-{
- virtual ~Node() { }
-
- virtual void visit(NodeVisitor &) = 0;
-};
-
-struct Block: Node
-{
- std::vector<Node *> body;
- bool use_braces;
-
- Block();
- virtual ~Block();
-
- virtual void visit(NodeVisitor &);
-};
-
-struct Expression
-{
- std::vector<std::string> tokens;
-
- bool empty() const { return tokens.empty(); }
-};
-
-struct ExpressionStatement: Node
-{
- Expression expression;
-
- virtual void visit(NodeVisitor &);
-};
-
-struct Layout: Node
-{
- struct Qualifier
- {
- std::string identifier;
- std::string value;
- };
-
- std::vector<Qualifier> qualifiers;
- std::string interface;
-
- virtual void visit(NodeVisitor &);
-};
-
-struct StructDeclaration: Node
-{
- std::string name;
- Block members;
-
- StructDeclaration();
-
- virtual void visit(NodeVisitor &);
-};
-
-struct VariableDeclaration: Node
-{
- bool constant;
- std::string sampling;
- std::string interface;
- std::string type;
- std::string name;
- bool array;
- Expression array_size;
- Expression init_expression;
-
- VariableDeclaration();
-
- virtual void visit(NodeVisitor &);
-};
-
-struct InterfaceBlock: Node
-{
- std::string interface;
- std::string name;
- Block members;
-
- InterfaceBlock();
-
- virtual void visit(NodeVisitor &);
-};
-
-struct FunctionDeclaration: Node
-{
- std::string return_type;
- std::string name;
- std::vector<VariableDeclaration *> parameters;
- bool definition;
- Block body;
-
- FunctionDeclaration();
- ~FunctionDeclaration();
-
- virtual void visit(NodeVisitor &);
-};
-
-struct Conditional: Node
-{
- Expression condition;
- Block body;
- Block else_body;
-
- virtual void visit(NodeVisitor &);
-};
-
-struct Iteration: Node
-{
- Node *init_statement;
- Expression condition;
- Expression loop_expression;
- Block body;
-
- Iteration();
- virtual ~Iteration();
-
- virtual void visit(NodeVisitor &);
-};
-
-struct Return: Node
-{
- Expression expression;
-
- virtual void visit(NodeVisitor &);
-};
-
-struct NodeVisitor
-{
- virtual ~NodeVisitor() { }
-
- virtual void visit(Block &) { }
- virtual void visit(ExpressionStatement &) { }
- virtual void visit(Layout &) { }
- virtual void visit(StructDeclaration &) { }
- virtual void visit(VariableDeclaration &) { }
- virtual void visit(InterfaceBlock &) { }
- virtual void visit(FunctionDeclaration &) { }
- virtual void visit(Conditional &) { }
- virtual void visit(Iteration &) { }
- virtual void visit(Return &) { }
-};
-
-enum ContextType
-{
- GLOBAL,
- VERTEX,
- GEOMETRY,
- FRAGMENT
-};
-
-struct Context
-{
- ContextType type;
- bool present;
- ProgramSyntax::Block content;
-
- Context(ContextType);
-};
-
-struct Module
-{
- Context global_context;
- Context vertex_context;
- Context geometry_context;
- Context fragment_context;
- std::map<std::string, StructDeclaration *> structs;
-
- Module();
-};
-
-} // namespace ProgramSyntax
-} // namespace GL
-} // namespace Msp
-
-#endif