]> git.tdb.fi Git - libs/gl.git/blobdiff - source/programcompiler.h
Add file and line information to ProgramParser errors
[libs/gl.git] / source / programcompiler.h
index daf2a5db7904988f9e782e300b25e88ebcc47835..fea7a73fb78c3e8a0b68d12c7a9aa25f73018840 100644 (file)
@@ -26,6 +26,19 @@ private:
                void get_result() const { }
        };
 
+       struct BlockModifier: Visitor
+       {
+               bool remove_node;
+               std::list<RefPtr<ProgramSyntax::Node> > insert_nodes;
+
+               BlockModifier();
+
+               void flatten_block(ProgramSyntax::Block &);
+               void apply_and_increment(ProgramSyntax::Block &, std::list<RefPtr<ProgramSyntax::Node> >::iterator &);
+               using Visitor::visit;
+               virtual void visit(ProgramSyntax::Block &);
+       };
+
        struct Formatter: Visitor
        {
                typedef std::string ResultType;
@@ -77,12 +90,11 @@ private:
                virtual void visit(T &n) { nodes.push_back(&n); }
        };
 
-       struct DeclarationCombiner: Visitor
+       struct DeclarationCombiner: BlockModifier
        {
                bool toplevel;
                std::map<std::string, std::vector<ProgramSyntax::FunctionDeclaration *> > functions;
                std::map<std::string, ProgramSyntax::VariableDeclaration *> variables;
-               bool remove_node;
 
                DeclarationCombiner();
 
@@ -125,19 +137,6 @@ private:
                virtual void visit(ProgramSyntax::FunctionDeclaration &);
        };
 
-       struct BlockModifier: Visitor
-       {
-               bool remove_node;
-               std::list<RefPtr<ProgramSyntax::Node> > insert_nodes;
-
-               BlockModifier();
-
-               void flatten_block(ProgramSyntax::Block &);
-               void apply_and_increment(ProgramSyntax::Block &, std::list<RefPtr<ProgramSyntax::Node> >::iterator &);
-               using Visitor::visit;
-               virtual void visit(ProgramSyntax::Block &);
-       };
-
        struct InterfaceGenerator: BlockModifier
        {
                std::string in_prefix;
@@ -377,8 +376,9 @@ private:
 public:
        ProgramCompiler();
 
-       void compile(const std::string &);
-       void compile(IO::Base &, Resources * = 0);
+       void compile(const std::string &, const std::string & = "<string>");
+       void compile(IO::Base &, Resources * = 0, const std::string & = "<file>");
+       void compile(IO::Base &, const std::string &);
        void add_shaders(Program &);
 
 private: