]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/parser.h
Recognize the #line directive in the GLSL parser
[libs/gl.git] / source / glsl / parser.h
index c9588bfbdd99486a0e759df55ebd7c520ebeefb0..cdb57ebc5b48850bae81f4af251e5a841b669504 100644 (file)
@@ -1,12 +1,12 @@
 #ifndef MSP_GL_SL_PARSER_H_
 #define MSP_GL_SL_PARSER_H_
 
-#include <deque>
-#include <map>
 #include <set>
 #include <string>
 #include <msp/io/base.h>
+#include "preprocessor.h"
 #include "syntax.h"
+#include "tokenizer.h"
 
 namespace Msp {
 namespace GL {
@@ -15,44 +15,16 @@ namespace SL {
 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 base_index;
        unsigned source_index;
-       unsigned current_line;
-       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<std::string> next_tokens;
        Module *module;
        Stage *cur_stage;
        std::set<std::string> declared_types;
 
-       static Operator operators[];
-
 public:
        Parser();
        ~Parser();
@@ -61,19 +33,12 @@ public:
        Module &parse(IO::Base &, const std::string &, unsigned = 0);
 
 private:
-       void parse_source();
-
-       std::string format_error(const std::string &);
-       std::string format_syntax_error(const std::string &);
+       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();
        bool check(const std::string &);