xref: /AOO41X/main/autodoc/source/parser/cpp/pe_enval.cxx (revision 78bc99aafea97f4987aed12e674c2d2f1166dd91)
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 "pe_enval.hxx"
24 
25 
26 // NOT FULLY DEFINED SERVICES
27 #include <cosv/tpl/tpltools.hxx>
28 #include <ary/cpp/c_gate.hxx>
29 #include <ary/cpp/cp_ce.hxx>
30 #include "pe_expr.hxx"
31 
32 
33 
34 namespace cpp {
35 
36 
PE_EnumValue(Cpp_PE * i_pParent)37 PE_EnumValue::PE_EnumValue( Cpp_PE * i_pParent )
38     :   Cpp_PE(i_pParent),
39         pStati( new PeStatusArray<PE_EnumValue> )
40         // pSpExpression,
41         // pSpuInitExpression
42 {
43     Setup_StatusFunctions();
44 
45     pSpExpression       = new SP_Expression(*this);
46     pSpuInitExpression  = new SPU_Expression(*pSpExpression, 0, &PE_EnumValue::SpReturn_InitExpression);
47 }
48 
~PE_EnumValue()49 PE_EnumValue::~PE_EnumValue()
50 {
51 }
52 
53 void
Call_Handler(const cpp::Token & i_rTok)54 PE_EnumValue::Call_Handler( const cpp::Token &  i_rTok )
55 {
56     pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
57 }
58 
59 void
Setup_StatusFunctions()60 PE_EnumValue::Setup_StatusFunctions()
61 {
62     typedef CallFunction<PE_EnumValue>::F_Tok   F_Tok;
63 
64     static F_Tok stateF_start[] =           { &PE_EnumValue::On_start_Identifier };
65     static INT16 stateT_start[] =           { Tid_Identifier };
66 
67     static F_Tok stateF_afterName[] =       { &PE_EnumValue::On_afterName_SwBracket_Right,
68                                               &PE_EnumValue::On_afterName_Comma,
69                                               &PE_EnumValue::On_afterName_Assign };
70     static INT16 stateT_afterName[] =       { Tid_SwBracket_Right,
71                                               Tid_Comma,
72                                               Tid_Assign };
73 
74     static F_Tok stateF_expectFinish[] =    { &PE_EnumValue::On_expectFinish_SwBracket_Right,
75                                               &PE_EnumValue::On_expectFinish_Comma };
76     static INT16 stateT_expectFinish[] =    { Tid_SwBracket_Right,
77                                               Tid_Comma };
78 
79     SEMPARSE_CREATE_STATUS(PE_EnumValue, start, Hdl_SyntaxError);
80     SEMPARSE_CREATE_STATUS(PE_EnumValue, afterName, Hdl_SyntaxError);
81     SEMPARSE_CREATE_STATUS(PE_EnumValue, expectFinish, Hdl_SyntaxError);
82 }
83 
84 void
InitData()85 PE_EnumValue::InitData()
86 {
87     pStati->SetCur(start);
88 
89     sName.clear();
90     sInitExpression.clear();
91 }
92 
93 void
TransferData()94 PE_EnumValue::TransferData()
95 {
96     pStati->SetCur(size_of_states);
97 
98     ary::cpp::EnumValue &
99     rEnVal = Env().AryGate().Ces().Store_EnumValue(
100                     Env().Context(), sName, sInitExpression );
101     Env().Event_Store_EnumValue(rEnVal);
102 }
103 
104 void
Hdl_SyntaxError(const char * i_sText)105 PE_EnumValue::Hdl_SyntaxError( const char * i_sText)
106 {
107     StdHandlingOfSyntaxError(i_sText);
108 }
109 
110 void
SpReturn_InitExpression()111 PE_EnumValue::SpReturn_InitExpression()
112 {
113     pStati->SetCur(expectFinish);
114 
115     sInitExpression = pSpuInitExpression->Child().Result_Text();
116 }
117 
118 void
On_start_Identifier(const char * i_sText)119 PE_EnumValue::On_start_Identifier(const char * i_sText)
120 {
121     SetTokenResult(done, stay);
122     pStati->SetCur(afterName);
123 
124     sName = i_sText;
125 }
126 
127 void
On_afterName_SwBracket_Right(const char *)128 PE_EnumValue::On_afterName_SwBracket_Right(const char *)
129 {
130     SetTokenResult(not_done, pop_success);
131 }
132 
133 void
On_afterName_Comma(const char *)134 PE_EnumValue::On_afterName_Comma(const char * )
135 {
136     SetTokenResult(done, pop_success);
137 }
138 
139 void
On_afterName_Assign(const char *)140 PE_EnumValue::On_afterName_Assign(const char * )
141 {
142     pSpuInitExpression->Push(done);
143 }
144 
145 void
On_expectFinish_SwBracket_Right(const char *)146 PE_EnumValue::On_expectFinish_SwBracket_Right(const char * )
147 {
148     SetTokenResult(not_done, pop_success);
149 }
150 
151 void
On_expectFinish_Comma(const char *)152 PE_EnumValue::On_expectFinish_Comma(const char * )
153 {
154     SetTokenResult(done, pop_success);
155 }
156 
157 
158 }   // namespace cpp
159 
160 
161 
162 
163