[Avida-SVN] r1721 - in development: Avida.xcodeproj source/script

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Jun 27 12:43:41 PDT 2007


Author: brysonda
Date: 2007-06-27 15:43:41 -0400 (Wed, 27 Jun 2007)
New Revision: 1721

Added:
   development/source/script/ASTree.cc
   development/source/script/ASTree.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/script/AvidaScript.h
   development/source/script/cLexer.l
   development/source/script/cParser.cc
Log:
Update cParser grammar.  Add some missing ASTree files.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2007-06-26 21:54:06 UTC (rev 1720)
+++ development/Avida.xcodeproj/project.pbxproj	2007-06-27 19:43:41 UTC (rev 1721)
@@ -165,6 +165,7 @@
 		7039884E09F00D030052ACE7 /* avida.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 707AF2D509EE8501001AEA89 /* avida.cfg */; };
 		7039884F09F00D060052ACE7 /* environment.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 707AF2D709EE8501001AEA89 /* environment.cfg */; };
 		7039885009F00D080052ACE7 /* events.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 707AF2D809EE8501001AEA89 /* events.cfg */; };
+		704368D60C31991500A05ABA /* ASTree.cc in Sources */ = {isa = PBXBuildFile; fileRef = 704368CC0C3198F200A05ABA /* ASTree.cc */; };
 		7049F3560A66A8F500640512 /* instset-classic.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F3520A66A8F500640512 /* instset-classic.cfg */; };
 		7049F3570A66A8F500640512 /* instset-sex-classic.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F3530A66A8F500640512 /* instset-sex-classic.cfg */; };
 		7049F3580A66A8F500640512 /* instset-smt.cfg in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F3540A66A8F500640512 /* instset-smt.cfg */; };
@@ -388,6 +389,9 @@
 		70422A23091B141000A5E67F /* cAnalyzeFunction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeFunction.h; sourceTree = "<group>"; };
 		70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeGenotype.cc; sourceTree = "<group>"; };
 		70422A25091B141000A5E67F /* cAnalyzeGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeGenotype.h; sourceTree = "<group>"; };
+		704368CC0C3198F200A05ABA /* ASTree.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ASTree.cc; sourceTree = "<group>"; };
+		704368CD0C3198F200A05ABA /* ASTree.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ASTree.h; sourceTree = "<group>"; };
+		704368F50C32E6AB00A05ABA /* cFlexVar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cFlexVar.h; sourceTree = "<group>"; };
 		7049F2D70A66859300640512 /* cHardwareTransSMT.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareTransSMT.cc; sourceTree = "<group>"; };
 		7049F2D80A66859300640512 /* cHardwareTransSMT.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHardwareTransSMT.h; sourceTree = "<group>"; };
 		7049F3520A66A8F500640512 /* instset-classic.cfg */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = "instset-classic.cfg"; sourceTree = "<group>"; };
@@ -1119,6 +1123,8 @@
 		70DCAD1E097AF81A002F8733 /* script */ = {
 			isa = PBXGroup;
 			children = (
+				704368CC0C3198F200A05ABA /* ASTree.cc */,
+				704368CD0C3198F200A05ABA /* ASTree.h */,
 				70DCAD1F097AF81A002F8733 /* AvidaScript.h */,
 				70731662097C6DF500815164 /* cASLibrary.h */,
 				70731663097C6DF500815164 /* cASLibrary.cc */,
@@ -1372,6 +1378,7 @@
 		DCC314D8076253A2008F7A48 /* tools */ = {
 			isa = PBXGroup;
 			children = (
+				704368F50C32E6AB00A05ABA /* cFlexVar.h */,
 				703CA3760A5073CD00AB4DB4 /* SConscript */,
 				7057886F0A21FE8D00E85D8E /* cFixedBlock.cc */,
 				705788700A21FE8D00E85D8E /* cFixedCoords.cc */,
@@ -1872,6 +1879,7 @@
 				7023ECDB0C0A44CA00362B9C /* cParser.cc in Sources */,
 				7023ECDC0C0A44CC00362B9C /* cScriptObject.cc in Sources */,
 				7023ECDD0C0A44CE00362B9C /* cSymbolTable.cc in Sources */,
+				704368D60C31991500A05ABA /* ASTree.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: development/source/script/ASTree.cc
===================================================================
--- development/source/script/ASTree.cc	                        (rev 0)
+++ development/source/script/ASTree.cc	2007-06-27 19:43:41 UTC (rev 1721)
@@ -0,0 +1,26 @@
+/*
+ *  ASTree.cpp
+ *  Avida
+ *
+ *  Created by David on 4/7/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.
+ *
+ */
+
+#include "ASTree.h"
+

Added: development/source/script/ASTree.h
===================================================================
--- development/source/script/ASTree.h	                        (rev 0)
+++ development/source/script/ASTree.h	2007-06-27 19:43:41 UTC (rev 1721)
@@ -0,0 +1,60 @@
+/*
+ *  ASTree.h
+ *  Avida
+ *
+ *  Created by David on 4/7/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 ASTree_h
+#define ASTree_h
+
+enum eASTNodeType
+{
+  N_STMT_LIST,
+  N_EXPR,
+  N_VAR_DECL,
+  N_IF_BLOCK,
+  N_WHILE_BLOCK,
+  N_FOREACH_BLOCK,
+  N_FUNC,
+  N_RETURN,
+  N_BLOCK,
+  
+  N_ERROR
+};
+
+class cASTVisitor;
+
+class cASTNode
+{
+public:
+  eASTNodeType type;
+  
+  cASTNode() { ; }
+  virtual ~cASTNode() { ; }
+  
+  virtual void Accept(cASTVisitor& visitor) = 0;
+};
+
+
+
+
+
+#endif

Modified: development/source/script/AvidaScript.h
===================================================================
--- development/source/script/AvidaScript.h	2007-06-26 21:54:06 UTC (rev 1720)
+++ development/source/script/AvidaScript.h	2007-06-27 19:43:41 UTC (rev 1721)
@@ -66,10 +66,12 @@
   ARR_RANGE,
   ARR_EXPAN,
   
-  TYPE_BOOL,
+  TYPE_ARRAY,
   TYPE_CHAR,
   TYPE_FLOAT,
   TYPE_INT,
+  TYPE_MATRIX,
+  TYPE_STRING,
   TYPE_VOID,
   
   CMD_IF,
@@ -85,6 +87,8 @@
   CMD_FUNCTION,
   CMD_ENDFUNCTION,
   
+  CMD_RETURN,
+  
   ID,
   
   FLOAT,

Modified: development/source/script/cLexer.l
===================================================================
--- development/source/script/cLexer.l	2007-06-26 21:54:06 UTC (rev 1720)
+++ development/source/script/cLexer.l	2007-06-27 19:43:41 UTC (rev 1721)
@@ -81,10 +81,12 @@
 :           return ARR_RANGE;
 \^          return ARR_EXPAN;
 
-bool        return TYPE_BOOL;     // Built-in Types
+array       return TYPE_ARRAY;    // Built-in Types
 char        return TYPE_CHAR;
 float       return TYPE_FLOAT;
 int         return TYPE_INT;
+matrix      return TYPE_MATRIX;
+string      return TYPE_STRING;
 void        return TYPE_VOID;
 
 if          return CMD_IF;        // If Blocks
@@ -100,6 +102,8 @@
 function    return CMD_FUNCTION;  // Function Blocks
 endfunction return CMD_ENDFUNCTION;
 
+return      return CMD_RETURN;
+
 ([a-zA-Z]|_+[a-zA-Z])[a-zA-Z0-9_]*  return ID;      // Identifiers
   
 [0-9]*\.[0-9]+([eE][-+]?[0-9]+)?    return FLOAT;   // Literal Values

Modified: development/source/script/cParser.cc
===================================================================
--- development/source/script/cParser.cc	2007-06-26 21:54:06 UTC (rev 1720)
+++ development/source/script/cParser.cc	2007-06-27 19:43:41 UTC (rev 1721)
@@ -37,23 +37,38 @@
  statement_list: statement statement_list
                |
  
- statement: expr ENDL
-          | var_declare ENDL
-          | if_block
-          | while_block
-          | foreach_block
-          | declare_function
-          | define_function
-          | ENDL
+ statement: assign_expr lineterm
+          | expr lineterm
+          | var_declare lineterm
+          | loose_block
+          | if_block lineterm
+          | while_block lineterm
+          | foreach_block lineterm
+          | declare_function lineterm
+          | define_function lineterm
+          | return_stmt lineterm
+          | lineterm
   
- type_any: TYPE_BOOL | TYPE_CHAR | TYPE_FLOAT | TYPE_INT | TYPE_VOID
+ lineterm: SUPRESS | ENDL
  
- expr: p0_expr expr_1
+ type_any: TYPE_ARRAY | TYPE_CHAR | TYPE_FLOAT | TYPE_INT | TYPE_MATRIX | TYPE_STRING | TYPE_VOID
+ 
+ assign_expr: assign_dest ASSIGN expr
+            | assign_dest ASSIGN array_inline
+ 
+ array_inline: ARR_OPEN argument_list ARR_CLOSE
+ 
+ assign_dest: ID
+            | REF ARR_OPEN id_list ARR_CLOSE
 
- expr_1: ASSIGN p0_expr expr_1
-      |
+ id_list: ID id_list_1
  
+ id_list_1: COMMA ID id_list_1
+          |
  
+ 
+ expr: p0_expr 
+ 
  p0_expr: p1_expr p0_expr_1
  
  p0_expr_1: OP_LOGIC_AND p1_expr p0_expr_1
@@ -121,16 +136,22 @@
  argument_list_2: COMMA expr argument_list_2
                 |
 
- if_block: CMD_IF PREC_OPEN expr PREC_CLOSE ENDL statement_list CMD_ENDIF ENDL
-         | CMD_IF PREC_OPEN expr PREC_CLOSE ENDL statement_list CMD_ELSE statement_list CMD_ENDIF ENDL
+ loose_block: ARR_OPEN statement_list ARR_CLOSE
  
- while_block: CMD_WHILE PREC_OPEN expr PREC_CLOSE ENDL statement_list CMD_ENDWHILE ENDL
+ if_block: CMD_IF PREC_OPEN expr PREC_CLOSE lineterm statement_list CMD_ENDIF
+         | CMD_IF PREC_OPEN expr PREC_CLOSE lineterm statement_list CMD_ELSE lineterm statement_list CMD_ENDIF
  
- foreach_block: CMD_FOREACH REF ID PREC_OPEN expr PREC_CLOSE ENDL statement_list CMD_ENDFOREACH ENDL
-              | CMD_FOREACH type_any ID PREC_OPEN expr PREC_CLOSE ENDL statement_list CMD_ENDFOREACH ENDL
+ while_block: CMD_WHILE PREC_OPEN expr PREC_CLOSE lineterm statement_list CMD_ENDWHILE
+            | CMD_WHILE PREC_OPEN expr PREC_CLOSE loose_block
+ 
+ foreach_block: CMD_FOREACH REF ID PREC_OPEN expr PREC_CLOSE lineterm statement_list CMD_ENDFOREACH
+              | CMD_FOREACH type_any ID PREC_OPEN expr PREC_CLOSE lineterm statement_list CMD_ENDFOREACH
+              | CMD_FOREACH REF ID PREC_OPEN expr PREC_CLOSE loose_block
+              | CMD_FOREACH type_any ID PREC_OPEN expr PREC_CLOSE loose_block
 
  var_declare: type_any ID
             | type_any ID ASSIGN expr
+            | type_any ID ASSIGN array_inline
  
  var_declare_list: var_declare_list_1
                  |
@@ -140,15 +161,12 @@
  var_declare_list_2: COMMA var_declare var_declare_list_2
                    | 
  
- declare_function: REF CMD_FUNCTION type_any ID PREC_OPEN var_declare_list PREC_CLOSE ENDL
- define_function: CMD_FUNCTION type_any ID PREC_OPEN var_declare_list PREC_CLOSE ENDL statement_list CMD_ENDFUNCTION
+ declare_function: REF CMD_FUNCTION type_any ID PREC_OPEN var_declare_list PREC_CLOSE
+ define_function: CMD_FUNCTION type_any ID PREC_OPEN var_declare_list PREC_CLOSE lineterm statement_list CMD_ENDFUNCTION
+                | CMD_FUNCTION type_any ID PREC_OPEN var_declare_list PREC_CLOSE loose_block
  
+ return_stmt: CMD_RETURN expr
  
- @TODO - return
- @TODO - array definitions
- @TODO - suppress
- @TODO - ARR_OPEN ARR_CLOSE as block open/close.  
- @TODO - function variant with block rather than endfunction.
  */
 
 bool cParser::Parse(cFile& input)




More information about the Avida-cvs mailing list