1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #include <precomp.h>
23 #include <s2_luidl/pe_evalu.hxx>
24 
25 // NOT FULLY DECLARED SERVICES
26 #include <ary/idl/i_enumvalue.hxx>
27 #include <ary/idl/i_gate.hxx>
28 #include <ary/idl/ip_ce.hxx>
29 #include <ary/doc/d_oldidldocu.hxx>
30 #include <s2_luidl/tk_ident.hxx>
31 #include <s2_luidl/tk_punct.hxx>
32 #include <s2_luidl/tk_const.hxx>
33 
34 
35 namespace csi
36 {
37 namespace uidl
38 {
39 
40 
41 #ifdef DF
42 #undef DF
43 #endif
44 #define DF 	&PE_Value::On_Default
45 
46 PE_Value::F_TOK
47 PE_Value::aDispatcher[PE_Value::e_STATES_MAX][PE_Value::tt_MAX] =
48 		{ 	{ DF, DF, DF },  // e_none
49 			{ &PE_Value::On_expect_name_Identifier,
50 				  DF, DF },  // expect_name
51 			{ DF, &PE_Value::On_got_name_Punctuation,
52 					  &PE_Value::On_got_name_Assignment }  // got_name
53 		};
54 
55 
56 
57 inline void
CallHandler(const char * i_sTokenText,E_TokenType i_eTokenType)58 PE_Value::CallHandler( const char *		i_sTokenText,
59 					   E_TokenType		i_eTokenType )
60 	{ (this->*aDispatcher[eState][i_eTokenType])(i_sTokenText); }
61 
62 
63 
64 
65 
PE_Value(String & o_rName,String & o_rAssignment,bool i_bIsConst)66 PE_Value::PE_Value( String  & 	o_rName,
67 					String  &	o_rAssignment,
68 					bool		i_bIsConst )
69 	:	eState(e_none),
70 		pName(&o_rName),
71 		pAssignment(&o_rAssignment),
72 		bIsConst(i_bIsConst)
73 {
74 }
75 
76 void
EstablishContacts(UnoIDL_PE * io_pParentPE,ary::Repository & io_rRepository,TokenProcessing_Result & o_rResult)77 PE_Value::EstablishContacts( UnoIDL_PE *				io_pParentPE,
78 							 ary::Repository &			io_rRepository,
79 							 TokenProcessing_Result & 	o_rResult )
80 {
81 	UnoIDL_PE::EstablishContacts(io_pParentPE,io_rRepository,o_rResult);
82 }
83 
~PE_Value()84 PE_Value::~PE_Value()
85 {
86 }
87 
88 void
ProcessToken(const Token & i_rToken)89 PE_Value::ProcessToken( const Token & i_rToken )
90 {
91 	i_rToken.Trigger(*this);
92 }
93 
94 void
Process_Identifier(const TokIdentifier & i_rToken)95 PE_Value::Process_Identifier( const TokIdentifier & i_rToken )
96 {
97 	CallHandler(i_rToken.Text(), tt_identifier);
98 }
99 
100 void
Process_Punctuation(const TokPunctuation & i_rToken)101 PE_Value::Process_Punctuation( const TokPunctuation & i_rToken )
102 {
103 	CallHandler(i_rToken.Text(), tt_punctuation);
104 }
105 
106 void
Process_Assignment(const TokAssignment & i_rToken)107 PE_Value::Process_Assignment( const TokAssignment & i_rToken )
108 {
109 	CallHandler(i_rToken.Text(), tt_assignment);
110 }
111 
112 void
On_expect_name_Identifier(const char * i_sText)113 PE_Value::On_expect_name_Identifier(const char * i_sText)
114 {
115 	*pName = i_sText;
116 	SetResult(done,stay);
117 	eState = got_name;
118 }
119 
120 void
On_got_name_Punctuation(const char * i_sText)121 PE_Value::On_got_name_Punctuation(const char * i_sText)
122 {
123 	if ( (i_sText[0] == ',' AND NOT IsConst())
124 		 OR (i_sText[0] == ';' AND IsConst()) )
125 	{
126 		SetResult(done,pop_success);
127 		eState = e_none;
128 	}
129 	else if (i_sText[0] == '}' AND NOT IsConst())
130 	{
131 		SetResult(not_done,pop_success);
132 		eState = e_none;
133 	}
134 	else
135 		On_Default(i_sText);
136 }
137 
138 void
On_got_name_Assignment(const char * i_sText)139 PE_Value::On_got_name_Assignment(const char * i_sText)
140 {
141 	*pAssignment = i_sText;
142 	SetResult(done,pop_success);
143 	eState = e_none;
144 }
145 
146 void
On_Default(const char *)147 PE_Value::On_Default(const char * )
148 {
149 	SetResult(not_done,pop_failure);
150 }
151 
152 void
InitData()153 PE_Value::InitData()
154 {
155 	eState = expect_name;
156 
157 	*pName = "";
158 	*pAssignment = "";
159 }
160 
161 void
TransferData()162 PE_Value::TransferData()
163 {
164 	csv_assert(pName->length() > 0);
165 	eState = e_none;
166 }
167 
168 UnoIDL_PE &
MyPE()169 PE_Value::MyPE()
170 {
171 	return *this;
172 }
173 
174 }   // namespace uidl
175 }   // namespace csi
176 
177