]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/parser.h
Make the GLSL parser resilient against common errors
[libs/gl.git] / source / glsl / parser.h
index 1572128ffc6bb2378e0e465433a6e01240d6bbe4..acfb7d9eed9a8cc857becf5436e59a92bac522ba 100644 (file)
@@ -24,6 +24,7 @@ private:
        Module *module;
        Stage *cur_stage;
        std::set<std::string> declared_types;
+       std::vector<std::string> errors;
 
 public:
        Parser();
@@ -60,16 +61,20 @@ private:
        void preprocess_stage();
 
        RefPtr<Statement> parse_global_declaration();
+       template<typename T>
+       RefPtr<T> parse_with_recovery(RefPtr<T> (Parser::*)());
        RefPtr<Statement> parse_statement();
        RefPtr<Import> parse_import();
        RefPtr<Precision> parse_precision();
        RefPtr<Layout> parse_layout();
-       void parse_block(Block &, bool);
+       template<typename T>
+       void parse_block(Block &, bool, RefPtr<T> (Parser::*)());
        RefPtr<Expression> parse_expression(unsigned = 0);
        RefPtr<BinaryExpression> parse_binary(const RefPtr<Expression> &, const Operator *);
        RefPtr<FunctionCall> parse_function_call(const VariableReference &);
        RefPtr<StructDeclaration> parse_struct_declaration();
        RefPtr<VariableDeclaration> parse_variable_declaration();
+       RefPtr<VariableDeclaration> parse_variable_declaration_with_layout();
        RefPtr<FunctionDeclaration> parse_function_declaration();
        RefPtr<InterfaceBlock> parse_interface_block();
        RefPtr<Conditional> parse_conditional();