X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogramparser.h;h=72817e7ede06f8fe9607a2c17d8d99a503ea6c8e;hp=4c2d7b7ea5bc1049ddacede49a9f6a1cb280d3e7;hb=ca52c492bd4f2fa1a1db3a85e50eaf7c43474830;hpb=a29cc14162e911b36d18d1d1896216697c7dc0c1 diff --git a/source/programparser.h b/source/programparser.h index 4c2d7b7e..72817e7e 100644 --- a/source/programparser.h +++ b/source/programparser.h @@ -37,7 +37,13 @@ private: }; std::string source; + std::string source_name; + unsigned current_line; std::string::const_iterator iter; + std::string::const_iterator source_end; + bool allow_preprocess; + bool allow_stage_change; + std::string last_token; std::deque next_tokens; ProgramSyntax::Module *module; ProgramSyntax::Stage *cur_stage; @@ -49,19 +55,22 @@ public: ProgramParser(); ~ProgramParser(); - ProgramSyntax::Module &parse(const std::string &); - ProgramSyntax::Module &parse(IO::Base &); + ProgramSyntax::Module &parse(const std::string &, const std::string &); + ProgramSyntax::Module &parse(IO::Base &, const std::string &); private: void parse_source(); + std::string format_error(const std::string &); + std::string format_syntax_error(const std::string &); + const std::string &peek_token(unsigned = 0); - std::string parse_token(); + const std::string &parse_token(); std::string parse_token_(); std::string parse_identifier(); std::string parse_number(); std::string parse_other(); - bool skip_comment_and_whitespace(); + void skip_comment_and_whitespace(); void expect(const std::string &); std::string expect_type(); std::string expect_identifier(); @@ -69,27 +78,36 @@ private: static bool is_interface_qualifier(const std::string &); static bool is_sampling_qualifier(const std::string &); + 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 &); - ProgramSyntax::Node *parse_global_declaration(); - ProgramSyntax::Node *parse_statement(); - ProgramSyntax::Layout *parse_layout(); + void preprocess(); + void preprocess_pragma(); + void preprocess_pragma_msp(); + void preprocess_stage(); + + RefPtr parse_global_declaration(); + RefPtr parse_statement(); + RefPtr parse_import(); + RefPtr parse_precision(); + RefPtr parse_layout(); void parse_block(ProgramSyntax::Block &, bool); - ProgramSyntax::Expression *parse_expression(unsigned = 0); - ProgramSyntax::BinaryExpression *parse_binary(ProgramSyntax::Expression *, const Operator *); - ProgramSyntax::FunctionCall *parse_function_call(ProgramSyntax::VariableReference *); - ProgramSyntax::StructDeclaration *parse_struct_declaration(); - ProgramSyntax::VariableDeclaration *parse_variable_declaration(); - ProgramSyntax::FunctionDeclaration *parse_function_declaration(); - void parse_function_parameter_list(ProgramSyntax::FunctionDeclaration &); - ProgramSyntax::InterfaceBlock *parse_interface_block(); - ProgramSyntax::Conditional *parse_conditional(); - ProgramSyntax::Iteration *parse_iteration(); - ProgramSyntax::Passthrough *parse_passthrough(); - ProgramSyntax::Return *parse_return(); + RefPtr parse_expression(unsigned = 0); + RefPtr parse_binary(const RefPtr &, const Operator *); + RefPtr parse_function_call(const ProgramSyntax::VariableReference &); + RefPtr parse_struct_declaration(); + RefPtr parse_variable_declaration(); + RefPtr parse_function_declaration(); + RefPtr parse_interface_block(); + RefPtr parse_conditional(); + RefPtr parse_for(); + RefPtr parse_while(); + RefPtr parse_passthrough(); + RefPtr parse_return(); }; } // namespace GL