merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / parser / cpp / pe_defs.cxx
blob72ca51567767791b254182c5761461a26bf38abf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pe_defs.cxx,v $
10 * $Revision: 1.8 $
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 ************************************************************************/
31 #include <precomp.h>
32 #include "pe_defs.hxx"
35 // NOT FULLY DECLARED SERVICES
36 #include <cosv/tpl/tpltools.hxx>
37 #include <ary/cpp/c_gate.hxx>
38 #include <ary/cpp/c_define.hxx>
39 #include <ary/cpp/c_macro.hxx>
40 #include <ary/cpp/cp_def.hxx>
41 #include "all_toks.hxx"
44 namespace cpp
48 PE_Defines::PE_Defines( Cpp_PE * i_pParent )
49 : Cpp_PE(i_pParent),
50 pStati( new PeStatusArray<PE_Defines> ),
51 // sName,
52 // aParameters,
53 // sDefinition,
54 bIsMacro(false)
56 Setup_StatusFunctions();
60 PE_Defines::~PE_Defines()
64 void
65 PE_Defines::Call_Handler( const cpp::Token & i_rTok )
67 pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
70 void
71 PE_Defines::Setup_StatusFunctions()
73 typedef CallFunction<PE_Defines>::F_Tok F_Tok;
74 static F_Tok stateF_expectName[] = { &PE_Defines::On_expectName_DefineName,
75 &PE_Defines::On_expectName_MacroName
77 static INT16 stateT_expectName[] = { Tid_DefineName,
78 Tid_MacroName
81 static F_Tok stateF_gotDefineName[] = { &PE_Defines::On_gotDefineName_PreProDefinition };
82 static INT16 stateT_gotDefineName[] = { Tid_PreProDefinition };
84 static F_Tok stateF_expectMacroParameters[] =
85 { &PE_Defines::On_expectMacroParameters_MacroParameter,
86 &PE_Defines::On_expectMacroParameters_PreProDefinition
88 static INT16 stateT_expectMacroParameters[] =
89 { Tid_MacroParameter,
90 Tid_PreProDefinition
93 SEMPARSE_CREATE_STATUS(PE_Defines, expectName, Hdl_SyntaxError);
94 SEMPARSE_CREATE_STATUS(PE_Defines, gotDefineName, Hdl_SyntaxError);
95 SEMPARSE_CREATE_STATUS(PE_Defines, expectMacroParameters, Hdl_SyntaxError);
98 void
99 PE_Defines::InitData()
101 pStati->SetCur(expectName);
103 sName.clear();
104 csv::erase_container( aParameters );
105 csv::erase_container( aDefinition );
106 bIsMacro = false;
109 void
110 PE_Defines::TransferData()
112 if (NOT bIsMacro)
114 if (aDefinition.empty() OR aDefinition.front().empty())
115 return;
117 ary::cpp::Define &
118 rNew = Env().AryGate().Defs().Store_Define(
119 Env().Context(), sName, aDefinition );
120 Env().Event_Store_CppDefinition(rNew);
122 else
124 ary::cpp::Macro &
125 rNew = Env().AryGate().Defs().Store_Macro(
126 Env().Context(), sName, aParameters, aDefinition );
127 Env().Event_Store_CppDefinition(rNew);
129 pStati->SetCur(size_of_states);
132 void
133 PE_Defines::Hdl_SyntaxError( const char * i_sText)
135 StdHandlingOfSyntaxError(i_sText);
138 void
139 PE_Defines::On_expectName_DefineName( const char * i_sText )
141 SetTokenResult(done, stay);
142 pStati->SetCur(gotDefineName);
144 sName = i_sText;
145 bIsMacro = false;
148 void
149 PE_Defines::On_expectName_MacroName( const char * i_sText )
151 SetTokenResult(done, stay);
152 pStati->SetCur(expectMacroParameters);
154 sName = i_sText;
155 bIsMacro = true;
158 void
159 PE_Defines::On_gotDefineName_PreProDefinition( const char * i_sText )
161 SetTokenResult(done, pop_success);
163 aDefinition.push_back( String (i_sText) );
166 void
167 PE_Defines::On_expectMacroParameters_MacroParameter( const char * i_sText )
169 SetTokenResult(done, stay);
170 aParameters.push_back( String (i_sText) );
173 void
174 PE_Defines::On_expectMacroParameters_PreProDefinition( const char * i_sText )
176 SetTokenResult(done, pop_success);
178 aDefinition.push_back( String (i_sText) );
182 } // namespace cpp