From fb28f6800864176be2ffca29e8e664b641f33170 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Mon, 21 Dec 2009 18:04:02 +0000 Subject: m3 is copied into trunk, we should be good to go, now. --- src/ast.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/ast.h (limited to 'src/ast.h') diff --git a/src/ast.h b/src/ast.h new file mode 100644 index 0000000..a4f9361 --- /dev/null +++ b/src/ast.h @@ -0,0 +1,44 @@ +#ifndef AST_H +#define AST_H + +#include "bu/list.h" +#include "bu/stack.h" +#include "bu/fstring.h" +#include "bu/formatter.h" + +#include "astnode.h" + +/** + * Abstract Symbol Tree. This is the thing that the parser builds for us. In + * the end, this is also what we "run" when we run build files. + */ +class Ast +{ +public: + typedef Bu::List NodeList; + Ast(); + virtual ~Ast(); + + void addNode( AstNode::Type eType ); + void addNode( AstNode::Type eType, int iVal ); + void addNode( AstNode::Type eType, float fVal ); + void addNode( AstNode::Type eType, bool bVal ); + void addNode( AstNode::Type eType, const Bu::FString &sVal ); + void addNode( AstNode::Type eType, const char *sVal ); + void addNode( AstNode *pNode ); + + void openBranch(); + + void closeNode(); + + NodeList::const_iterator getNodeBegin() const; + +private: + NodeList lNode; + typedef Bu::Stack BranchStack; + BranchStack sBranch; +}; + +Bu::Formatter &operator<<( Bu::Formatter &f, const Ast &a ); + +#endif -- cgit v1.2.3