X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fparser.h;h=1572128ffc6bb2378e0e465433a6e01240d6bbe4;hb=c6d59d1b35ee981c10ee8b9870338ffbaaa23e19;hp=743149d83362a84be8b91e5b13dad8789e90bede;hpb=47286086863b6009192ffdb3d3471c83211ee943;p=libs%2Fgl.git diff --git a/source/glsl/parser.h b/source/glsl/parser.h index 743149d8..1572128f 100644 --- a/source/glsl/parser.h +++ b/source/glsl/parser.h @@ -1,63 +1,30 @@ #ifndef MSP_GL_SL_PARSER_H_ #define MSP_GL_SL_PARSER_H_ -#include -#include #include #include #include +#include "preprocessor.h" #include "syntax.h" +#include "tokenizer.h" namespace Msp { namespace GL { namespace SL { -struct Location -{ - std::string name; - unsigned line; -}; - class Parser { private: - enum OperatorType - { - NO_OPERATOR, - BINARY, - PREFIX, - POSTFIX - }; - - enum Associativity - { - LEFT_TO_RIGHT, - RIGHT_TO_LEFT - }; - - struct Operator - { - const char token[4]; - unsigned precedence; - OperatorType type; - Associativity assoc; - }; - std::string source; + unsigned base_index; unsigned source_index; - Location location; - std::string::const_iterator iter; - std::string::const_iterator source_end; - bool allow_preprocess; + Tokenizer tokenizer; + Preprocessor preprocessor; bool allow_stage_change; - std::string last_token; - std::deque next_tokens; Module *module; Stage *cur_stage; std::set declared_types; - static Operator operators[]; - public: Parser(); ~Parser(); @@ -66,18 +33,15 @@ public: Module &parse(IO::Base &, const std::string &, unsigned = 0); private: - void parse_source(); + void parse_source(const std::string &, unsigned); + void set_required_version(const Version &); + void source_reference(unsigned, const std::string &); + void stage_change(Stage::Type); + void line_change(int, unsigned); - const std::string &peek_token(unsigned = 0); - const std::string &parse_token(); - std::string parse_token_(); - std::string parse_identifier(); - std::string parse_number(); - std::string parse_other(); - void skip_comment_and_whitespace(); - void expect(const std::string &); std::string expect_type(); std::string expect_identifier(); + int expect_integer(); bool check(const std::string &); static bool is_interface_qualifier(const std::string &);