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