source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/include/Enum.h@ 727

Last change on this file since 727 was 547, checked in by dai_9181, 17 years ago

Enum収集をLexicalAnalyzerクラスに実装しなおした。

File size: 1.4 KB
Line 
1#pragma once
2
3class EnumMember
4{
5 std::string name;
6 std::string value;
7 int sourceIndex;
8public:
9 EnumMember( const std::string &name, const std::string &value, int sourceIndex )
10 : name( name )
11 , value( value )
12 , sourceIndex( sourceIndex )
13 {
14 }
15 const std::string &GetName() const
16 {
17 return name;
18 }
19 const std::string &GetValueStr() const
20 {
21 return value;
22 }
23 int GetSourceIndex() const
24 {
25 return sourceIndex;
26 }
27};
28
29class EnumInfo
30 : public Symbol
31{
32
33 BOOL bConst;
34
35 std::vector<EnumMember> members;
36public:
37
38 EnumInfo( const NamespaceScopes &namespaceScopes, const std::string &name )
39 : Symbol( namespaceScopes, name )
40 {
41 }
42
43 const std::vector<EnumMember> &GetMembers() const
44 {
45 return members;
46 }
47
48 const EnumMember &GetEnumMember( const std::string &memberName ) const
49 {
50 BOOST_FOREACH( const EnumMember &member, members )
51 {
52 if( member.GetName() == memberName )
53 {
54 return member;
55 }
56 }
57 throw;
58 }
59
60 std::vector<EnumMember> &GetEnumMembers()
61 {
62 return members;
63 }
64};
65
66class EnumInfoCollection
67 : public std::vector<EnumInfo>
68{
69public:
70 const EnumInfo *Find( const Symbol &symbol ) const
71 {
72 const EnumInfoCollection &thisEnumInfoCollection = *this;
73 BOOST_FOREACH( const EnumInfo &enumInfo, thisEnumInfoCollection )
74 {
75 if( enumInfo.IsEqualSymbol( symbol ) )
76 {
77 return &enumInfo;
78 }
79 }
80 return NULL;
81 };
82};
Note: See TracBrowser for help on using the repository browser.