Index: trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp	(revision 508)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp	(revision 511)
@@ -67,2 +67,456 @@
 	return FullNameToSymbol( fullName.c_str() );
 }
+
+void LexicalAnalyzer::CollectClassesForNameOnly( const char *source, Classes &classes )
+{
+	int i, i2;
+	char temporary[VN_SIZE];
+
+	// 名前空間管理
+	NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
+	namespaceScopes.clear();
+
+	// Importsされた名前空間の管理
+	NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();
+	importedNamespaces.clear();
+
+	for(i=0;;i++){
+		if(source[i]=='\0') break;
+
+		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;
+		}
+
+		if(source[i]==1&&(
+			source[i+1]==ESC_CLASS||
+			source[i+1]==ESC_TYPE||
+			source[i+1]==ESC_INTERFACE
+			))
+		{
+			int nowLine = i;
+			i += 2;
+
+			Type blittableType;
+			if(memicmp(source+i,"Align(",6)==0){
+				//アラインメント修飾子
+				i+=6;
+				i=JumpStringInPare(source,i)+1;
+			}
+			else if( memicmp( source + i, "Blittable(", 10 ) == 0 ){
+				// Blittable修飾子
+				i+=10;
+				i+=GetStringInPare_RemovePare(temporary,source+i)+1;
+				compiler.StringToType( temporary, blittableType );
+			}
+
+			bool isEnum = false;
+			bool isDelegate = false;
+			if( source[i] == 1 && source[i+1] == ESC_ENUM ){
+				// 列挙型の場合
+				isEnum = true;
+
+				i += 2;
+			}
+			else if( source[i] == 1 && source[i+1] == ESC_DELEGATE )
+			{
+				// デリゲートの場合
+				isDelegate = true;
+
+				i += 2;
+			}
+
+			for(i2=0;;i++,i2++){
+				if(!IsVariableChar(source[i])){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+			}
+
+			//クラスを追加
+			CClass *pClass = classes.Add(namespaceScopes, importedNamespaces, temporary,nowLine);
+			if( pClass ){
+				if( source[nowLine+1] == ESC_CLASS ){
+					if( isEnum )
+					{
+						pClass->SetClassType( CClass::Enum );
+					}
+					else if( isDelegate )
+					{
+						pClass->SetClassType( CClass::Delegate );
+					}
+					else{
+						pClass->SetClassType( CClass::Class );
+					}
+				}
+				else if( source[nowLine+1] == ESC_INTERFACE ){
+					pClass->SetClassType( CClass::Interface );
+				}
+				else{
+					pClass->SetClassType( CClass::Structure );
+				}
+			}
+
+			// Blittable型の場合
+			if( !blittableType.IsNull() ){
+				pClass->SetBlittableType( blittableType );
+
+				// Blittable型として登録
+				compiler.GetObjectModule().meta.GetBlittableTypes().push_back( BlittableType( blittableType, pClass ) );
+			}
+		}
+	}
+}
+
+UserProc* LexicalAnalyzer::ParseUserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, char *buffer,int nowLine,bool isVirtual,CClass *pobj_c, bool isStatic, char *interfaceName )
+{
+	int i2,i3;
+	char temporary[8192];
+
+	int i=1;
+
+	Procedure::Kind kind = Procedure::Sub;
+	bool isMacro = false;
+	if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function;
+	if(buffer[i]==ESC_MACRO){
+		isMacro = true;
+	}
+
+	i++;
+
+	bool isCdecl = false;
+	bool isExport = false;
+	while(1){
+		if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){
+			isCdecl = true;
+
+			i+=2;
+		}
+		else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){
+			isExport = true;
+
+			i+=2;
+		}
+		else break;
+	}
+
+	i2=0;
+	if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){
+		if(!pobj_c){
+			compiler.errorMessenger.Output(126,NULL,nowLine);
+			return 0;
+		}
+
+		//オペレータの場合
+		temporary[i2++]=buffer[i++];
+		temporary[i2++]=buffer[i++];
+
+		int iCalcId;
+		if(buffer[i]=='='&&buffer[i+1]=='='){
+			iCalcId=CALC_EQUAL;
+			i3=2;
+		}
+		else if(buffer[i]=='='){
+			iCalcId=CALC_SUBSITUATION;
+			i3=1;
+		}
+		else if(buffer[i]=='('){
+			iCalcId=CALC_AS;
+			i3=0;
+		}
+		else if(buffer[i]=='['&&buffer[i+1]==']'&&buffer[i+2]=='='){
+			iCalcId=CALC_ARRAY_SET;
+			i3=3;
+		}
+		else if(buffer[i]=='['&&buffer[i+1]==']'){
+			iCalcId=CALC_ARRAY_GET;
+			i3=2;
+		}
+		else{
+			iCalcId=GetCalcId(buffer+i,&i3);
+			i3++;
+		}
+		if(!iCalcId){
+			compiler.errorMessenger.Output(1,NULL,nowLine);
+			return 0;
+		}
+		temporary[i2++]=iCalcId;
+		temporary[i2]=0;
+
+		i+=i3;
+	}
+	else{
+		if(pobj_c){
+			//クラスメンバの場合、デストラクタには~が付くことを考慮
+			if(buffer[i]=='~'){
+				temporary[i2]='~';
+				i++;
+				i2++;
+			}
+		}
+
+		for(;;i++,i2++){
+			if(!IsVariableChar(buffer[i])){
+				temporary[i2]=0;
+				break;
+			}
+			temporary[i2]=buffer[i];
+		}
+
+		char parentName[VN_SIZE], memberName[VN_SIZE];
+		ReferenceKind refKind;
+		if( SplitMemberName( temporary, parentName, memberName, refKind ) )
+		{
+			if( pobj_c )
+			{
+				if( interfaceName )
+				{
+					lstrcpy( interfaceName, parentName );
+				}
+				else
+				{
+					compiler.errorMessenger.OutputFatalError();
+					return NULL;
+				}
+
+				char dummyMemberName[VN_SIZE];
+				if( SplitMemberName( memberName, parentName, dummyMemberName, refKind ) )
+				{
+					compiler.errorMessenger.Output(69,temporary,nowLine);
+					return NULL;
+				}
+			}
+			else
+			{
+				compiler.errorMessenger.Output(68,temporary,nowLine);
+				return NULL;
+			}
+
+			lstrcpy( temporary, memberName );
+		}
+	}
+
+	if( isMacro ){
+		//大文字に変換
+		CharUpper(temporary);
+	}
+
+	if(!pobj_c){
+		//クラスメンバ以外の場合のみ
+		//重複チェック
+
+		if(GetDeclareHash(temporary)){
+			compiler.errorMessenger.Output(15,temporary,nowLine);
+			return 0;
+		}
+	}
+
+	UserProc *pUserProc = new UserProc( namespaceScopes, importedNamespaces, temporary, kind, isMacro, isCdecl, isExport );
+	pUserProc->SetParentClass( pobj_c );
+
+	// 親インターフェイスをセット
+	if( interfaceName && interfaceName[0] )
+	{
+		::Interface *pTargetInterface = NULL;
+		BOOST_FOREACH( ::Interface *pInterface, pobj_c->GetInterfaces() )
+		{
+			if( pInterface->GetClass().GetName() == interfaceName )
+			{
+				pTargetInterface = pInterface;
+				break;
+			}
+		}
+		pUserProc->SetInterface( pTargetInterface );
+	}
+
+	if(isExport){
+		pUserProc->Using();
+	}
+
+	// パラメータを解析
+	// ※第1パラメータにに指定するデータの例："( s As String ) As String"
+	pUserProc->SetParamsAndReturnType( buffer + i, nowLine, isStatic );
+
+	pUserProc->_paramStr = buffer + i;
+
+	return pUserProc;
+}
+
+void LexicalAnalyzer::CollectProcedures( const BasicSource &source, UserProcs &userProcs, DllProcs &dllProcs )
+{
+	extern HANDLE hHeap;
+	int i,i2,i3;
+	char temporary[8192];
+
+	// 名前空間管理
+	NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes();
+	namespaceScopes.clear();
+
+	// Importsされた名前空間の管理
+	NamespaceScopesCollection &importedNamespaces = compiler.GetNamespaceSupporter().GetImportedNamespaces();
+	importedNamespaces.clear();
+
+	i=-1;
+	while(1){
+		i++;
+
+		if(source[i]==1&&(source[i+1]==ESC_CLASS||source[i+1]==ESC_INTERFACE)){
+			/*	Class ～ End Class
+				Interface ～ End Interface
+				を飛び越す			*/
+			i3=GetEndXXXCommand(source[i+1]);
+			for(i+=2,i2=0;;i++,i2++){
+				if(source[i]=='\0') break;
+				if(source[i]==1&&source[i+1]==(char)i3){
+					i++;
+					break;
+				}
+			}
+			if(source[i]=='\0') break;
+			continue;
+		}
+
+		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,cp );
+			}
+
+			continue;
+		}
+		else if( source[i] == 1 && source[i+1] == ESC_CLEARNAMESPACEIMPORTED ){
+			importedNamespaces.clear();
+			continue;
+		}
+
+		if(source[i]==1&&source[i+1]==ESC_DECLARE){
+			for(i+=2,i2=0;;i2++,i++){
+				if(source[i]=='\n'){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+				if(source[i]=='\0') break;
+			}
+			dllProcs.Add(namespaceScopes,temporary,i);
+
+			continue;
+		}
+		if(source[i]==1&&(source[i+1]==ESC_SUB||source[i+1]==ESC_FUNCTION||source[i+1]==ESC_MACRO)){
+			char statementChar = source[i+1];
+
+			for(i2=0;;i2++,i++){
+				if(IsCommandDelimitation(source[i])){
+					temporary[i2]=0;
+					break;
+				}
+				temporary[i2]=source[i];
+				if(source[i]=='\0') break;
+			}
+
+			UserProc *pUserProc = ParseUserProc( namespaceScopes, importedNamespaces, temporary, i, false, NULL, false );
+			userProcs.Insert( pUserProc, i );
+
+			/*	Sub ～ End Sub
+				Function ～ End Function
+				Macro ～ End Macro
+				を飛び越す			*/
+			char endStatementChar = GetEndXXXCommand( statementChar );
+			for(i2=0;;i++,i2++){
+				if( source[i] == '\0' ) break;
+				if( source[i] == 1 && source[i+1] == endStatementChar ){
+					i++;
+					break;
+				}
+			}
+			if(source[i]=='\0') break;
+			continue;
+		}
+
+		//次の行
+		for(;;i++){
+			if(IsCommandDelimitation(source[i])) break;
+		}
+		if(source[i]=='\0') break;
+	}
+
+	////////////
+	// 特殊関数
+	////////////
+	namespaceScopes.clear();
+	importedNamespaces.clear();
+
+	compiler.globalAreaProcName = "_System_GlobalArea_" + compiler.GetModuleName();
+	sprintf(temporary,"%c%c%s()",1,ESC_SUB,compiler.globalAreaProcName.c_str());
+	UserProc *pUserProc = ParseUserProc( namespaceScopes, importedNamespaces, temporary, 0, false, NULL, false );
+	userProcs.Insert( pUserProc, i );
+}
