]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/parser.h
Inject builtins into the module
[libs/gl.git] / source / glsl / parser.h
index cdb57ebc5b48850bae81f4af251e5a841b669504..bce9698f7d608a4b3c18417bf2eef1d149f54a81 100644 (file)
@@ -16,24 +16,25 @@ class Parser
 {
 private:
        std::string source;
-       unsigned base_index;
-       unsigned source_index;
+       int base_index;
+       int source_index;
        Tokenizer tokenizer;
        Preprocessor preprocessor;
        bool allow_stage_change;
        Module *module;
        Stage *cur_stage;
        std::set<std::string> declared_types;
+       std::vector<std::string> errors;
 
 public:
        Parser();
        ~Parser();
 
-       Module &parse(const std::string &, const std::string &, unsigned = 0);
-       Module &parse(IO::Base &, const std::string &, unsigned = 0);
+       Module &parse(const std::string &, const std::string &, int);
+       Module &parse(IO::Base &, const std::string &, int);
 
 private:
-       void parse_source(const std::string &, unsigned);
+       void parse_source(const std::string &, int);
        void set_required_version(const Version &);
        void source_reference(unsigned, const std::string &);
        void stage_change(Stage::Type);
@@ -41,6 +42,7 @@ private:
 
        std::string expect_type();
        std::string expect_identifier();
+       int expect_integer();
        bool check(const std::string &);
 
        static bool is_interface_qualifier(const std::string &);
@@ -59,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();