1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_param.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #include "pe_param.hxx"
35 // NOT FULLY DEFINED SERVICES
36 #include <cosv/tpl/tpltools.hxx>
37 #include <ary/cpp/c_gate.hxx>
38 #include <ary/cpp/cp_type.hxx>
39 #include "pe_type.hxx"
40 #include "pe_vari.hxx"
47 //*********************** PE_Parameter ***********************//
50 PE_Parameter::PE_Parameter( Cpp_PE
* i_pParent
)
52 pStati( new PeStatusArray
<PE_Parameter
> )
59 Setup_StatusFunctions();
61 pSpType
= new SP_Type(*this);
62 pSpuType
= new SPU_Type(*pSpType
, &PE_Parameter::SpInit_Type
, &PE_Parameter::SpReturn_Type
);
63 pSpVariable
= new SP_Variable(*this);
64 pSpuVariable
= new SPU_Variable(*pSpVariable
, &PE_Parameter::SpInit_Variable
, &PE_Parameter::SpReturn_Variable
);
67 PE_Parameter::~PE_Parameter()
72 PE_Parameter::Call_Handler( const cpp::Token
& i_rTok
)
74 pStati
->Cur().Call_Handler(i_rTok
.TypeId(), i_rTok
.Text());
78 PE_Parameter::Setup_StatusFunctions()
80 typedef CallFunction
<PE_Parameter
>::F_Tok F_Tok
;
81 static F_Tok stateF_start
[] = { &PE_Parameter::On_start_Type
,
82 &PE_Parameter::On_start_Type
,
83 &PE_Parameter::On_start_Type
,
84 &PE_Parameter::On_start_Type
,
85 &PE_Parameter::On_start_Type
,
87 &PE_Parameter::On_start_Type
,
88 &PE_Parameter::On_start_Type
,
89 &PE_Parameter::On_start_Bracket_Right
,
90 &PE_Parameter::On_start_Type
,
91 &PE_Parameter::On_start_Ellipse
,
93 &PE_Parameter::On_start_Type
,
94 &PE_Parameter::On_start_Type
,
95 &PE_Parameter::On_start_Type
};
96 static INT16 stateT_start
[] = { Tid_Identifier
,
110 Tid_TypeSpecializer
};
112 static F_Tok stateF_expectName
[] = { &PE_Parameter::On_expectName_Identifier
,
113 &PE_Parameter::On_expectName_ArrayBracket_Left
,
114 &PE_Parameter::On_expectName_Bracket_Right
,
115 &PE_Parameter::On_expectName_Comma
,
116 &PE_Parameter::On_afterName_Assign
};
117 static INT16 stateT_expectName
[] = { Tid_Identifier
,
118 Tid_ArrayBracket_Left
,
122 static F_Tok stateF_afterName
[] = { &PE_Parameter::On_afterName_ArrayBracket_Left
,
123 &PE_Parameter::On_afterName_Bracket_Right
,
124 &PE_Parameter::On_afterName_Comma
,
125 &PE_Parameter::On_afterName_Assign
};
126 static INT16 stateT_afterName
[] = { Tid_ArrayBracket_Left
,
130 static F_Tok stateF_finished
[] = { &PE_Parameter::On_finished_Comma
,
131 &PE_Parameter::On_finished_Bracket_Right
};
132 static INT16 stateT_finished
[] = { Tid_Bracket_Right
,
135 SEMPARSE_CREATE_STATUS(PE_Parameter
, start
, Hdl_SyntaxError
);
136 SEMPARSE_CREATE_STATUS(PE_Parameter
, expectName
, Hdl_SyntaxError
);
137 SEMPARSE_CREATE_STATUS(PE_Parameter
, afterName
, Hdl_SyntaxError
);
138 SEMPARSE_CREATE_STATUS(PE_Parameter
, finished
, Hdl_SyntaxError
);
143 PE_Parameter::InitData()
145 pStati
->SetCur(start
);
146 aResultParamInfo
.Empty();
150 PE_Parameter::TransferData()
152 pStati
->SetCur(size_of_states
);
156 PE_Parameter::Hdl_SyntaxError( const char * i_sText
)
158 StdHandlingOfSyntaxError(i_sText
);
162 PE_Parameter::SpInit_Type()
168 PE_Parameter::SpInit_Variable()
174 PE_Parameter::SpReturn_Type()
176 aResultParamInfo
.nType
= pSpuType
->Child().Result_Type().Id();
177 pStati
->SetCur(expectName
);
181 PE_Parameter::SpReturn_Variable()
183 if (pSpuVariable
->Child().Result_Pattern() > 0)
185 aResultParamInfo
.sSizeExpression
= pSpuVariable
->Child().Result_SizeExpression();
186 aResultParamInfo
.sInitExpression
= pSpuVariable
->Child().Result_InitExpression();
191 PE_Parameter::On_start_Type(const char *)
193 pSpuType
->Push(not_done
);
197 PE_Parameter::On_start_Bracket_Right(const char *)
199 SetTokenResult(not_done
, pop_success
);
203 PE_Parameter::On_start_Ellipse(const char *)
205 SetTokenResult(done
, pop_success
);
207 aResultParamInfo
.nType
= Env().AryGate().Types().Tid_Ellipse();
211 PE_Parameter::On_expectName_Identifier(const char * i_sText
)
213 SetTokenResult(done
, stay
);
214 pStati
->SetCur(afterName
);
216 aResultParamInfo
.sName
= i_sText
;
220 PE_Parameter::On_expectName_ArrayBracket_Left(const char * i_sText
)
222 On_afterName_ArrayBracket_Left(i_sText
);
226 PE_Parameter::On_expectName_Bracket_Right(const char * i_sText
)
228 On_afterName_Bracket_Right(i_sText
);
232 PE_Parameter::On_expectName_Comma(const char * i_sText
)
234 On_afterName_Comma(i_sText
);
238 PE_Parameter::On_afterName_ArrayBracket_Left(const char *)
240 pSpuVariable
->Push(not_done
);
244 PE_Parameter::On_afterName_Bracket_Right(const char *)
246 SetTokenResult(not_done
, pop_success
);
250 PE_Parameter::On_afterName_Comma(const char *)
252 SetTokenResult(not_done
, pop_success
);
256 PE_Parameter::On_afterName_Assign(const char *)
258 pSpuVariable
->Push(not_done
);
262 PE_Parameter::On_finished_Bracket_Right(const char *)
264 SetTokenResult(not_done
, pop_success
);
268 PE_Parameter::On_finished_Comma(const char *)
270 SetTokenResult(not_done
, pop_success
);