X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fglsl%2Fparser.h;h=51616378c29c947653496ca71be80640081e55f4;hp=58b14b502f5bf550e1285098a651662fcf653bbe;hb=HEAD;hpb=9d798ac368bfd236a7632a3a15e51bd1112ea63d diff --git a/source/glsl/parser.h b/source/glsl/parser.h index 58b14b50..51616378 100644 --- a/source/glsl/parser.h +++ b/source/glsl/parser.h @@ -12,32 +12,42 @@ namespace Msp { namespace GL { namespace SL { +class ModuleCache; + class Parser { private: + ModuleCache *mod_cache; std::string source; - unsigned source_index; + int base_index; + int source_index; Tokenizer tokenizer; Preprocessor preprocessor; bool allow_stage_change; Module *module; + std::vector imported_modules; Stage *cur_stage; - std::set declared_types; + std::set global_types; + std::set stage_types; + std::vector errors; + RefPtr 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); + void line_change(int, unsigned); std::string expect_type(); std::string expect_identifier(); + int expect_integer(); bool check(const std::string &); static bool is_interface_qualifier(const std::string &); @@ -45,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 &); @@ -55,19 +64,31 @@ private: void preprocess_pragma_msp(); void preprocess_stage(); + template + RefPtr create_node(); + template + RefPtr parse_with_recovery(RefPtr (Parser::*)()); RefPtr parse_global_declaration(); RefPtr parse_statement(); RefPtr parse_import(); RefPtr parse_precision(); RefPtr parse_layout(); - void parse_block(Block &, bool); - RefPtr parse_expression(unsigned = 0); - RefPtr parse_binary(const RefPtr &, const Operator *); + template + void parse_block(Block &, bool, RefPtr (Parser::*)()); + RefPtr parse_expression(const Operator * = 0); + RefPtr parse_literal(); + RefPtr parse_binary(const RefPtr &, const Operator &); + RefPtr parse_ternary(const RefPtr &, const Operator &); RefPtr parse_function_call(const VariableReference &); + void add_type(TypeDeclaration &); + RefPtr parse_type_declaration(); + RefPtr parse_basic_type_declaration(); + RefPtr parse_image_type_declaration(); RefPtr parse_struct_declaration(); RefPtr parse_variable_declaration(); + RefPtr parse_variable_declaration_with_layout(); RefPtr parse_function_declaration(); - RefPtr parse_interface_block(); + RefPtr parse_interface_block(); RefPtr parse_conditional(); RefPtr parse_for(); RefPtr parse_while();