]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/parser.h
Check the flat qualifier from the correct member
[libs/gl.git] / source / glsl / parser.h
index 9ab1232aaa0d9ad7aec82b24ee873b8b4e998e16..51616378c29c947653496ca71be80640081e55f4 100644 (file)
@@ -12,28 +12,34 @@ namespace Msp {
 namespace GL {
 namespace SL {
 
+class ModuleCache;
+
 class Parser
 {
 private:
+       ModuleCache *mod_cache;
        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;
+       std::vector<const Module *> imported_modules;
        Stage *cur_stage;
-       std::set<std::string> declared_types;
+       std::set<std::string> global_types;
+       std::set<std::string> stage_types;
+       std::vector<std::string> errors;
+       RefPtr<Statement> next_global_declaration;
 
 public:
-       Parser();
-       ~Parser();
+       Parser(ModuleCache *);
 
-       Module &parse(const std::string &, const std::string &, unsigned = 0);
-       Module &parse(IO::Base &, const std::string &, unsigned = 0);
+       void parse(Module &, const std::string &, const std::string &, int);
+       void parse(Module &, 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);
@@ -49,7 +55,6 @@ private:
        static bool is_interpolation_qualifier(const std::string &);
        static bool is_precision_qualifier(const std::string &);
        static bool is_qualifier(const std::string &);
-       static bool is_builtin_type(const std::string &);
        bool is_type(const std::string &);
        bool is_identifier(const std::string &);
 
@@ -59,6 +64,10 @@ private:
        void preprocess_pragma_msp();
        void preprocess_stage();
 
+       template<typename T>
+       RefPtr<T> create_node();
+       template<typename T>
+       RefPtr<T> parse_with_recovery(RefPtr<T> (Parser::*)());
        RefPtr<Statement> parse_global_declaration();
        RefPtr<Statement> parse_statement();
        RefPtr<Import> parse_import();
@@ -66,14 +75,20 @@ private:
        RefPtr<Layout> parse_layout();
        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<Expression> parse_expression(const Operator * = 0);
+       RefPtr<Literal> parse_literal();
+       RefPtr<BinaryExpression> parse_binary(const RefPtr<Expression> &, const Operator &);
+       RefPtr<TernaryExpression> parse_ternary(const RefPtr<Expression> &, const Operator &);
        RefPtr<FunctionCall> parse_function_call(const VariableReference &);
+       void add_type(TypeDeclaration &);
+       RefPtr<TypeDeclaration> parse_type_declaration();
+       RefPtr<BasicTypeDeclaration> parse_basic_type_declaration();
+       RefPtr<ImageTypeDeclaration> parse_image_type_declaration();
        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<StructDeclaration> parse_interface_block();
        RefPtr<Conditional> parse_conditional();
        RefPtr<Iteration> parse_for();
        RefPtr<Iteration> parse_while();