X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Fparser.h;h=b6c8369debb91d379e66d8f1a2afda5f2e53bea9;hb=7a16308e72aef363727b21348779673edf8e5c07;hp=743149d83362a84be8b91e5b13dad8789e90bede;hpb=47286086863b6009192ffdb3d3471c83211ee943;p=libs%2Fgl.git diff --git a/source/glsl/parser.h b/source/glsl/parser.h index 743149d8..b6c8369d 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; + std::string source_name; 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,16 +33,10 @@ public: Module &parse(IO::Base &, const std::string &, unsigned = 0); private: - void parse_source(); + void parse_source(const std::string &); + void set_required_version(const Version &); + void stage_change(Stage::Type); - 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(); bool check(const std::string &);