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_expr.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_expr.hxx"
35 // NOT FULLY DECLARED SERVICES
42 PE_Expression::PE_Expression( Cpp_PE
* i_pParent
)
44 pStati( new PeStatusArray
<PE_Expression
> ),
48 Setup_StatusFunctions();
52 PE_Expression::~PE_Expression()
57 PE_Expression::Call_Handler( const cpp::Token
& i_rTok
)
59 pStati
->Cur().Call_Handler(i_rTok
.TypeId(), i_rTok
.Text());
62 switch (i_rTok
.TypeId())
64 case Tid_SwBracket_Left
: SetTokenResult(done
, stay
);
68 case Tid_SwBracket_Right
: SetTokenResult(done
, stay
);
71 case Tid_Semicolon
: if (nBracketCounter
== 0)
72 SetTokenResult(done
, pop_success
);
74 SetTokenResult(done
, stay
);
77 if ( bBlockOpened AND nBracketCounter
== 0 )
79 SetTokenResult(not_done
, pop_success
);
83 SetTokenResult(done
, stay
);
90 PE_Expression::Setup_StatusFunctions()
92 typedef CallFunction
<PE_Expression
>::F_Tok F_Tok
;
94 static F_Tok stateF_std
[] = { &PE_Expression::On_std_SwBracket_Left
,
95 &PE_Expression::On_std_SwBracket_Right
,
96 &PE_Expression::On_std_ArrayBracket_Left
,
97 &PE_Expression::On_std_ArrayBracket_Right
,
98 &PE_Expression::On_std_Bracket_Left
,
99 &PE_Expression::On_std_Bracket_Right
,
100 &PE_Expression::On_std_Semicolon
,
101 &PE_Expression::On_std_Comma
};
102 static INT16 stateT_std
[] = { Tid_SwBracket_Left
,
104 Tid_ArrayBracket_Left
,
105 Tid_ArrayBracket_Right
,
111 SEMPARSE_CREATE_STATUS(PE_Expression
, std
, On_std_Default
);
115 PE_Expression::InitData()
118 aResult_Text
.seekp(0);
123 PE_Expression::TransferData()
125 pStati
->SetCur(size_of_states
);
126 if ( aResult_Text
.tellp() > 0)
127 aResult_Text
.pop_back(1);
131 PE_Expression::On_std_Default( const char * i_sText
)
133 SetTokenResult(done
, stay
);
134 aResult_Text
<< i_sText
<< " ";
138 PE_Expression::On_std_SwBracket_Left( const char *)
140 SetTokenResult(done
, stay
);
145 PE_Expression::On_std_SwBracket_Right( const char *)
148 if ( nBracketCounter
>= 0 )
149 SetTokenResult(done
, stay
);
151 SetTokenResult(not_done
, pop_success
);
155 PE_Expression::On_std_ArrayBracket_Left( const char *)
157 SetTokenResult(done
, stay
);
162 PE_Expression::On_std_ArrayBracket_Right( const char *)
165 if ( nBracketCounter
>= 0 )
166 SetTokenResult(done
, stay
);
168 SetTokenResult(not_done
, pop_success
);
172 PE_Expression::On_std_Bracket_Left( const char *)
174 SetTokenResult(done
, stay
);
179 PE_Expression::On_std_Bracket_Right( const char *)
182 if ( nBracketCounter
>= 0 )
183 SetTokenResult(done
, stay
);
185 SetTokenResult(not_done
, pop_success
);
189 PE_Expression::On_std_Semicolon( const char *)
191 SetTokenResult(not_done
, pop_success
);
195 PE_Expression::On_std_Comma( const char *)
197 SetTokenResult(not_done
, pop_success
);