[Avida-SVN] r1788 - in development: Avida.xcodeproj source/script
brysonda at myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Wed Jul 11 11:30:11 PDT 2007
Author: brysonda
Date: 2007-07-11 14:30:11 -0400 (Wed, 11 Jul 2007)
New Revision: 1788
Added:
development/source/script/cASTVisitor.h
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/script/ASTree.cc
development/source/script/ASTree.h
Log:
AS: Stub in some more AST Node classes.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2007-07-11 15:16:00 UTC (rev 1787)
+++ development/Avida.xcodeproj/project.pbxproj 2007-07-11 18:30:11 UTC (rev 1788)
@@ -795,6 +795,7 @@
70DCF57F09CFBD3D00924128 /* tcmalloc-logging.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = "tcmalloc-logging.cc"; sourceTree = "<group>"; };
70DCF58009CFBD3D00924128 /* tcmalloc-logging.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = "tcmalloc-logging.h"; sourceTree = "<group>"; };
70E130BF0C442B2900CE9249 /* cCoords.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cCoords.h; sourceTree = "<group>"; };
+ 70E130E30C4551E900CE9249 /* cASTVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cASTVisitor.h; sourceTree = "<group>"; };
70F7DAEF09290468009E311D /* cClassificationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cClassificationManager.h; sourceTree = "<group>"; };
70F7DAF009290468009E311D /* cClassificationManager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cClassificationManager.cc; sourceTree = "<group>"; };
70F7DC9E09293E6F009E311D /* cGenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cGenotype.cc; sourceTree = "<group>"; };
@@ -1195,6 +1196,7 @@
702F52A80992F8F600B2B507 /* cSymbolTable.cc */,
702F52DE0992FD8000B2B507 /* cScriptObject.h */,
702F52DF0992FD8000B2B507 /* cScriptObject.cc */,
+ 70E130E30C4551E900CE9249 /* cASTVisitor.h */,
);
path = script;
sourceTree = "<group>";
Modified: development/source/script/ASTree.cc
===================================================================
--- development/source/script/ASTree.cc 2007-07-11 15:16:00 UTC (rev 1787)
+++ development/source/script/ASTree.cc 2007-07-11 18:30:11 UTC (rev 1788)
@@ -24,29 +24,23 @@
#include "ASTree.h"
+#include "cASTVisitor.h"
-void cASTExpressionUnary::Accept(cASTVisitor& visitor)
-{
-
-}
-void cASTExpressionBinary::Accept(cASTVisitor& visitor)
-{
-
-}
+void cASTAssignment::Accept(cASTVisitor& visitor) { visitor.visitAssignment(*this); }
-void cASTLiteral::Accept(cASTVisitor& visitor)
-{
-
-}
+void cASTStatementList::Accept(cASTVisitor& visitor) { visitor.visitStatementList(*this); }
-void cASTFunctionCall::Accept(cASTVisitor& visitor)
-{
-
-}
+void cASTForeachBlock::Accept(cASTVisitor& visitor) { visitor.visitForeachBlock(*this); }
+void cASTIfBlock::Accept(cASTVisitor& visitor) { visitor.visitIfBlock(*this); }
+void cASTWhileBlock::Accept(cASTVisitor& visitor) { visitor.visitWhileBlock(*this); }
-void cASTVariableReference::Accept(cASTVisitor& visitor)
-{
-
-}
+void cASTFunctionDefinition::Accept(cASTVisitor& visitor) { visitor.visitFunctionDefinition(*this); }
+void cASTVariableDefinition::Accept(cASTVisitor& visitor) { visitor.visitVariableDefinition(*this); }
+void cASTExpressionBinary::Accept(cASTVisitor& visitor) { visitor.visitExpressionBinary(*this); }
+void cASTExpressionUnary::Accept(cASTVisitor& visitor) { visitor.visitExpressionUnary(*this); }
+
+void cASTFunctionCall::Accept(cASTVisitor& visitor) { visitor.visitFunctionCall(*this); }
+void cASTLiteral::Accept(cASTVisitor& visitor) { visitor.visitLiteral(*this); }
+void cASTVariableReference::Accept(cASTVisitor& visitor) { visitor.visitVariableReference(*this); }
Modified: development/source/script/ASTree.h
===================================================================
--- development/source/script/ASTree.h 2007-07-11 15:16:00 UTC (rev 1787)
+++ development/source/script/ASTree.h 2007-07-11 18:30:11 UTC (rev 1788)
@@ -36,6 +36,11 @@
class cASTVisitor;
+// -- Abstract Syntax Tree Base Class
+// ---------------------------------------------------------------------------------------------------------------------
+
+
+//! Abstract base class for all AvidaScript abstract syntax tree nodes
class cASTNode
{
private:
@@ -52,21 +57,105 @@
};
-class cASTExpressionUnary : public cASTNode
+
+// -- Concrete Abstract Syntax Tree Nodes
+// ---------------------------------------------------------------------------------------------------------------------
+
+
+// -------- Assignment Nodes --------
+
+class cASTAssignment : public cASTNode
{
private:
- ASToken_t m_op;
- cASTNode* m_expr;
public:
- cASTExpressionUnary(ASToken_t op, cASTNode* e) : m_op(op), m_expr(e) { ; }
- ~cASTExpressionUnary() { delete m_expr; }
+ cASTAssignment() { ; }
- void SetExpression(cASTNode* expr) { m_expr = expr; }
+ void Accept(cASTVisitor& visitor);
+};
+
+
+
+// -------- Block Nodes --------
+
+class cASTStatementList : public cASTNode
+{
+private:
+public:
+ cASTStatementList() { ; }
+
void Accept(cASTVisitor& visitor);
};
+
+
+
+// -------- Conditional Block Nodes --------
+
+class cASTForeachBlock : public cASTNode
+{
+private:
+
+public:
+ cASTForeachBlock() { ; }
+
+ void Accept(cASTVisitor& visitor);
+};
+
+
+class cASTIfBlock : public cASTNode
+{
+private:
+
+public:
+ cASTIfBlock() { ; }
+
+ void Accept(cASTVisitor& visitor);
+};
+
+
+class cASTWhileBlock : public cASTNode
+{
+private:
+
+public:
+ cASTWhileBlock() { ; }
+
+ void Accept(cASTVisitor& visitor);
+};
+
+
+
+
+// -------- Definition Nodes --------
+
+class cASTFunctionDefinition : public cASTNode
+{
+private:
+
+public:
+ cASTFunctionDefinition() { ; }
+
+ void Accept(cASTVisitor& visitor);
+};
+
+
+class cASTVariableDefinition : public cASTNode
+{
+private:
+
+public:
+ cASTVariableDefinition() { ; }
+
+ void Accept(cASTVisitor& visitor);
+};
+
+
+
+
+// -------- Expression Operation Nodes --------
+
class cASTExpressionBinary : public cASTNode
{
private:
@@ -85,18 +174,25 @@
};
-class cASTLiteral : public cASTNode
+class cASTExpressionUnary : public cASTNode
{
private:
- ASToken_t m_type;
+ ASToken_t m_op;
+ cASTNode* m_expr;
public:
- cASTLiteral(ASToken_t t) : m_type(t) { ; }
-
+ cASTExpressionUnary(ASToken_t op, cASTNode* e) : m_op(op), m_expr(e) { ; }
+ ~cASTExpressionUnary() { delete m_expr; }
+
+ void SetExpression(cASTNode* expr) { m_expr = expr; }
+
void Accept(cASTVisitor& visitor);
};
+
+// -------- Expression Value Nodes --------
+
class cASTFunctionCall : public cASTNode
{
private:
@@ -108,6 +204,18 @@
};
+class cASTLiteral : public cASTNode
+{
+private:
+ ASToken_t m_type;
+
+public:
+ cASTLiteral(ASToken_t t) : m_type(t) { ; }
+
+ void Accept(cASTVisitor& visitor);
+};
+
+
class cASTVariableReference : public cASTNode
{
private:
Added: development/source/script/cASTVisitor.h
===================================================================
--- development/source/script/cASTVisitor.h (rev 0)
+++ development/source/script/cASTVisitor.h 2007-07-11 18:30:11 UTC (rev 1788)
@@ -0,0 +1,59 @@
+/*
+ * cASTVisitor.h
+ * Avida
+ *
+ * Created by David on 7/11/07.
+ * Copyright 2007 Michigan State University. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef cASTVisitor_h
+#define cASTVisitor_h
+
+#ifndef ASTree_h
+#include "ASTree.h"
+#endif
+
+
+class cASTVisitor
+{
+public:
+ cASTVisitor() { ; }
+ virtual ~cASTVisitor() { ; }
+
+
+ virtual void visitAssignment(cASTAssignment&) = 0;
+
+ virtual void visitStatementList(cASTStatementList&) = 0;
+
+ virtual void visitForeachBlock(cASTForeachBlock&) = 0;
+ virtual void visitIfBlock(cASTIfBlock&) = 0;
+ virtual void visitWhileBlock(cASTWhileBlock&) = 0;
+
+ virtual void visitFunctionDefinition(cASTFunctionDefinition&) = 0;
+ virtual void visitVariableDefinition(cASTVariableDefinition&) = 0;
+
+ virtual void visitExpressionBinary(cASTExpressionBinary&) = 0;
+ virtual void visitExpressionUnary(cASTExpressionUnary&) = 0;
+
+ virtual void visitFunctionCall(cASTFunctionCall&) = 0;
+ virtual void visitLiteral(cASTLiteral&) = 0;
+ virtual void visitVariableReference(cASTVariableReference&) = 0;
+};
+
+#endif
More information about the Avida-cvs
mailing list