Index: /trunk/ab5.0/abdev/BasicCompiler_Common/include/Delegate.h
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/include/Delegate.h	(revision 524)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/include/Delegate.h	(revision 525)
@@ -1,5 +1,3 @@
 #pragma once
-
-class Delegates;
 
 class Delegate
@@ -7,6 +5,4 @@
 	, public Jenga::Common::ObjectInHashmap<Delegate>
 {
-	friend Delegates;
-
 	// importされている名前空間
 	NamespaceScopesCollection importedNamespaces;
@@ -43,4 +39,13 @@
 	}
 
+	const std::string &GetParamStr() const
+	{
+		return paramStr;
+	}
+	const std::string &GetReturnTypeName() const
+	{
+		return returnTypeName;
+	}
+
 	void RefleshParameterAndReturnType();
 
@@ -61,10 +66,3 @@
 	bool IsSimilar( const Delegate &dgt ) const;
 };
-
-class Delegates : public Jenga::Common::Hashmap<Delegate>
-{
-public:
-	void Collect( const BasicSource &source );
-	void GenerateSourceCode( std::string &destSource );
-	void RefleshParameterAndReturnType();
-};
+typedef Jenga::Common::Hashmap<Delegate> Delegates;
Index: /trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h	(revision 524)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h	(revision 525)
@@ -30,4 +30,9 @@
 	static UserProc* ParseUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName = NULL );
 	static void CollectProcedures( const BasicSource &source, UserProcs &userProcs, DllProcs &dllProcs );
+
+	// デリゲートを収集する
+	static void CollectDelegates( const BasicSource &source, Delegates &delegates );
+	static std::string GenerateDelegatesSourceCode( const Delegates &delegates );
+	static void RefleshDelegatesParameterAndReturnType( Delegates &delegates );
 };
 
Index: /trunk/ab5.0/abdev/BasicCompiler_Common/src/Delegate.cpp
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/src/Delegate.cpp	(revision 524)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/src/Delegate.cpp	(revision 525)
@@ -42,219 +42,2 @@
 	return false;
 }
-
-void Delegates::Collect( const BasicSource &source )
-{
-	int i2;
-	char temporary[VN_SIZE];
-
-	// 名前空間管理
-	NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
-	namespaceScopes.clear();
-
-	// Importsされた名前空間の管理
-	NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();
-	importedNamespaces.clear();
-
-	for( int i=0; i<source.GetLength(); i++ )
-	{
-		if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
-			for(i+=2,i2=0;;i2++,i++){
-				if( IsCommandDelimitation( source[i] ) ){
-					temporary[i2]=0;
-					break;
-				}
-				temporary[i2]=source[i];
-			}
-			namespaceScopes.push_back( temporary );
-
-			continue;
-		}
-		else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
-			if( namespaceScopes.size() <= 0 ){
-				compiler.errorMessenger.Output(12, "End Namespace", i );
-			}
-			else{
-				namespaceScopes.pop_back();
-			}
-
-			i += 2;
-			continue;
-		}
-		else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){
-			for(i+=2,i2=0;;i2++,i++){
-				if( IsCommandDelimitation( source[i] ) ){
-					temporary[i2]=0;
-					break;
-				}
-				temporary[i2]=source[i];
-			}
-			if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) )
-			{
-				compiler.errorMessenger.Output(64,temporary,i );
-			}
-
-			continue;
-		}
-		else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
-			importedNamespaces.clear();
-			continue;
-		}
-
-		else if( source[i] == 1 && source[i+1] == ESC_DELEGATE )
-		{
-			int nowLine = i;
-
-			i += 2;
-			if( !( source[i] == 1 && ( source[i+1] == ESC_SUB || source[i+1] == ESC_FUNCTION ) ) )
-			{
-				compiler.errorMessenger.Output(1,NULL,i);
-				continue;
-			}
-
-			Procedure::Kind procKind = Procedure::Sub;
-			if( source[i+1] == ESC_FUNCTION )
-			{
-				procKind = Procedure::Function;
-			}
-			i += 2;
-
-			// 名前
-			char name[VN_SIZE];
-			GetIdentifierToken( name, source.GetBuffer(), i );
-
-			if( source[i] != '(' )
-			{
-				compiler.errorMessenger.Output(1,NULL,nowLine);
-				continue;
-			}
-
-			// パラメータ文字列
-			char paramStr[8192];
-			i += GetStringInPare( paramStr, source.GetBuffer() + i, true );
-
-			// 戻り値の型の文字列
-			char returnTypeName[VN_SIZE] = "";
-			if( source[i] == 1 && source[i+1] == ESC_AS )
-			{
-				i += 2;
-				GetCommandToken( returnTypeName, source.GetBuffer(), i );
-
-				if( procKind != Procedure::Function )
-				{
-					compiler.errorMessenger.Output(38,name,nowLine);
-				}
-			}
-			else
-			{
-				if( procKind == Procedure::Function )
-				{
-					compiler.errorMessenger.Output(-104,name,nowLine);
-					lstrcpy( returnTypeName, "Double" );
-				}
-			}
-
-			this->Put( new Delegate( namespaceScopes, importedNamespaces, name, procKind, paramStr, returnTypeName, nowLine ) );
-		}
-	}
-}
-
-void Delegates::GenerateSourceCode( std::string &destSource )
-{
-	destSource = "";
-
-	SourceTemplate sourceTemplate( ActiveBasic::Common::Environment::GetAbdevSystemDirPath() + "\\templates\\delegate_class.tab" );
-
-	this->Iterator_Reset();
-	while( this->Iterator_HasNext() )
-	{
-		const Delegate &dg = *this->Iterator_GetNext();
-
-		if( !dg.isTargetObjectModule )
-		{
-			// 静的リンクライブラリの場合は飛ばす（既にインスタンスが定義済みであるため）
-			continue;
-		}
-
-		std::map<std::string,std::string> values;
-
-		if( dg.GetNamespaceScopes().size() )
-		{
-			std::string namespaceScopesCommandStr = "";
-			std::string endNamespaceScopesCommandStr = "";
-			BOOST_FOREACH( const std::string &namespaceStr, dg.GetNamespaceScopes() )
-			{
-				if( namespaceScopesCommandStr.size() )
-				{
-					namespaceScopesCommandStr += ":";
-					endNamespaceScopesCommandStr += ":";
-				}
-				namespaceScopesCommandStr += "Namespace " + namespaceStr;
-				endNamespaceScopesCommandStr += "End Namespace";
-			}
-
-			values.insert( std::map<std::string,std::string>::value_type(
-				"#namespace_begin#",
-				namespaceScopesCommandStr
-			) );
-			values.insert( std::map<std::string,std::string>::value_type(
-				"#namespace_end#",
-				endNamespaceScopesCommandStr
-			) );
-		}
-		else
-		{
-			values.insert( std::map<std::string,std::string>::value_type( "#namespace_begin#", "" ) );
-			values.insert( std::map<std::string,std::string>::value_type( "#namespace_end#", "" ) );
-		}
-
-		values.insert( std::map<std::string,std::string>::value_type( "#name#", dg.GetName() ) );
-
-		if( dg.IsFunction() )
-		{
-			values.insert( std::map<std::string,std::string>::value_type(
-				"#call_method_begin#",
-				(std::string)"Function Call(" + dg.paramStr + ") As " + dg.returnTypeName
-			) );
-
-			values.insert( std::map<std::string,std::string>::value_type(
-				"#call_method_end#",
-				"End Function"
-			) );
-
-			values.insert( std::map<std::string,std::string>::value_type( "#result#", "Call=" ) );
-		}
-		else
-		{
-			values.insert( std::map<std::string,std::string>::value_type(
-				"#call_method_begin#",
-				(std::string)"Sub Call(" + dg.paramStr + ")"
-			) );
-
-			values.insert( std::map<std::string,std::string>::value_type(
-				"#call_method_end#",
-				"End Sub"
-			) );
-
-			values.insert( std::map<std::string,std::string>::value_type( "#result#", "" ) );
-		}
-
-		values.insert( std::map<std::string,std::string>::value_type( "#params#", dg.paramStr ) );
-
-		destSource += sourceTemplate.GetResult( values );
-	}
-/*
-	std::ofstream ofs( ( Jenga::Common::Environment::GetAppDir() + "\\generated_delegate_code.log" ).c_str() );
-	ofs << destSource;
-	ofs.close();
-	*/
-}
-
-void Delegates::RefleshParameterAndReturnType()
-{
-	this->Iterator_Reset();
-	while( this->Iterator_HasNext() )
-	{
-		Delegate &dg = *this->Iterator_GetNext();
-		dg.RefleshParameterAndReturnType();
-	}
-}
Index: /trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp
===================================================================
--- /trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp	(revision 524)
+++ /trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp	(revision 525)
@@ -75,5 +75,4 @@
 #include <Variable.h>
 #include <Procedure.h>
-#include <LexicalAnalyzer.h>
 #include <Program.h>
 #include <TypeDef.h>
@@ -84,4 +83,5 @@
 #include <Exception.h>
 #include <Meta.h>
+
 #include <CodeGenerator.h>
 #include <Messenger.h>
@@ -91,4 +91,6 @@
 #include <Debugger.h>
 #include <Program.h>
+#include <LexicalAnalyzer.h>
+
 
 
Index: /trunk/ab5.0/abdev/compiler_x86/MakePeHdr.cpp
===================================================================
--- /trunk/ab5.0/abdev/compiler_x86/MakePeHdr.cpp	(revision 524)
+++ /trunk/ab5.0/abdev/compiler_x86/MakePeHdr.cpp	(revision 525)
@@ -156,12 +156,14 @@
 	// デリゲートに関する情報を収集
 	{
-		compiler.GetObjectModule().meta.GetDelegates().Collect(
-			compiler.GetObjectModule().GetCurrentSource()
+		ActiveBasic::Compiler::LexicalAnalyzer::CollectDelegates(
+			compiler.GetObjectModule().GetCurrentSource(),
+			compiler.GetObjectModule().meta.GetDelegates()
 		);
 		compiler.GetObjectModule().meta.GetDelegates().Iterator_Init();
 
 		// デリゲートからクラスコードを生成
-		std::string tempSource;
-		compiler.GetObjectModule().meta.GetDelegates().GenerateSourceCode( tempSource );
+		std::string tempSource = ActiveBasic::Compiler::LexicalAnalyzer::GenerateDelegatesSourceCode(
+			compiler.GetObjectModule().meta.GetDelegates()
+		);
 		AddSourceCode( tempSource.c_str() );
 	}
@@ -183,5 +185,7 @@
 	型情報に依存するパラメータ情報を取得できないため、ここでの再取得が必要
 	*/
-	compiler.GetObjectModule().meta.GetDelegates().RefleshParameterAndReturnType();
+	ActiveBasic::Compiler::LexicalAnalyzer::RefleshDelegatesParameterAndReturnType(
+		compiler.GetObjectModule().meta.GetDelegates()
+	);
 
 	//定数情報を取得
Index: /trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj
===================================================================
--- /trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj	(revision 524)
+++ /trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj	(revision 525)
@@ -1261,4 +1261,8 @@
 				</File>
 				<File
+					RelativePath="..\BasicCompiler_Common\src\LexicalAnalyzer_Delegate.cpp"
+					>
+				</File>
+				<File
 					RelativePath="..\BasicCompiler_Common\src\Linker.cpp"
 					>
@@ -1272,8 +1276,4 @@
 					>
 					<File
-						RelativePath="..\BasicCompiler_Common\src\Class.cpp"
-						>
-					</File>
-					<File
 						RelativePath="..\BasicCompiler_Common\src\Const.cpp"
 						>
@@ -1308,8 +1308,4 @@
 					</File>
 					<File
-						RelativePath="..\BasicCompiler_Common\src\Method.cpp"
-						>
-					</File>
-					<File
 						RelativePath="..\BasicCompiler_Common\src\NativeCode.cpp"
 						>
@@ -1345,8 +1341,4 @@
 					<File
 						RelativePath="..\BasicCompiler_Common\src\Source.cpp"
-						>
-					</File>
-					<File
-						RelativePath="..\BasicCompiler_Common\src\Type.cpp"
 						>
 					</File>
@@ -1477,8 +1469,4 @@
 					>
 					<File
-						RelativePath="..\BasicCompiler_Common\include\Class.h"
-						>
-					</File>
-					<File
 						RelativePath="..\BasicCompiler_Common\include\Const.h"
 						>
@@ -1509,16 +1497,8 @@
 					</File>
 					<File
-						RelativePath="..\BasicCompiler_Common\include\Member.h"
-						>
-					</File>
-					<File
 						RelativePath="..\BasicCompiler_Common\include\Meta.h"
 						>
 					</File>
 					<File
-						RelativePath="..\BasicCompiler_Common\include\Method.h"
-						>
-					</File>
-					<File
 						RelativePath="..\BasicCompiler_Common\include\NativeCode.h"
 						>
@@ -1538,8 +1518,4 @@
 					<File
 						RelativePath="..\BasicCompiler_Common\include\Source.h"
-						>
-					</File>
-					<File
-						RelativePath="..\BasicCompiler_Common\include\Type.h"
 						>
 					</File>
Index: /trunk/ab5.0/abdev/compiler_x86/stdafx.h
===================================================================
--- /trunk/ab5.0/abdev/compiler_x86/stdafx.h	(revision 524)
+++ /trunk/ab5.0/abdev/compiler_x86/stdafx.h	(revision 525)
@@ -55,5 +55,4 @@
 #include <Variable.h>
 #include <Procedure.h>
-#include <LexicalAnalyzer.h>
 #include <Program.h>
 #include <TypeDef.h>
@@ -64,4 +63,5 @@
 #include <Exception.h>
 #include <Meta.h>
+
 #include <CodeGenerator.h>
 #include <Messenger.h>
@@ -71,2 +71,3 @@
 #include <Debugger.h>
 #include <Program.h>
+#include <LexicalAnalyzer.h>
