X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fprogramparser.h;h=fa37118de262efe46c02ad0c6c13dcdf43b4517c;hp=0a46c09ece6202e18c71625afd916b8680f4806a;hb=bfeb6c6404659fffb1222e084b0bd08cccb4e67d;hpb=57c1139e4fe21aeca7118b18eb3ba6fa43d7bf90 diff --git a/source/programparser.h b/source/programparser.h index 0a46c09e..fa37118d 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,14 +78,21 @@ private: static bool is_interface_qualifier(const std::string &); static bool is_sampling_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 &); + 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); RefPtr parse_expression(unsigned = 0);