]> git.mdlowis.com Git - archive/parse-utils.git/commitdiff
Cleaned up namespaces and added setters for AST class.
authorMike D. Lowis <mike@mdlowis.com>
Sat, 10 Mar 2012 20:23:40 +0000 (15:23 -0500)
committerMike D. Lowis <mike@mdlowis.com>
Sat, 10 Mar 2012 20:23:40 +0000 (15:23 -0500)
source/lexer/ilexer.cpp
source/parser/ast/ast.cpp
source/parser/ast/ast.h
source/parser/btparser/btparser.cpp
source/parser/iparser.h
source/visitor/astprinter/astprinter.cpp

index b90320dcde58fcd7d746c32c2d8334362ac41592..66288f705228071d66e03dc108c8994149b89775 100644 (file)
@@ -4,7 +4,7 @@
 
 using namespace std;
 
-ILexer::ILexer(istream& in) : line(-1), column(-1), in_stream(in)
+ILexer::ILexer(istream& in) : line(-1), column(-1), in_stream(in), current(in_stream.get())
 {
 }
 
index 273dd6e8e5a574e1d1195d7f6d3db2e00ff3ce4f..4f3a9938b44a3bbdb1a4f0898f96bf72a692a519 100644 (file)
@@ -3,6 +3,8 @@
 #include <string.h>
 #include <iostream>
 
+using namespace std;
+
 AST::AST(ASTNodeType type)
 {
     node_type = type;
@@ -69,6 +71,11 @@ ASTNodeType AST::type(void) const
     return node_type;
 }
 
+void AST::type(ASTNodeType typ)
+{
+    node_type = typ;
+}
+
 list<AST*>* AST::children(void)
 {
     return node_children;
@@ -79,6 +86,11 @@ string AST::text(void) const
     return node_text;
 }
 
+void AST::text(std::string& txt)
+{
+    node_text = txt;
+}
+
 void AST::addChild(AST* node)
 {
     node_children->push_back(node);
index ce9a89754045735a8e7972d048e124b1e7b268a6..abce052aaa3a334f251e29b49f2643f8783b2237 100644 (file)
@@ -5,30 +5,30 @@
 #include <list>
 #include <string>
 
-using namespace std;
-
 typedef unsigned int ASTNodeType;
 
 class AST
 {
     protected:
         ASTNodeType node_type;
-        string node_text;
-        list<AST*>* node_children;
+        std::string node_text;
+        std::list<AST*>* node_children;
     public:
         AST(ASTNodeType type);
         AST(ASTNodeType type, const char* text);
-        AST(ASTNodeType type, string text);
+        AST(ASTNodeType type, std::string text);
         AST(ASTNodeType type, int child_count, ...);
         virtual ~AST();
 
         AST& operator = (AST& rhs);
 
         ASTNodeType type(void) const;
-        string      text(void) const;
-        list<AST*>* children(void);
-        void        addChild(AST* node);
-        AST*        clone(void) const;
+        void type(ASTNodeType typ);
+        std::string text(void) const;
+        void text(std::string& txt);
+        std::list<AST*>* children(void);
+        void addChild(AST* node);
+        AST* clone(void) const;
 };
 
 #endif
index 0981361dbcfc2d764f1d34663fcb638c4e1f2bd7..a9138483d81c3ec48bef5a3362b1b7e84618deef 100644 (file)
@@ -1,6 +1,8 @@
 #include "btparser.h"
 #include "exception.h"
 
+using namespace std;
+
 BTParser::BTParser() : current(0)
 {
 }
index 747778dbefa40bf05963df3df57b55c9281b0ce5..9f01626cb936f891da373234c6b74dea17c20940 100644 (file)
@@ -23,8 +23,6 @@
 #include "ilexer.h"
 #include "ivisitor.h"
 
-using namespace std;
-
 class IParser {
     protected:
         AST*    result;
index 11e434ed937950220280fec772a4c63c64017c1f..c612f6259ad31c28623feea1b6c85ded71327932 100644 (file)
@@ -1,6 +1,7 @@
 #include <iostream>
 #include "astprinter.h"
 
+using namespace std;
 
 void ASTPrinter::beforeVisit(AST* cur, int depth)
 {