merge the formfield patch from ooo-build
[ooovba.git] / autodoc / source / parser / cpp / pe_expr.cxx
blob15535b201d4bf6acdc2bfc5011af0cb7b09af7ff
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_expr.cxx,v $
10 * $Revision: 1.7 $
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_expr.hxx"
35 // NOT FULLY DECLARED SERVICES
38 namespace cpp {
42 PE_Expression::PE_Expression( Cpp_PE * i_pParent )
43 : Cpp_PE(i_pParent),
44 pStati( new PeStatusArray<PE_Expression> ),
45 aResult_Text(100),
46 nBracketCounter(0)
48 Setup_StatusFunctions();
52 PE_Expression::~PE_Expression()
56 void
57 PE_Expression::Call_Handler( const cpp::Token & i_rTok )
59 pStati->Cur().Call_Handler(i_rTok.TypeId(), i_rTok.Text());
61 #if 0
62 switch (i_rTok.TypeId())
64 case Tid_SwBracket_Left: SetTokenResult(done, stay);
65 nBracketCounter++;
66 bBlockOpened = true;
67 break;
68 case Tid_SwBracket_Right: SetTokenResult(done, stay);
69 nBracketCounter--;
70 break;
71 case Tid_Semicolon: if (nBracketCounter == 0)
72 SetTokenResult(done, pop_success);
73 else
74 SetTokenResult(done, stay);
75 break;
76 default:
77 if ( bBlockOpened AND nBracketCounter == 0 )
79 SetTokenResult(not_done, pop_success);
81 else
83 SetTokenResult(done, stay);
85 } // end switch
86 #endif // 0
89 void
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,
103 Tid_SwBracket_Right,
104 Tid_ArrayBracket_Left,
105 Tid_ArrayBracket_Right,
106 Tid_Bracket_Left,
107 Tid_Bracket_Right,
108 Tid_Semicolon,
109 Tid_Comma };
111 SEMPARSE_CREATE_STATUS(PE_Expression, std, On_std_Default);
114 void
115 PE_Expression::InitData()
117 pStati->SetCur(std);
118 aResult_Text.seekp(0);
119 nBracketCounter = 0;
122 void
123 PE_Expression::TransferData()
125 pStati->SetCur(size_of_states);
126 if ( aResult_Text.tellp() > 0)
127 aResult_Text.pop_back(1);
130 void
131 PE_Expression::On_std_Default( const char * i_sText)
133 SetTokenResult(done, stay);
134 aResult_Text << i_sText << " ";
137 void
138 PE_Expression::On_std_SwBracket_Left( const char *)
140 SetTokenResult(done, stay);
141 nBracketCounter++;
144 void
145 PE_Expression::On_std_SwBracket_Right( const char *)
147 nBracketCounter--;
148 if ( nBracketCounter >= 0 )
149 SetTokenResult(done, stay);
150 else
151 SetTokenResult(not_done, pop_success);
154 void
155 PE_Expression::On_std_ArrayBracket_Left( const char *)
157 SetTokenResult(done, stay);
158 nBracketCounter++;
161 void
162 PE_Expression::On_std_ArrayBracket_Right( const char *)
164 nBracketCounter--;
165 if ( nBracketCounter >= 0 )
166 SetTokenResult(done, stay);
167 else
168 SetTokenResult(not_done, pop_success);
171 void
172 PE_Expression::On_std_Bracket_Left( const char *)
174 SetTokenResult(done, stay);
175 nBracketCounter++;
178 void
179 PE_Expression::On_std_Bracket_Right( const char *)
181 nBracketCounter--;
182 if ( nBracketCounter >= 0 )
183 SetTokenResult(done, stay);
184 else
185 SetTokenResult(not_done, pop_success);
188 void
189 PE_Expression::On_std_Semicolon( const char *)
191 SetTokenResult(not_done, pop_success);
194 void
195 PE_Expression::On_std_Comma( const char *)
197 SetTokenResult(not_done, pop_success);
201 } // namespace cpp