xref: /trunk/main/autodoc/source/parser/cpp/pe_vari.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include <precomp.h>
29 #include "pe_vari.hxx"
30 
31 
32 // NOT FULLY DEFINED SERVICES
33 #include <cosv/tpl/tpltools.hxx>
34 #include "pe_expr.hxx"
35 
36 
37 
38 
39 namespace cpp {
40 
41 
42 PE_Variable::PE_Variable( Cpp_PE * i_pParent )
43 	:   Cpp_PE(i_pParent),
44 		pStati( new PeStatusArray<PE_Variable> )
45 		// pSpExpression,
46         // pSpuArraySizeExpression,
47 		// pSpuInitExpression,
48         // sResultSizeExpression,
49         // sResultInitExpression
50 {
51 	Setup_StatusFunctions();
52 
53 	pSpExpression       = new SP_Expression(*this);
54 
55 	pSpuArraySizeExpression  = new SPU_Expression(*pSpExpression, 0, &PE_Variable::SpReturn_ArraySizeExpression);
56 	pSpuInitExpression  = new SPU_Expression(*pSpExpression, 0, &PE_Variable::SpReturn_InitExpression);
57 }
58 
59 PE_Variable::~PE_Variable()
60 {
61 }
62 
63 void
64 PE_Variable::Call_Handler( const cpp::Token &	i_rTok )
65 {
66 	pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
67 }
68 
69 void
70 PE_Variable::Setup_StatusFunctions()
71 {
72 	typedef CallFunction<PE_Variable>::F_Tok	F_Tok;
73 
74 	static F_Tok stateF_afterName[] =		{ &PE_Variable::On_afterName_ArrayBracket_Left,
75 											  &PE_Variable::On_afterName_Semicolon,
76 											  &PE_Variable::On_afterName_Comma,
77 											  &PE_Variable::On_afterName_Assign };
78 	static INT16 stateT_afterName[] =     	{ Tid_ArrayBracket_Left,
79 											  Tid_Semicolon,
80 											  Tid_Comma,
81 											  Tid_Assign };
82 	static F_Tok stateF_afterSize[] =		{ &PE_Variable::On_afterSize_ArrayBracket_Right };
83 	static INT16 stateT_afterSize[] =		{ Tid_ArrayBracket_Right };
84 	static F_Tok stateF_expectFinish[] =	{ &PE_Variable::On_expectFinish_Bracket_Right,
85                                               &PE_Variable::On_expectFinish_Semicolon,
86 											  &PE_Variable::On_expectFinish_Comma };
87 	static INT16 stateT_expectFinish[] =   	{ Tid_Bracket_Right,
88                                               Tid_Semicolon,
89 											  Tid_Comma };
90 
91 	SEMPARSE_CREATE_STATUS(PE_Variable, afterName, Hdl_SyntaxError);
92 	SEMPARSE_CREATE_STATUS(PE_Variable, afterSize, Hdl_SyntaxError);
93 	SEMPARSE_CREATE_STATUS(PE_Variable, expectFinish, Hdl_SyntaxError);
94 }
95 
96 void
97 PE_Variable::InitData()
98 {
99     pStati->SetCur(afterName);
100 
101     sResultSizeExpression.clear();
102     sResultInitExpression.clear();
103 }
104 
105 void
106 PE_Variable::TransferData()
107 {
108     pStati->SetCur(size_of_states);
109 }
110 
111 void
112 PE_Variable::Hdl_SyntaxError( const char * i_sText)
113 {
114 	StdHandlingOfSyntaxError(i_sText);
115 }
116 
117 void
118 PE_Variable::SpReturn_ArraySizeExpression()
119 {
120     pStati->SetCur(afterSize);
121 
122     sResultSizeExpression = pSpuArraySizeExpression->Child().Result_Text();
123 }
124 
125 void
126 PE_Variable::SpReturn_InitExpression()
127 {
128     pStati->SetCur(expectFinish);
129 
130     sResultInitExpression = pSpuInitExpression->Child().Result_Text();
131 }
132 
133 void
134 PE_Variable::On_afterName_ArrayBracket_Left(const char *)
135 {
136     pSpuArraySizeExpression->Push(done);
137 }
138 
139 void
140 PE_Variable::On_afterName_Semicolon(const char *)
141 {
142     SetTokenResult(not_done, pop_success);
143 }
144 
145 void
146 PE_Variable::On_afterName_Comma(const char *)
147 {
148     SetTokenResult(not_done, pop_success);
149 }
150 
151 void
152 PE_Variable::On_afterName_Assign(const char *)
153 {
154     pSpuInitExpression->Push(done);
155 }
156 
157 void
158 PE_Variable::On_afterSize_ArrayBracket_Right(const char *)
159 {
160     SetTokenResult(done, stay);
161     pStati->SetCur(afterName);
162 }
163 
164 void
165 PE_Variable::On_expectFinish_Semicolon(const char *)
166 {
167     SetTokenResult(not_done, pop_success);
168 }
169 
170 void
171 PE_Variable::On_expectFinish_Comma(const char *)
172 {
173     SetTokenResult(not_done, pop_success);
174 }
175 
176 void
177 PE_Variable::On_expectFinish_Bracket_Right(const char *)
178 {
179     SetTokenResult(not_done, pop_success);
180 }
181 
182 
183 }   // namespace cpp
184 
185 
186 
187 
188