xref: /trunk/main/autodoc/source/parser/cpp/pe_vari.cxx (revision 78bc99aa)
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 "pe_vari.hxx"
24cdf0e10cSrcweir 
25cdf0e10cSrcweir 
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx>
28cdf0e10cSrcweir #include "pe_expr.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace cpp {
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
PE_Variable(Cpp_PE * i_pParent)36cdf0e10cSrcweir PE_Variable::PE_Variable( Cpp_PE * i_pParent )
37cdf0e10cSrcweir 	:   Cpp_PE(i_pParent),
38cdf0e10cSrcweir 		pStati( new PeStatusArray<PE_Variable> )
39cdf0e10cSrcweir 		// pSpExpression,
40cdf0e10cSrcweir         // pSpuArraySizeExpression,
41cdf0e10cSrcweir 		// pSpuInitExpression,
42cdf0e10cSrcweir         // sResultSizeExpression,
43cdf0e10cSrcweir         // sResultInitExpression
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 	Setup_StatusFunctions();
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	pSpExpression       = new SP_Expression(*this);
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	pSpuArraySizeExpression  = new SPU_Expression(*pSpExpression, 0, &PE_Variable::SpReturn_ArraySizeExpression);
50cdf0e10cSrcweir 	pSpuInitExpression  = new SPU_Expression(*pSpExpression, 0, &PE_Variable::SpReturn_InitExpression);
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
~PE_Variable()53cdf0e10cSrcweir PE_Variable::~PE_Variable()
54cdf0e10cSrcweir {
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir void
Call_Handler(const cpp::Token & i_rTok)58cdf0e10cSrcweir PE_Variable::Call_Handler( const cpp::Token &	i_rTok )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir 	pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir void
Setup_StatusFunctions()64cdf0e10cSrcweir PE_Variable::Setup_StatusFunctions()
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	typedef CallFunction<PE_Variable>::F_Tok	F_Tok;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	static F_Tok stateF_afterName[] =		{ &PE_Variable::On_afterName_ArrayBracket_Left,
69cdf0e10cSrcweir 											  &PE_Variable::On_afterName_Semicolon,
70cdf0e10cSrcweir 											  &PE_Variable::On_afterName_Comma,
71cdf0e10cSrcweir 											  &PE_Variable::On_afterName_Assign };
72cdf0e10cSrcweir 	static INT16 stateT_afterName[] =     	{ Tid_ArrayBracket_Left,
73cdf0e10cSrcweir 											  Tid_Semicolon,
74cdf0e10cSrcweir 											  Tid_Comma,
75cdf0e10cSrcweir 											  Tid_Assign };
76cdf0e10cSrcweir 	static F_Tok stateF_afterSize[] =		{ &PE_Variable::On_afterSize_ArrayBracket_Right };
77cdf0e10cSrcweir 	static INT16 stateT_afterSize[] =		{ Tid_ArrayBracket_Right };
78cdf0e10cSrcweir 	static F_Tok stateF_expectFinish[] =	{ &PE_Variable::On_expectFinish_Bracket_Right,
79cdf0e10cSrcweir                                               &PE_Variable::On_expectFinish_Semicolon,
80cdf0e10cSrcweir 											  &PE_Variable::On_expectFinish_Comma };
81cdf0e10cSrcweir 	static INT16 stateT_expectFinish[] =   	{ Tid_Bracket_Right,
82cdf0e10cSrcweir                                               Tid_Semicolon,
83cdf0e10cSrcweir 											  Tid_Comma };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	SEMPARSE_CREATE_STATUS(PE_Variable, afterName, Hdl_SyntaxError);
86cdf0e10cSrcweir 	SEMPARSE_CREATE_STATUS(PE_Variable, afterSize, Hdl_SyntaxError);
87cdf0e10cSrcweir 	SEMPARSE_CREATE_STATUS(PE_Variable, expectFinish, Hdl_SyntaxError);
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir void
InitData()91cdf0e10cSrcweir PE_Variable::InitData()
92cdf0e10cSrcweir {
93cdf0e10cSrcweir     pStati->SetCur(afterName);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     sResultSizeExpression.clear();
96cdf0e10cSrcweir     sResultInitExpression.clear();
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir void
TransferData()100cdf0e10cSrcweir PE_Variable::TransferData()
101cdf0e10cSrcweir {
102cdf0e10cSrcweir     pStati->SetCur(size_of_states);
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir void
Hdl_SyntaxError(const char * i_sText)106cdf0e10cSrcweir PE_Variable::Hdl_SyntaxError( const char * i_sText)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	StdHandlingOfSyntaxError(i_sText);
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir void
SpReturn_ArraySizeExpression()112cdf0e10cSrcweir PE_Variable::SpReturn_ArraySizeExpression()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     pStati->SetCur(afterSize);
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     sResultSizeExpression = pSpuArraySizeExpression->Child().Result_Text();
117cdf0e10cSrcweir }
118cdf0e10cSrcweir 
119cdf0e10cSrcweir void
SpReturn_InitExpression()120cdf0e10cSrcweir PE_Variable::SpReturn_InitExpression()
121cdf0e10cSrcweir {
122cdf0e10cSrcweir     pStati->SetCur(expectFinish);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     sResultInitExpression = pSpuInitExpression->Child().Result_Text();
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir void
On_afterName_ArrayBracket_Left(const char *)128cdf0e10cSrcweir PE_Variable::On_afterName_ArrayBracket_Left(const char *)
129cdf0e10cSrcweir {
130cdf0e10cSrcweir     pSpuArraySizeExpression->Push(done);
131cdf0e10cSrcweir }
132cdf0e10cSrcweir 
133cdf0e10cSrcweir void
On_afterName_Semicolon(const char *)134cdf0e10cSrcweir PE_Variable::On_afterName_Semicolon(const char *)
135cdf0e10cSrcweir {
136cdf0e10cSrcweir     SetTokenResult(not_done, pop_success);
137cdf0e10cSrcweir }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir void
On_afterName_Comma(const char *)140cdf0e10cSrcweir PE_Variable::On_afterName_Comma(const char *)
141cdf0e10cSrcweir {
142cdf0e10cSrcweir     SetTokenResult(not_done, pop_success);
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir void
On_afterName_Assign(const char *)146cdf0e10cSrcweir PE_Variable::On_afterName_Assign(const char *)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir     pSpuInitExpression->Push(done);
149cdf0e10cSrcweir }
150cdf0e10cSrcweir 
151cdf0e10cSrcweir void
On_afterSize_ArrayBracket_Right(const char *)152cdf0e10cSrcweir PE_Variable::On_afterSize_ArrayBracket_Right(const char *)
153cdf0e10cSrcweir {
154cdf0e10cSrcweir     SetTokenResult(done, stay);
155cdf0e10cSrcweir     pStati->SetCur(afterName);
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir void
On_expectFinish_Semicolon(const char *)159cdf0e10cSrcweir PE_Variable::On_expectFinish_Semicolon(const char *)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     SetTokenResult(not_done, pop_success);
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir void
On_expectFinish_Comma(const char *)165cdf0e10cSrcweir PE_Variable::On_expectFinish_Comma(const char *)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     SetTokenResult(not_done, pop_success);
168cdf0e10cSrcweir }
169cdf0e10cSrcweir 
170cdf0e10cSrcweir void
On_expectFinish_Bracket_Right(const char *)171cdf0e10cSrcweir PE_Variable::On_expectFinish_Bracket_Right(const char *)
172cdf0e10cSrcweir {
173cdf0e10cSrcweir     SetTokenResult(not_done, pop_success);
174cdf0e10cSrcweir }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 
177cdf0e10cSrcweir }   // namespace cpp
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 
181cdf0e10cSrcweir 
182