]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programparser.h
Record statement source lines and emit #line directives to output
[libs/gl.git] / source / programparser.h
index be6da197481aa3d264c7516427b55859e40e04d9..dc94bd0044443bd01ca862584e6784a58da4fb9f 100644 (file)
@@ -38,8 +38,12 @@ private:
 
        std::string source;
        std::string source_name;
+       unsigned source_index;
        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<std::string> next_tokens;
        ProgramSyntax::Module *module;
@@ -52,8 +56,8 @@ public:
        ProgramParser();
        ~ProgramParser();
 
-       ProgramSyntax::Module &parse(const std::string &, const std::string &);
-       ProgramSyntax::Module &parse(IO::Base &, const std::string &);
+       ProgramSyntax::Module &parse(const std::string &, const std::string &, unsigned = 0);
+       ProgramSyntax::Module &parse(IO::Base &, const std::string &, unsigned = 0);
 
 private:
        void parse_source();
@@ -67,7 +71,7 @@ private:
        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();
@@ -75,14 +79,20 @@ 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 &);
 
-       RefPtr<ProgramSyntax::Node> parse_global_declaration();
-       RefPtr<ProgramSyntax::Node> parse_statement();
+       void preprocess();
+       void preprocess_pragma();
+       void preprocess_pragma_msp();
+       void preprocess_stage();
+
+       RefPtr<ProgramSyntax::Statement> parse_global_declaration();
+       RefPtr<ProgramSyntax::Statement> parse_statement();
        RefPtr<ProgramSyntax::Import> parse_import();
        RefPtr<ProgramSyntax::Precision> parse_precision();
        RefPtr<ProgramSyntax::Layout> parse_layout();
@@ -95,7 +105,8 @@ private:
        RefPtr<ProgramSyntax::FunctionDeclaration> parse_function_declaration();
        RefPtr<ProgramSyntax::InterfaceBlock> parse_interface_block();
        RefPtr<ProgramSyntax::Conditional> parse_conditional();
-       RefPtr<ProgramSyntax::Iteration> parse_iteration();
+       RefPtr<ProgramSyntax::Iteration> parse_for();
+       RefPtr<ProgramSyntax::Iteration> parse_while();
        RefPtr<ProgramSyntax::Passthrough> parse_passthrough();
        RefPtr<ProgramSyntax::Return> parse_return();
 };