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_defs.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_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"
48 PE_Defines::PE_Defines( Cpp_PE
* i_pParent
)
50 pStati( new PeStatusArray
<PE_Defines
> ),
56 Setup_StatusFunctions();
60 PE_Defines::~PE_Defines()
65 PE_Defines::Call_Handler( const cpp::Token
& i_rTok
)
67 pStati
->Cur().Call_Handler(i_rTok
.TypeId(), i_rTok
.Text());
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
,
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
[] =
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
);
99 PE_Defines::InitData()
101 pStati
->SetCur(expectName
);
104 csv::erase_container( aParameters
);
105 csv::erase_container( aDefinition
);
110 PE_Defines::TransferData()
114 if (aDefinition
.empty() OR aDefinition
.front().empty())
118 rNew
= Env().AryGate().Defs().Store_Define(
119 Env().Context(), sName
, aDefinition
);
120 Env().Event_Store_CppDefinition(rNew
);
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
);
133 PE_Defines::Hdl_SyntaxError( const char * i_sText
)
135 StdHandlingOfSyntaxError(i_sText
);
139 PE_Defines::On_expectName_DefineName( const char * i_sText
)
141 SetTokenResult(done
, stay
);
142 pStati
->SetCur(gotDefineName
);
149 PE_Defines::On_expectName_MacroName( const char * i_sText
)
151 SetTokenResult(done
, stay
);
152 pStati
->SetCur(expectMacroParameters
);
159 PE_Defines::On_gotDefineName_PreProDefinition( const char * i_sText
)
161 SetTokenResult(done
, pop_success
);
163 aDefinition
.push_back( String (i_sText
) );
167 PE_Defines::On_expectMacroParameters_MacroParameter( const char * i_sText
)
169 SetTokenResult(done
, stay
);
170 aParameters
.push_back( String (i_sText
) );
174 PE_Defines::On_expectMacroParameters_PreProDefinition( const char * i_sText
)
176 SetTokenResult(done
, pop_success
);
178 aDefinition
.push_back( String (i_sText
) );