1 | #include "stdafx.h"
|
---|
2 |
|
---|
3 | using namespace ActiveBasic::Compiler;
|
---|
4 |
|
---|
5 | using boost::numeric_cast;
|
---|
6 |
|
---|
7 | bool LexicalAnalyzer::CollectNamespaces(char const* source, NamespaceScopesCollection &namespaceScopesCollection)
|
---|
8 | {
|
---|
9 | bool isSuccessful = true;
|
---|
10 |
|
---|
11 | // 名前空間管理
|
---|
12 | NamespaceScopes namespaceScopes;
|
---|
13 |
|
---|
14 | for (int i = 0; ; i++)
|
---|
15 | {
|
---|
16 | if(source[i]=='\0') break;
|
---|
17 |
|
---|
18 | if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){
|
---|
19 | i+=2;
|
---|
20 | char const* p = &source[i];
|
---|
21 | while (!IsCommandDelimitation(source[i]))
|
---|
22 | {
|
---|
23 | ++i;
|
---|
24 | }
|
---|
25 | namespaceScopes.push_back(std::string(p, &source[i]));
|
---|
26 |
|
---|
27 | if( !namespaceScopesCollection.IsExist( namespaceScopes ) ){
|
---|
28 | namespaceScopesCollection.push_back( namespaceScopes );
|
---|
29 | }
|
---|
30 |
|
---|
31 | continue;
|
---|
32 | }
|
---|
33 | else if( source[i] == 1 && source[i+1] == ESC_ENDNAMESPACE ){
|
---|
34 | if( namespaceScopes.size() <= 0 ){
|
---|
35 | compiler.errorMessenger.Output( 12, "End Namespace", i );
|
---|
36 | isSuccessful = false;
|
---|
37 | }
|
---|
38 | else{
|
---|
39 | namespaceScopes.pop_back();
|
---|
40 | }
|
---|
41 |
|
---|
42 | i += 2;
|
---|
43 | continue;
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | if( !namespaceScopes.empty() ){
|
---|
48 | compiler.errorMessenger.Output( 63, NULL, cp );
|
---|
49 | isSuccessful = false;
|
---|
50 | }
|
---|
51 |
|
---|
52 | return isSuccessful;
|
---|
53 | }
|
---|
54 |
|
---|
55 | Symbol LexicalAnalyzer::FullNameToSymbol( const char *fullName )
|
---|
56 | {
|
---|
57 | char areaName[VN_SIZE] = ""; //オブジェクト変数
|
---|
58 | char nestName[VN_SIZE] = ""; //入れ子メンバ
|
---|
59 | bool isNest = SplitMemberName( fullName, areaName, nestName );
|
---|
60 |
|
---|
61 | return Symbol( NamespaceScopes( areaName ), nestName );
|
---|
62 | }
|
---|
63 |
|
---|
64 | Symbol LexicalAnalyzer::FullNameToSymbol( const std::string &fullName )
|
---|
65 | {
|
---|
66 | return FullNameToSymbol( fullName.c_str() );
|
---|
67 | }
|
---|