[Avida-SVN] r2372 - in development: Avida.xcodeproj source/script source/targets/avida-s source/tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sun Feb 24 19:22:08 PST 2008


Author: brysonda
Date: 2008-02-24 22:22:08 -0500 (Sun, 24 Feb 2008)
New Revision: 2372

Added:
   development/source/script/cSemanticASTVisitor.cc
   development/source/script/cSemanticASTVisitor.h
Removed:
   development/source/script/FlexLexer.h
   development/source/script/cASSymbol.cc
   development/source/script/cASSymbol.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/script/ASTree.h
   development/source/script/cASLibrary.h
   development/source/script/cASTDumpVisitor.h
   development/source/script/cASTVisitor.h
   development/source/script/cLexer.h
   development/source/script/cParser.cc
   development/source/script/cParser.h
   development/source/script/cScriptObject.h
   development/source/script/cSymbolTable.h
   development/source/targets/avida-s/main.cc
   development/source/tools/cFile.cc
   development/source/tools/tSmartArray.h
Log:
Lay some groundwork for AS semantic analysis pass.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/Avida.xcodeproj/project.pbxproj	2008-02-25 03:22:08 UTC (rev 2372)
@@ -161,7 +161,6 @@
 		7023ECD40C0A447800362B9C /* libtcmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 70AA941909D486AE006A24C8 /* libtcmalloc.a */; };
 		7023ECD70C0A44BF00362B9C /* main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70DCAC57097AF730002F8733 /* main.cc */; };
 		7023ECD80C0A44C400362B9C /* cASLibrary.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70731663097C6DF500815164 /* cASLibrary.cc */; };
-		7023ECD90C0A44C600362B9C /* cASSymbol.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70731669097C6E0C00815164 /* cASSymbol.cc */; };
 		7023ECDA0C0A44C900362B9C /* cLexer.l in Sources */ = {isa = PBXBuildFile; fileRef = 70DCAD21097AF81A002F8733 /* cLexer.l */; };
 		7023ECDB0C0A44CA00362B9C /* cParser.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7073165B097C6C8F00815164 /* cParser.cc */; };
 		7023ECDC0C0A44CC00362B9C /* cScriptObject.cc in Sources */ = {isa = PBXBuildFile; fileRef = 702F52DF0992FD8000B2B507 /* cScriptObject.cc */; };
@@ -186,6 +185,7 @@
 		7049F3730A66AD7E00640512 /* default-transsmt.org in CopyFiles */ = {isa = PBXBuildFile; fileRef = 7049F36F0A66AD7E00640512 /* default-transsmt.org */; };
 		704C21DC0C28C3980038F1A5 /* libtcmalloc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 70AA941909D486AE006A24C8 /* libtcmalloc.a */; };
 		70658C5A085DF67D00486BED /* libncurses.5.4.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 70658C59085DF67D00486BED /* libncurses.5.4.dylib */; };
+		7073972E0D725B9F003855D3 /* cSemanticASTVisitor.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7073972C0D725B9D003855D3 /* cSemanticASTVisitor.cc */; };
 		7076FEB00D347FD000556CAF /* cAnalyzeTreeStats_CumulativeStemminess.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7076FEAE0D347FD000556CAF /* cAnalyzeTreeStats_CumulativeStemminess.cc */; };
 		7076FEB10D347FD000556CAF /* cAnalyzeTreeStats_Gamma.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7076FEAF0D347FD000556CAF /* cAnalyzeTreeStats_Gamma.cc */; };
 		70A778390D69D5CA00735F1E /* cDemeProbSchedule.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70A778370D69D5C200735F1E /* cDemeProbSchedule.cc */; };
@@ -487,8 +487,8 @@
 		7073165B097C6C8F00815164 /* cParser.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cParser.cc; sourceTree = "<group>"; };
 		70731662097C6DF500815164 /* cASLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cASLibrary.h; sourceTree = "<group>"; };
 		70731663097C6DF500815164 /* cASLibrary.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cASLibrary.cc; sourceTree = "<group>"; };
-		70731668097C6E0C00815164 /* cASSymbol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cASSymbol.h; sourceTree = "<group>"; };
-		70731669097C6E0C00815164 /* cASSymbol.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cASSymbol.cc; sourceTree = "<group>"; };
+		7073972C0D725B9D003855D3 /* cSemanticASTVisitor.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cSemanticASTVisitor.cc; sourceTree = "<group>"; };
+		7073972D0D725B9D003855D3 /* cSemanticASTVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cSemanticASTVisitor.h; sourceTree = "<group>"; };
 		707415C70AA7E4100064A546 /* main.css */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = main.css; sourceTree = "<group>"; };
 		7076FEAE0D347FD000556CAF /* cAnalyzeTreeStats_CumulativeStemminess.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeTreeStats_CumulativeStemminess.cc; sourceTree = "<group>"; };
 		7076FEAF0D347FD000556CAF /* cAnalyzeTreeStats_Gamma.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeTreeStats_Gamma.cc; sourceTree = "<group>"; };
@@ -799,7 +799,6 @@
 		70DCAD1F097AF81A002F8733 /* AvidaScript.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AvidaScript.h; sourceTree = "<group>"; };
 		70DCAD20097AF81A002F8733 /* cLexer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cLexer.h; sourceTree = "<group>"; };
 		70DCAD21097AF81A002F8733 /* cLexer.l */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.lex; path = cLexer.l; sourceTree = "<group>"; };
-		70DCAD22097AF81A002F8733 /* FlexLexer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FlexLexer.h; sourceTree = "<group>"; };
 		70DCF50109CFB0B400924128 /* system-alloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "system-alloc.h"; sourceTree = "<group>"; };
 		70DCF50209CFB0B400924128 /* system-alloc.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "system-alloc.cc"; sourceTree = "<group>"; };
 		70DCF52809CFB93200924128 /* spinlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spinlock.h; sourceTree = "<group>"; };
@@ -1206,18 +1205,17 @@
 		70DCAD1E097AF81A002F8733 /* script */ = {
 			isa = PBXGroup;
 			children = (
+				7073972C0D725B9D003855D3 /* cSemanticASTVisitor.cc */,
+				7073972D0D725B9D003855D3 /* cSemanticASTVisitor.h */,
 				704368CC0C3198F200A05ABA /* ASTree.cc */,
 				704368CD0C3198F200A05ABA /* ASTree.h */,
 				70DCAD1F097AF81A002F8733 /* AvidaScript.h */,
 				70731662097C6DF500815164 /* cASLibrary.h */,
 				70731663097C6DF500815164 /* cASLibrary.cc */,
-				70731668097C6E0C00815164 /* cASSymbol.h */,
-				70731669097C6E0C00815164 /* cASSymbol.cc */,
 				70DCAD20097AF81A002F8733 /* cLexer.h */,
 				70DCAD21097AF81A002F8733 /* cLexer.l */,
 				7073165A097C6C8F00815164 /* cParser.h */,
 				7073165B097C6C8F00815164 /* cParser.cc */,
-				70DCAD22097AF81A002F8733 /* FlexLexer.h */,
 				702F52A70992F8F600B2B507 /* cSymbolTable.h */,
 				702F52A80992F8F600B2B507 /* cSymbolTable.cc */,
 				702F52DE0992FD8000B2B507 /* cScriptObject.h */,
@@ -2012,13 +2010,13 @@
 			files = (
 				7023ECD70C0A44BF00362B9C /* main.cc in Sources */,
 				7023ECD80C0A44C400362B9C /* cASLibrary.cc in Sources */,
-				7023ECD90C0A44C600362B9C /* cASSymbol.cc in Sources */,
 				7023ECDA0C0A44C900362B9C /* cLexer.l in Sources */,
 				7023ECDB0C0A44CA00362B9C /* cParser.cc in Sources */,
 				7023ECDC0C0A44CC00362B9C /* cScriptObject.cc in Sources */,
 				7023ECDD0C0A44CE00362B9C /* cSymbolTable.cc in Sources */,
 				704368D60C31991500A05ABA /* ASTree.cc in Sources */,
 				70F9FC100C469DD70083B788 /* cASTDumpVisitor.cc in Sources */,
+				7073972E0D725B9F003855D3 /* cSemanticASTVisitor.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: development/source/script/ASTree.h
===================================================================
--- development/source/script/ASTree.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/ASTree.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -25,21 +25,14 @@
 #ifndef ASTree_h
 #define ASTree_h
 
-#ifndef AvidaScript_h
 #include "AvidaScript.h"
-#endif
-#ifndef cString_h
+
 #include "cString.h"
-#endif
-#ifndef defs_h
+
 #include "defs.h"
-#endif
-#ifndef tList_h
+
 #include "tList.h"
-#endif
-#ifndef tManagedPointerArray_h
 #include "tManagedPointerArray.h"
-#endif
 
 
 class cASTVisitor;

Deleted: development/source/script/FlexLexer.h
===================================================================
--- development/source/script/FlexLexer.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/FlexLexer.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -1,189 +0,0 @@
-// $Header: /cvs/root/flex/flex/FlexLexer.h,v 1.2 2003/07/29 23:09:28 landonf Exp $
-
-// FlexLexer.h -- define interfaces for lexical analyzer classes generated
-//		  by flex
-
-// Copyright (c) 1993 The Regents of the University of California.
-// All rights reserved.
-//
-// This code is derived from software contributed to Berkeley by
-// Kent Williams and Tom Epperly.
-//
-// Redistribution and use in source and binary forms with or without
-// modification are permitted provided that: (1) source distributions retain
-// this entire copyright notice and comment, and (2) distributions including
-// binaries display the following acknowledgement:  ``This product includes
-// software developed by the University of California, Berkeley and its
-// contributors'' in the documentation or other materials provided with the
-// distribution and in all advertising materials mentioning features or use
-// of this software.  Neither the name of the University nor the names of
-// its contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-
-// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
-// WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
-// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
-// This file defines FlexLexer, an abstract class which specifies the
-// external interface provided to flex C++ lexer objects, and yyFlexLexer,
-// which defines a particular lexer class.
-//
-// If you want to create multiple lexer classes, you use the -P flag
-// to rename each yyFlexLexer to some other xxFlexLexer.  You then
-// include <FlexLexer.h> in your other sources once per lexer class:
-//
-//	#undef yyFlexLexer
-//	#define yyFlexLexer xxFlexLexer
-//	#include <FlexLexer.h>
-//
-//	#undef yyFlexLexer
-//	#define yyFlexLexer zzFlexLexer
-//	#include <FlexLexer.h>
-//	...
-
-#ifndef __FLEX_LEXER_H
-// Never included before - need to define base class.
-#define __FLEX_LEXER_H
-
-extern "C++" {
-
-#include <iostream>
-  
-  using namespace std;
-
-struct yy_buffer_state;
-typedef int yy_state_type;
-
-class FlexLexer {
-public:
-	virtual ~FlexLexer()	{ }
-
-	const char* YYText()	{ return yytext; }
-	int YYLeng()		{ return yyleng; }
-
-	virtual void
-		yy_switch_to_buffer( struct yy_buffer_state* new_buffer ) = 0;
-	virtual struct yy_buffer_state*
-		yy_create_buffer( istream* s, int size ) = 0;
-	virtual void yy_delete_buffer( struct yy_buffer_state* b ) = 0;
-	virtual void yyrestart( istream* s ) = 0;
-
-	virtual int yylex() = 0;
-
-	// Call yylex with new input/output sources.
-	int yylex( istream* new_in, ostream* new_out = 0 )
-		{
-		switch_streams( new_in, new_out );
-		return yylex();
-		}
-
-	// Switch to new input/output streams.  A nil stream pointer
-	// indicates "keep the current one".
-	virtual void switch_streams( istream* new_in = 0,
-					ostream* new_out = 0 ) = 0;
-
-	int lineno() const		{ return yylineno; }
-
-	int debug() const		{ return yy_flex_debug; }
-	void set_debug( int flag )	{ yy_flex_debug = flag; }
-
-protected:
-	char* yytext;
-	int yyleng;
-	int yylineno;		// only maintained if you use %option yylineno
-	int yy_flex_debug;	// only has effect with -d or "%option debug"
-};
-
-}
-#endif
-
-#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
-// Either this is the first time through (yyFlexLexerOnce not defined),
-// or this is a repeated include to define a different flavor of
-// yyFlexLexer, as discussed in the flex man page.
-#define yyFlexLexerOnce
-
-class yyFlexLexer : public FlexLexer {
-public:
-	// arg_yyin and arg_yyout default to the cin and cout, but we
-	// only make that assignment when initializing in yylex().
-	yyFlexLexer( istream* arg_yyin = 0, ostream* arg_yyout = 0 );
-
-	virtual ~yyFlexLexer();
-
-	void yy_switch_to_buffer( struct yy_buffer_state* new_buffer );
-	struct yy_buffer_state* yy_create_buffer( istream* s, int size );
-	void yy_delete_buffer( struct yy_buffer_state* b );
-	void yyrestart( istream* s );
-
-	virtual int yylex();
-	virtual void switch_streams( istream* new_in, ostream* new_out );
-
-protected:
-	virtual int LexerInput( char* buf, int max_size );
-	virtual void LexerOutput( const char* buf, int size );
-	virtual void LexerError( const char* msg );
-
-	void yyunput( int c, char* buf_ptr );
-	int yyinput();
-
-	void yy_load_buffer_state();
-	void yy_init_buffer( struct yy_buffer_state* b, istream* s );
-	void yy_flush_buffer( struct yy_buffer_state* b );
-
-	int yy_start_stack_ptr;
-	int yy_start_stack_depth;
-	int* yy_start_stack;
-
-	void yy_push_state( int new_state );
-	void yy_pop_state();
-	int yy_top_state();
-
-	yy_state_type yy_get_previous_state();
-	yy_state_type yy_try_NUL_trans( yy_state_type current_state );
-	int yy_get_next_buffer();
-
-	istream* yyin;	// input source for default LexerInput
-	ostream* yyout;	// output sink for default LexerOutput
-
-	struct yy_buffer_state* yy_current_buffer;
-
-	// yy_hold_char holds the character lost when yytext is formed.
-	char yy_hold_char;
-
-	// Number of characters read into yy_ch_buf.
-	int yy_n_chars;
-
-	// Points to current character in buffer.
-	char* yy_c_buf_p;
-
-	int yy_init;		// whether we need to initialize
-	int yy_start;		// start state number
-
-	// Flag which is used to allow yywrap()'s to do buffer switches
-	// instead of setting up a fresh yyin.  A bit of a hack ...
-	int yy_did_buffer_switch_on_eof;
-
-	// The following are not always needed, but may be depending
-	// on use of certain flex features (like REJECT or yymore()).
-
-	yy_state_type yy_last_accepting_state;
-	char* yy_last_accepting_cpos;
-
-	yy_state_type* yy_state_buf;
-	yy_state_type* yy_state_ptr;
-
-	char* yy_full_match;
-	int* yy_full_state;
-	int yy_full_lp;
-
-	int yy_lp;
-	int yy_looking_for_trail_begin;
-
-	int yy_more_flag;
-	int yy_more_len;
-	int yy_more_offset;
-	int yy_prev_more_offset;
-};
-
-#endif

Modified: development/source/script/cASLibrary.h
===================================================================
--- development/source/script/cASLibrary.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cASLibrary.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -25,18 +25,13 @@
 #ifndef cASLibrary_h
 #define cASLibrary_h
 
-#ifndef cASSymbol_h
-#include "cASSymbol.h"
-#endif
-#ifndef tDictionary_h
 #include "tDictionary.h"
-#endif
 
 
 class cASLibrary
 {
 private:
-  tDictionary<cASSymbol> m_symtbl;
+//  tDictionary<cASSymbol> m_symtbl;
 
 public:
   cASLibrary() { ; }

Deleted: development/source/script/cASSymbol.cc
===================================================================
--- development/source/script/cASSymbol.cc	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cASSymbol.cc	2008-02-25 03:22:08 UTC (rev 2372)
@@ -1,26 +0,0 @@
-/*
- *  cASSymbol.cc
- *  Avida
- *
- *  Created by David on 1/16/06.
- *  Copyright 1999-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 "cASSymbol.h"
-

Deleted: development/source/script/cASSymbol.h
===================================================================
--- development/source/script/cASSymbol.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cASSymbol.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -1,50 +0,0 @@
-/*
- *  cASSymbol.h
- *  Avida
- *
- *  Created by David on 1/16/06.
- *  Copyright 1999-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 cASSymbol_h
-#define cASSymbol_h
-
-#ifndef AvidaScript_h
-#include "AvidaScript.h"
-#endif
-#ifndef cString_h
-#include "cString.h"
-#endif
-
-class cASSymbol
-{
-private:
-  cString m_name;
-  ASType_t m_type;
-  cString* 
-  
-  
-  cASSymbol();
-  
-public:
-  cASSymbol(cString name) : m_name(name) { ; }
-};
-
-
-#endif

Modified: development/source/script/cASTDumpVisitor.h
===================================================================
--- development/source/script/cASTDumpVisitor.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cASTDumpVisitor.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -25,9 +25,7 @@
 #ifndef cASTDumpVisitor_h
 #define cASTDumpVisitor_h
 
-#ifndef cASTVisitor_h
 #include "cASTVisitor.h"
-#endif
 
 
 class cASTDumpVisitor : public cASTVisitor

Modified: development/source/script/cASTVisitor.h
===================================================================
--- development/source/script/cASTVisitor.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cASTVisitor.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -25,9 +25,7 @@
 #ifndef cASTVisitor_h
 #define cASTVisitor_h
 
-#ifndef ASTree_h
 #include "ASTree.h"
-#endif
 
 
 class cASTVisitor

Modified: development/source/script/cLexer.h
===================================================================
--- development/source/script/cLexer.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cLexer.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -26,6 +26,6 @@
 
 #undef yyFlexLexer
 #define yyFlexLexer cLexer
-#include "FlexLexer.h"
+#include <FlexLexer.h>
 
 #endif

Modified: development/source/script/cParser.cc
===================================================================
--- development/source/script/cParser.cc	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cParser.cc	2008-02-25 03:22:08 UTC (rev 2372)
@@ -195,9 +195,8 @@
 #define TOKEN(x) AS_TOKEN_ ## x
 
 
-cParser::cParser(cASLibrary* library)
-: m_library(library)
-, m_filename("(unknown)")
+cParser::cParser()
+: m_filename("(unknown)")
 , m_eof(false)
 , m_success(true)
 , m_cur_tok(TOKEN(INVALID))

Modified: development/source/script/cParser.h
===================================================================
--- development/source/script/cParser.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cParser.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -27,24 +27,12 @@
 
 #include <iostream>
 
-#ifndef AvidaScript_h
 #include "AvidaScript.h"
-#endif
-#ifndef ASTree_h
 #include "ASTree.h"
-#endif
-#ifndef cASLibrary_h
+
 #include "cASLibrary.h"
-#endif
-#ifndef cLexer_h
 #include "cLexer.h"
-#endif
-#ifndef cScriptObject_h
 #include "cScriptObject.h"
-#endif
-#ifndef cSymbolTable_h
-#include "cSymbolTable.h"
-#endif
 
 class cFile;
 
@@ -52,8 +40,6 @@
 class cParser
 {
 private:
-  cASLibrary* m_library;
-  
   cString m_filename;
   
   cLexer* m_lexer;
@@ -69,17 +55,16 @@
   bool m_err_eof;
   
   
-  cParser(); // @not_implemented
   cParser(const cParser&); // @not_implemented
   cParser& operator=(const cParser&); // @not_implemented
   
   
 public:
-  cParser(cASLibrary* library);
+  cParser();
   ~cParser();
   
   bool Parse(cFile& input);
-  inline void Accept(cASTVisitor& visitor) { if (m_tree) m_tree->Accept(visitor); }
+  inline cASTNode* ExtractTree() { cASTNode* tree = m_tree; m_tree = NULL; return tree; }
   
   
 private:

Modified: development/source/script/cScriptObject.h
===================================================================
--- development/source/script/cScriptObject.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cScriptObject.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -27,10 +27,15 @@
 
 class cScriptObject
 {
-private:
+private:  
+  cScriptObject(const cScriptObject&); // @not_implemented
+  cScriptObject& operator=(const cScriptObject&); // @not_implemented
+    
   
 public:
-    cScriptObject() { ; }
+  cScriptObject() { ; }
+  
+  virtual void Run() = 0;
 };
 
 

Added: development/source/script/cSemanticASTVisitor.cc
===================================================================
--- development/source/script/cSemanticASTVisitor.cc	                        (rev 0)
+++ development/source/script/cSemanticASTVisitor.cc	2008-02-25 03:22:08 UTC (rev 2372)
@@ -0,0 +1,125 @@
+/*
+ *  cSemanticASTVisitor.cc
+ *  Avida
+ *
+ *  Created by David on 2/24/08.
+ *  Copyright 2008 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 "cSemanticASTVisitor.h"
+
+#include "cASLibrary.h"
+#include "cSymbolTable.h"
+
+
+cSemanticASTVisitor::cSemanticASTVisitor(cASLibrary* lib, cSymbolTable* global_symtbl)
+  : m_library(lib), m_global_symtbl(global_symtbl), m_cur_symtbl(NULL)
+{
+}
+
+void cSemanticASTVisitor::visitAssignment(cASTAssignment& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitReturnStatement(cASTReturnStatement& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitStatementList(cASTStatementList& node)
+{
+  tListIterator<cASTNode> it = node.Iterator();
+  
+  cASTNode* stmt = NULL;
+  while ((stmt = it.Next())) {
+    stmt->Accept(*this);
+  }
+}
+
+
+void cSemanticASTVisitor::visitForeachBlock(cASTForeachBlock& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitIfBlock(cASTIfBlock& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitWhileBlock(cASTWhileBlock& node)
+{
+}
+
+
+
+void cSemanticASTVisitor::visitFunctionDefinition(cASTFunctionDefinition& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitVariableDefinition(cASTVariableDefinition& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitVariableDefinitionList(cASTVariableDefinitionList& node)
+{
+}
+
+
+
+void cSemanticASTVisitor::visitExpressionBinary(cASTExpressionBinary& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitExpressionUnary(cASTExpressionUnary& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitArgumentList(cASTArgumentList& node)
+{
+}
+
+void cSemanticASTVisitor::visitFunctionCall(cASTFunctionCall& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitLiteral(cASTLiteral& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitLiteralArray(cASTLiteralArray& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitVariableReference(cASTVariableReference& node)
+{
+}
+
+
+void cSemanticASTVisitor::visitUnpackTarget(cASTUnpackTarget& node)
+{
+}

Added: development/source/script/cSemanticASTVisitor.h
===================================================================
--- development/source/script/cSemanticASTVisitor.h	                        (rev 0)
+++ development/source/script/cSemanticASTVisitor.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -0,0 +1,74 @@
+/*
+ *  cASTDumpVisitor.h
+ *  Avida
+ *
+ *  Created by David on 7/12/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 cSemanticASTVisitor_h
+#define cSemanticASTVisitor_h
+
+#include "cASTVisitor.h"
+
+#include "tSmartArray.h"
+
+class cASLibrary;
+class cSymbolTable;
+
+
+class cSemanticASTVisitor : public cASTVisitor
+{
+private:
+  cASLibrary* m_library;
+  cSymbolTable* m_global_symtbl;
+  cSymbolTable* m_cur_symtbl;
+  tSmartArray<cSymbolTable*> m_symtbl_stack;
+  
+public:
+  cSemanticASTVisitor(cASLibrary* lib, cSymbolTable* global_symtbl);
+  
+  void visitAssignment(cASTAssignment&);
+  
+  void visitReturnStatement(cASTReturnStatement&);
+  void visitStatementList(cASTStatementList&);
+  
+  void visitForeachBlock(cASTForeachBlock&);
+  void visitIfBlock(cASTIfBlock&);
+  void visitWhileBlock(cASTWhileBlock&);
+  
+  void visitFunctionDefinition(cASTFunctionDefinition&);
+  void visitVariableDefinition(cASTVariableDefinition&);
+  void visitVariableDefinitionList(cASTVariableDefinitionList&);
+  
+  void visitExpressionBinary(cASTExpressionBinary&);
+  void visitExpressionUnary(cASTExpressionUnary&);
+  
+  void visitArgumentList(cASTArgumentList&);
+  void visitFunctionCall(cASTFunctionCall&);
+  void visitLiteral(cASTLiteral&);
+  void visitLiteralArray(cASTLiteralArray&);
+  void visitVariableReference(cASTVariableReference&);
+  void visitUnpackTarget(cASTUnpackTarget&);
+
+private:
+
+};
+
+#endif

Modified: development/source/script/cSymbolTable.h
===================================================================
--- development/source/script/cSymbolTable.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/script/cSymbolTable.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -25,21 +25,52 @@
 #ifndef cSymbolTable_h
 #define cSymbolTable_h
 
-#ifndef cASSymbol_h
-#include "cASSymbol.h"
-#endif
-#ifndef tDictionary_h
+#include "AvidaScript.h"
+
+#include "tArray.h"
 #include "tDictionary.h"
-#endif
 
+// Active/inactive functions and variables within the scope of the current function (or globally)
 
+
 class cSymbolTable
 {
 private:
-  tDictionary<cASSymbol> m_symbols;
+  struct sSymbolEntry
+  {
+    cString name;
+    ASType_t type;
+
+    bool active;
+    
+    sSymbolEntry(const cString& in_name, ASType_t in_type) : name(in_name), type(in_type), active(true) { ; }
+  };
+  tArray<sSymbolEntry*> m_sym_tbl;
+  tDictionary<int> m_sym_dict;
   
+  struct sFunctionEntry
+  {
+    cString name;
+    ASType_t type;
+    
+    bool active;
+    
+    sFunctionEntry(const cString& in_name, ASType_t in_type) : name(in_name), type(in_type), active(true) { ; }    
+  };
+  tArray<sFunctionEntry*> m_fun_tbl;
+  tDictionary<int> m_fun_dict;
+  
+  
+  cSymbolTable(const cSymbolTable&); // @not_implemented
+  cSymbolTable& operator=(const cSymbolTable&); // @not_implemented
+  
+  
 public:
   cSymbolTable() { ; }
+  
+  bool AddSymbol(const cString& name);
+  
+  bool Lookup(const cString& name) const;
 };
 
 

Modified: development/source/targets/avida-s/main.cc
===================================================================
--- development/source/targets/avida-s/main.cc	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/targets/avida-s/main.cc	2008-02-25 03:22:08 UTC (rev 2372)
@@ -23,11 +23,14 @@
  */
 
 #include "avida.h"
+#include "PlatformExpert.h"
+
 #include "cASLibrary.h"
 #include "cASTDumpVisitor.h"
 #include "cFile.h"
 #include "cParser.h"
-#include "PlatformExpert.h"
+#include "cSemanticASTVisitor.h"
+#include "cSymbolTable.h"
 
 #include <iostream>
 
@@ -37,16 +40,22 @@
   PlatformExpert::Initialize();
 
   cASLibrary* lib = new cASLibrary;
-  cParser* parser = new cParser(lib);
+  cParser* parser = new cParser;
   
   cFile file;
   if (file.Open("main.asl")) {
     if (parser->Parse(file)) {
       std::cout << "Parse Successful\n" << std::endl;
+      
+      cASTNode* tree = parser->ExtractTree();
 
-      cASTDumpVisitor visitor;
-      parser->Accept(visitor);
+      cSymbolTable global_symtbl;
+      cSemanticASTVisitor semantic_check(lib, &global_symtbl);
+      tree->Accept(semantic_check);
       
+      cASTDumpVisitor dump;
+      tree->Accept(dump);
+      
       std::cout << std::endl;
       Avida::Exit(0);
     } else {

Modified: development/source/tools/cFile.cc
===================================================================
--- development/source/tools/cFile.cc	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/tools/cFile.cc	2008-02-25 03:22:08 UTC (rev 2372)
@@ -3,7 +3,7 @@
  *  Avida
  *
  *  Called "file.cc" prior to 12/7/05.
- *  Copyright 1999-1999-2007 Michigan State University. All rights reserved.
+ *  Copyright 1999-2007 Michigan State University. All rights reserved.
  *  Copyright 1993-2003 California Institute of Technology.
  *
  *

Modified: development/source/tools/tSmartArray.h
===================================================================
--- development/source/tools/tSmartArray.h	2008-02-24 02:39:36 UTC (rev 2371)
+++ development/source/tools/tSmartArray.h	2008-02-25 03:22:08 UTC (rev 2372)
@@ -151,12 +151,23 @@
     return m_data[index];
   }
   
+  
+  // Stack-like Methods...
   void Push(const T& value)
   {
     Resize(m_active + 1);
     m_data[m_active - 1] = value;
   }
   
+  T Pop()
+  {
+    T value = m_data[m_active - 1];
+    Resize(m_active - 1);
+    return value;
+  }
+  
+  
+  
   void SetAll(const T& value)
   {
     for (int i = 0; i < m_active; i++) m_data[i] = value;




More information about the Avida-cvs mailing list