|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "messagedefparser\aliasprocessor.h" |
|
17 #include "messagedefparser\initialstate.h" |
|
18 #include "messagedefparser\definitiontokenizer.h" |
|
19 #include "messagedefparser\signatureidentifier.h" |
|
20 #include "messagedefparser\messageidentifier.h" |
|
21 #include "messagedefparser\contextidentifier.h" |
|
22 #include "util.h" |
|
23 |
|
24 namespace Parser |
|
25 { |
|
26 #if 1 |
|
27 |
|
28 void CAliasProcessor::ProcessState() |
|
29 { |
|
30 Tokens::TTokenType tokenType = CurrentTokenType(); |
|
31 iResult = Parser::EUnexpectedToken; |
|
32 |
|
33 switch (iInternalState) |
|
34 { |
|
35 case EStateExpectAliasTargetType: |
|
36 iResult = Parser::ENoError; |
|
37 switch (tokenType) |
|
38 { |
|
39 case Tokens::EContext: |
|
40 iAliasTargetType = Parser::EContextIdentifier; |
|
41 break; |
|
42 |
|
43 case Tokens::ESignature: |
|
44 iAliasTargetType = Parser::ESignatureIdentifier; |
|
45 break; |
|
46 |
|
47 case Tokens::EMessage: |
|
48 iAliasTargetType = Parser::EMessageIdentifier; |
|
49 break; |
|
50 |
|
51 default: |
|
52 iResult = Parser::EUnexpectedToken; |
|
53 break; |
|
54 } |
|
55 iInternalState = EStateExpectAliasName; |
|
56 break; |
|
57 |
|
58 case EStateExpectAliasName: |
|
59 if (tokenType == Tokens::EIdentifier) |
|
60 { |
|
61 if (!ParserSM().FindIdentifier(CurrentToken())) |
|
62 { |
|
63 iName = _strdup(CurrentToken()); |
|
64 iInternalState = EStateExpectEquals; |
|
65 iResult = Parser::ENoError; |
|
66 } |
|
67 else |
|
68 { |
|
69 iResult = Parser::EDuplicateIdentifier; |
|
70 } |
|
71 } |
|
72 break; |
|
73 |
|
74 case EStateExpectEquals: |
|
75 if (tokenType == Tokens::EEquals) |
|
76 { |
|
77 iInternalState = EStateExpectAliasTarget; |
|
78 iResult = Parser::ENoError; |
|
79 } |
|
80 break; |
|
81 |
|
82 case EStateExpectAliasTarget: |
|
83 if (tokenType == Tokens::EIdentifier) |
|
84 { |
|
85 const CIdentifierBase* realIdentifier; |
|
86 realIdentifier = ParserSM().FindIdentifier(CurrentToken()); |
|
87 if (!realIdentifier || realIdentifier->Type() != iAliasTargetType) |
|
88 { |
|
89 iResult = Parser::EUnknownIdentifier; |
|
90 } |
|
91 else |
|
92 { |
|
93 switch (iAliasTargetType) |
|
94 { |
|
95 case Parser::EContextIdentifier: |
|
96 iIdentifier = new CContextAliasIdentifier( |
|
97 iName, static_cast<const CContextIdentifier*>(realIdentifier)); |
|
98 break; |
|
99 |
|
100 case Parser::ESignatureIdentifier: |
|
101 iIdentifier = new CSignatureAliasIdentifier( |
|
102 iName, static_cast<const CSignatureIdentifier*>(realIdentifier)); |
|
103 break; |
|
104 |
|
105 case Parser::EMessageIdentifier: |
|
106 iIdentifier = new CMessageAliasIdentifier( |
|
107 iName, static_cast<const CMessageIdentifier*>(realIdentifier)); |
|
108 break; |
|
109 } |
|
110 |
|
111 if (iIdentifier) |
|
112 { |
|
113 ParserSM().AddIdentifier(iIdentifier); |
|
114 iIdentifier = NULL; |
|
115 iResult = Parser::ENoError; |
|
116 ParserSM().SetState(new CInitialState(ParserSM())); |
|
117 } |
|
118 } |
|
119 } |
|
120 break; |
|
121 } |
|
122 |
|
123 if (iResult != Parser::ENoError) |
|
124 { |
|
125 ParserSM().SetError(iResult); |
|
126 } |
|
127 } |
|
128 |
|
129 |
|
130 CAliasProcessor::~CAliasProcessor() |
|
131 { |
|
132 delete iName; |
|
133 } |
|
134 |
|
135 #endif |
|
136 |
|
137 |
|
138 } // namespace Parser |
|
139 |