xref: /trunk/main/rsc/source/parser/rsclex.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_rsc.hxx"
30*cdf0e10cSrcweir #include <stdlib.h>
31*cdf0e10cSrcweir #include <stdio.h>
32*cdf0e10cSrcweir #include <string.h>
33*cdf0e10cSrcweir #include <ctype.h>
34*cdf0e10cSrcweir #include <limits.h>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #ifdef _RSCERROR_H
37*cdf0e10cSrcweir #include <rscerror.h>
38*cdf0e10cSrcweir #endif
39*cdf0e10cSrcweir #include <rschash.hxx>
40*cdf0e10cSrcweir #include <rscdb.hxx>
41*cdf0e10cSrcweir #include <rsctop.hxx>
42*cdf0e10cSrcweir #include <rsckey.hxx>
43*cdf0e10cSrcweir #include <rscpar.hxx>
44*cdf0e10cSrcweir #include <rscdef.hxx>
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include "rsclex.hxx"
47*cdf0e10cSrcweir #include <yyrscyacc.hxx>
48*cdf0e10cSrcweir 
49*cdf0e10cSrcweir #include <rtl/textcvt.h>
50*cdf0e10cSrcweir #include <rtl/textenc.h>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir using namespace rtl;
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir const char* StringContainer::putString( const char* pString )
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir     OString aString( static_cast<const sal_Char*>(pString) );
57*cdf0e10cSrcweir     std::pair<
58*cdf0e10cSrcweir         std::hash_set< OString, OStringHash >::iterator,
59*cdf0e10cSrcweir         bool > aInsert =
60*cdf0e10cSrcweir         m_aStrings.insert( aString );
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     return aInsert.first->getStr();
63*cdf0e10cSrcweir }
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir /*************************************************************************/
66*cdf0e10cSrcweir int             c;
67*cdf0e10cSrcweir sal_Bool            bLastInclude;// War letztes Symbol INCLUDE
68*cdf0e10cSrcweir RscFileInst*    pFI;
69*cdf0e10cSrcweir RscTypCont*     pTC;
70*cdf0e10cSrcweir RscExpression * pExp;
71*cdf0e10cSrcweir struct KeyVal {
72*cdf0e10cSrcweir     int     nKeyWord;
73*cdf0e10cSrcweir     YYSTYPE aYYSType;
74*cdf0e10cSrcweir } aKeyVal[ 1 ];
75*cdf0e10cSrcweir sal_Bool bTargetDefined;
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir StringContainer* pStringContainer = NULL;
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir /****************** C O D E **********************************************/
81*cdf0e10cSrcweir sal_uInt32 GetNumber(){
82*cdf0e10cSrcweir     sal_uInt32  l = 0;
83*cdf0e10cSrcweir     sal_uInt32  nLog = 10;
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     if( '0' == c ){
86*cdf0e10cSrcweir         c = pFI->GetFastChar();
87*cdf0e10cSrcweir         if( 'x' == c ){
88*cdf0e10cSrcweir             nLog = 16;
89*cdf0e10cSrcweir             c = pFI->GetFastChar();
90*cdf0e10cSrcweir         }
91*cdf0e10cSrcweir     };
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir     if( nLog == 16 ){
94*cdf0e10cSrcweir         while( isxdigit( c ) ){
95*cdf0e10cSrcweir             if( isdigit( c ) )
96*cdf0e10cSrcweir                 l = l * nLog + (c - '0');
97*cdf0e10cSrcweir             else
98*cdf0e10cSrcweir                 l = l * nLog + (toupper( c ) - 'A' + 10 );
99*cdf0e10cSrcweir             c = pFI->GetFastChar();
100*cdf0e10cSrcweir         }
101*cdf0e10cSrcweir     }
102*cdf0e10cSrcweir     else{
103*cdf0e10cSrcweir         while( isdigit( c ) || 'x' == c ){
104*cdf0e10cSrcweir             l = l * nLog + (c - '0');
105*cdf0e10cSrcweir             c = pFI->GetFastChar();
106*cdf0e10cSrcweir         }
107*cdf0e10cSrcweir     }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     while( c=='U' || c=='u' || c=='l' || c=='L' ) //Wg. Unsigned Longs
110*cdf0e10cSrcweir         c = pFI->GetFastChar();
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     if( l > 0x7fffffff ) //Oberstes bit gegebenenfalls abschneiden;
113*cdf0e10cSrcweir         l &= 0x7fffffff;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     return( l );
116*cdf0e10cSrcweir }
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir int MakeToken( YYSTYPE * pTokenVal ){
119*cdf0e10cSrcweir     int             c1;
120*cdf0e10cSrcweir     char *          pStr;
121*cdf0e10cSrcweir 
122*cdf0e10cSrcweir     while( sal_True ){  // Kommentare und Leerzeichen ueberlesen
123*cdf0e10cSrcweir         while( isspace( c ) )
124*cdf0e10cSrcweir             c = pFI->GetFastChar();
125*cdf0e10cSrcweir         if( '/' == c ){
126*cdf0e10cSrcweir             c1 = c;
127*cdf0e10cSrcweir             c = pFI->GetFastChar();
128*cdf0e10cSrcweir             if( '/' == c ){
129*cdf0e10cSrcweir                 while( '\n' != c && !pFI->IsEof() )
130*cdf0e10cSrcweir                     c = pFI->GetFastChar();
131*cdf0e10cSrcweir                 c = pFI->GetFastChar();
132*cdf0e10cSrcweir             }
133*cdf0e10cSrcweir             else if( '*' == c ){
134*cdf0e10cSrcweir                 c = pFI->GetFastChar();
135*cdf0e10cSrcweir                 do {
136*cdf0e10cSrcweir                     while( '*' != c && !pFI->IsEof() )
137*cdf0e10cSrcweir                         c = pFI->GetFastChar();
138*cdf0e10cSrcweir                     c = pFI->GetFastChar();
139*cdf0e10cSrcweir                 } while( '/' != c && !pFI->IsEof() );
140*cdf0e10cSrcweir                 c = pFI->GetFastChar();
141*cdf0e10cSrcweir             }
142*cdf0e10cSrcweir             else
143*cdf0e10cSrcweir                 return( c1 );
144*cdf0e10cSrcweir         }
145*cdf0e10cSrcweir         else
146*cdf0e10cSrcweir             break;
147*cdf0e10cSrcweir     };
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     if( c == pFI->IsEof() ){
150*cdf0e10cSrcweir         return( 0 );
151*cdf0e10cSrcweir     }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir     if( bLastInclude ){
154*cdf0e10cSrcweir         bLastInclude = sal_False; //Zuruecksetzten
155*cdf0e10cSrcweir         if( '<' == c ){
156*cdf0e10cSrcweir             OStringBuffer aBuf( 256 );
157*cdf0e10cSrcweir             c = pFI->GetFastChar();
158*cdf0e10cSrcweir             while( '>' != c && !pFI->IsEof() )
159*cdf0e10cSrcweir             {
160*cdf0e10cSrcweir                 aBuf.append( sal_Char(c) );
161*cdf0e10cSrcweir                 c = pFI->GetFastChar();
162*cdf0e10cSrcweir             };
163*cdf0e10cSrcweir             c = pFI->GetFastChar();
164*cdf0e10cSrcweir             pTokenVal->string = const_cast<char*>(pStringContainer->putString( aBuf.getStr() ));
165*cdf0e10cSrcweir             return( INCLUDE_STRING );
166*cdf0e10cSrcweir         };
167*cdf0e10cSrcweir     }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir     if( c == '"' )
170*cdf0e10cSrcweir     {
171*cdf0e10cSrcweir         OStringBuffer aBuf( 256 );
172*cdf0e10cSrcweir         sal_Bool bDone = sal_False;
173*cdf0e10cSrcweir         while( !bDone && !pFI->IsEof() && c )
174*cdf0e10cSrcweir         {
175*cdf0e10cSrcweir             c = pFI->GetFastChar();
176*cdf0e10cSrcweir             if( c == '"' )
177*cdf0e10cSrcweir             {
178*cdf0e10cSrcweir                 do
179*cdf0e10cSrcweir                 {
180*cdf0e10cSrcweir                     c = pFI->GetFastChar();
181*cdf0e10cSrcweir                 }
182*cdf0e10cSrcweir                 while(  c == ' ' || c == '\t' );
183*cdf0e10cSrcweir                 if( c == '"' )
184*cdf0e10cSrcweir                 {
185*cdf0e10cSrcweir                     // this is a continued string
186*cdf0e10cSrcweir                     // note: multiline string continuations are handled by the parser
187*cdf0e10cSrcweir                     // see rscyacc.y
188*cdf0e10cSrcweir                 }
189*cdf0e10cSrcweir                 else
190*cdf0e10cSrcweir                     bDone = sal_True;
191*cdf0e10cSrcweir             }
192*cdf0e10cSrcweir             else if( c == '\\' )
193*cdf0e10cSrcweir             {
194*cdf0e10cSrcweir                 aBuf.append( '\\' );
195*cdf0e10cSrcweir                 c = pFI->GetFastChar();
196*cdf0e10cSrcweir                 if( c )
197*cdf0e10cSrcweir                     aBuf.append( sal_Char(c) );
198*cdf0e10cSrcweir             }
199*cdf0e10cSrcweir             else
200*cdf0e10cSrcweir                 aBuf.append( sal_Char(c) );
201*cdf0e10cSrcweir         }
202*cdf0e10cSrcweir         pStr = pTokenVal->string = const_cast<char*>(pStringContainer->putString( aBuf.getStr() ));
203*cdf0e10cSrcweir         return( STRING );
204*cdf0e10cSrcweir     }
205*cdf0e10cSrcweir     if (isdigit (c)){
206*cdf0e10cSrcweir         pTokenVal->value = GetNumber();
207*cdf0e10cSrcweir         return( NUMBER );
208*cdf0e10cSrcweir     }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     if( isalpha (c) || (c == '_') ){
211*cdf0e10cSrcweir         Atom        nHashId;
212*cdf0e10cSrcweir         OStringBuffer aBuf( 256 );
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir         while( isalnum (c) || (c == '_') || (c == '-') )
215*cdf0e10cSrcweir         {
216*cdf0e10cSrcweir             aBuf.append( sal_Char(c) );
217*cdf0e10cSrcweir             c = pFI->GetFastChar();
218*cdf0e10cSrcweir         }
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir         nHashId = pHS->getID( aBuf.getStr(), true );
221*cdf0e10cSrcweir         if( InvalidAtom != nHashId )
222*cdf0e10cSrcweir         {
223*cdf0e10cSrcweir             KEY_STRUCT  aKey;
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir             // Suche nach dem Schluesselwort
226*cdf0e10cSrcweir             if( pTC->aNmTb.Get( nHashId, &aKey ) )
227*cdf0e10cSrcweir             {
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir                 // Schluesselwort gefunden
230*cdf0e10cSrcweir                 switch( aKey.nTyp )
231*cdf0e10cSrcweir                 {
232*cdf0e10cSrcweir                     case CLASSNAME:
233*cdf0e10cSrcweir                         pTokenVal->pClass = (RscTop *)aKey.yylval;
234*cdf0e10cSrcweir                         break;
235*cdf0e10cSrcweir                     case VARNAME:
236*cdf0e10cSrcweir                         pTokenVal->varid = aKey.nName;
237*cdf0e10cSrcweir                         break;
238*cdf0e10cSrcweir                     case CONSTNAME:
239*cdf0e10cSrcweir                         pTokenVal->constname.hashid = aKey.nName;
240*cdf0e10cSrcweir                         pTokenVal->constname.nValue = aKey.yylval;
241*cdf0e10cSrcweir                         break;
242*cdf0e10cSrcweir                     case BOOLEAN:
243*cdf0e10cSrcweir                         pTokenVal->svbool = (sal_Bool)aKey.yylval;
244*cdf0e10cSrcweir                         break;
245*cdf0e10cSrcweir                     case INCLUDE:
246*cdf0e10cSrcweir                         bLastInclude = sal_True;
247*cdf0e10cSrcweir                     default:
248*cdf0e10cSrcweir                         pTokenVal->value = aKey.yylval;
249*cdf0e10cSrcweir                 };
250*cdf0e10cSrcweir 
251*cdf0e10cSrcweir                 return( aKey.nTyp );
252*cdf0e10cSrcweir             }
253*cdf0e10cSrcweir             else
254*cdf0e10cSrcweir             {
255*cdf0e10cSrcweir                 pTokenVal->string = const_cast<char*>(pStringContainer->putString( aBuf.getStr() ));
256*cdf0e10cSrcweir                 return( SYMBOL );
257*cdf0e10cSrcweir             }
258*cdf0e10cSrcweir         }
259*cdf0e10cSrcweir         else{       // Symbol
260*cdf0e10cSrcweir             RscDefine  * pDef;
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir             pDef = pTC->aFileTab.FindDef( aBuf.getStr() );
263*cdf0e10cSrcweir             if( pDef ){
264*cdf0e10cSrcweir                 pTokenVal->defineele = pDef;
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir                 return( RSCDEFINE );
267*cdf0e10cSrcweir             }
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir             pTokenVal->string = const_cast<char*>(pStringContainer->putString( aBuf.getStr() ));
270*cdf0e10cSrcweir             return( SYMBOL );
271*cdf0e10cSrcweir         }
272*cdf0e10cSrcweir     }
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir     if( c=='<' )
275*cdf0e10cSrcweir     {
276*cdf0e10cSrcweir         c = pFI->GetFastChar();
277*cdf0e10cSrcweir         if( c=='<' )
278*cdf0e10cSrcweir         {
279*cdf0e10cSrcweir             c = pFI->GetFastChar();
280*cdf0e10cSrcweir             return LEFTSHIFT;
281*cdf0e10cSrcweir         }
282*cdf0e10cSrcweir         else
283*cdf0e10cSrcweir             return '<';
284*cdf0e10cSrcweir     }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir     if( c=='>' )
287*cdf0e10cSrcweir     {
288*cdf0e10cSrcweir         c = pFI->GetFastChar();
289*cdf0e10cSrcweir         if( c=='>' )
290*cdf0e10cSrcweir         {
291*cdf0e10cSrcweir             c = pFI->GetFastChar();
292*cdf0e10cSrcweir             return RIGHTSHIFT;
293*cdf0e10cSrcweir         }
294*cdf0e10cSrcweir         else
295*cdf0e10cSrcweir             return '>';
296*cdf0e10cSrcweir     }
297*cdf0e10cSrcweir 
298*cdf0e10cSrcweir     c1 = c;
299*cdf0e10cSrcweir     c = pFI->GetFastChar();
300*cdf0e10cSrcweir     return( c1 );
301*cdf0e10cSrcweir }
302*cdf0e10cSrcweir 
303*cdf0e10cSrcweir #if defined( RS6000 ) || defined( HP9000 ) || defined( SCO )
304*cdf0e10cSrcweir extern "C" int yylex()
305*cdf0e10cSrcweir #else
306*cdf0e10cSrcweir int yylex()
307*cdf0e10cSrcweir #endif
308*cdf0e10cSrcweir {
309*cdf0e10cSrcweir     if( bTargetDefined )
310*cdf0e10cSrcweir         bTargetDefined = sal_False;
311*cdf0e10cSrcweir     else
312*cdf0e10cSrcweir         aKeyVal[ 0 ].nKeyWord =
313*cdf0e10cSrcweir                      MakeToken( &aKeyVal[ 0 ].aYYSType );
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir     yylval = aKeyVal[ 0 ].aYYSType;
316*cdf0e10cSrcweir     return( aKeyVal[ 0 ].nKeyWord );
317*cdf0e10cSrcweir }
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir /****************** yyerror **********************************************/
320*cdf0e10cSrcweir #ifdef RS6000
321*cdf0e10cSrcweir extern "C" void yyerror( char* pMessage )
322*cdf0e10cSrcweir #elif defined HP9000 || defined SCO || defined SOLARIS
323*cdf0e10cSrcweir extern "C" void yyerror( const char* pMessage )
324*cdf0e10cSrcweir #else
325*cdf0e10cSrcweir void yyerror( char* pMessage )
326*cdf0e10cSrcweir #endif
327*cdf0e10cSrcweir {
328*cdf0e10cSrcweir     pTC->pEH->Error( ERR_YACC, NULL, RscId(), pMessage );
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir /****************** parser start function ********************************/
332*cdf0e10cSrcweir void InitParser( RscFileInst * pFileInst )
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir     pTC = pFileInst->pTypCont;          // Datenkontainer setzten
335*cdf0e10cSrcweir     pFI = pFileInst;
336*cdf0e10cSrcweir     pStringContainer = new StringContainer();
337*cdf0e10cSrcweir     pExp = NULL;                //fuer MacroParser
338*cdf0e10cSrcweir     bTargetDefined = sal_False;
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir     // Anfangszeichen initialisieren
341*cdf0e10cSrcweir     bLastInclude = sal_False;
342*cdf0e10cSrcweir     c = pFI->GetFastChar();
343*cdf0e10cSrcweir }
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir void EndParser(){
346*cdf0e10cSrcweir     // Stack abraeumen
347*cdf0e10cSrcweir     while( ! S.IsEmpty() )
348*cdf0e10cSrcweir         S.Pop();
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir     // free string container
351*cdf0e10cSrcweir     delete pStringContainer;
352*cdf0e10cSrcweir     pStringContainer = NULL;
353*cdf0e10cSrcweir 
354*cdf0e10cSrcweir     if( pExp )
355*cdf0e10cSrcweir         delete pExp;
356*cdf0e10cSrcweir     pTC      = NULL;
357*cdf0e10cSrcweir     pFI      = NULL;
358*cdf0e10cSrcweir     pExp     = NULL;
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir }
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir void IncludeParser( RscFileInst * pFileInst )
363*cdf0e10cSrcweir {
364*cdf0e10cSrcweir     int           nToken;   // Wert des Tokens
365*cdf0e10cSrcweir     YYSTYPE       aYYSType; // Daten des Tokens
366*cdf0e10cSrcweir     RscFile     * pFName;   // Filestruktur
367*cdf0e10cSrcweir     sal_uLong         lKey;     // Fileschluessel
368*cdf0e10cSrcweir     RscTypCont  * pTypCon  = pFileInst->pTypCont;
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir     pFName = pTypCon->aFileTab.Get( pFileInst->GetFileIndex() );
371*cdf0e10cSrcweir     InitParser( pFileInst );
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir     nToken = MakeToken( &aYYSType );
374*cdf0e10cSrcweir     while( 0 != nToken && CLASSNAME != nToken ){
375*cdf0e10cSrcweir         if( '#' == nToken ){
376*cdf0e10cSrcweir             if( INCLUDE == (nToken = MakeToken( &aYYSType )) ){
377*cdf0e10cSrcweir                 if( STRING == (nToken = MakeToken( &aYYSType )) ){
378*cdf0e10cSrcweir                     lKey = pTypCon->aFileTab.NewIncFile( aYYSType.string,
379*cdf0e10cSrcweir                                                          aYYSType.string );
380*cdf0e10cSrcweir                     pFName->InsertDependFile( lKey, LIST_APPEND );
381*cdf0e10cSrcweir                 }
382*cdf0e10cSrcweir                 else if( INCLUDE_STRING == nToken ){
383*cdf0e10cSrcweir                     lKey = pTypCon->aFileTab.NewIncFile( aYYSType.string,
384*cdf0e10cSrcweir                                                          ByteString() );
385*cdf0e10cSrcweir                     pFName->InsertDependFile( lKey, LIST_APPEND );
386*cdf0e10cSrcweir                 };
387*cdf0e10cSrcweir             };
388*cdf0e10cSrcweir         };
389*cdf0e10cSrcweir         nToken = MakeToken( &aYYSType );
390*cdf0e10cSrcweir     };
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir     EndParser();
393*cdf0e10cSrcweir }
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir ERRTYPE parser( RscFileInst * pFileInst )
396*cdf0e10cSrcweir {
397*cdf0e10cSrcweir     ERRTYPE aError;
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir     InitParser( pFileInst );
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir     aError = yyparse();
402*cdf0e10cSrcweir 
403*cdf0e10cSrcweir     EndParser();
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir     // yyparser gibt 0 zurueck, wenn erfolgreich
406*cdf0e10cSrcweir     if( 0 == aError )
407*cdf0e10cSrcweir         aError.Clear();
408*cdf0e10cSrcweir     if( pFileInst->pTypCont->pEH->nErrors )
409*cdf0e10cSrcweir         aError = ERR_ERROR;
410*cdf0e10cSrcweir     pFileInst->SetError( aError );
411*cdf0e10cSrcweir     return( aError );
412*cdf0e10cSrcweir }
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir RscExpression * MacroParser( RscFileInst & rFileInst )
415*cdf0e10cSrcweir {
416*cdf0e10cSrcweir     ERRTYPE       aError;
417*cdf0e10cSrcweir     RscExpression * pExpression;
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir     InitParser( &rFileInst );
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir     //Ziel auf macro_expression setzen
422*cdf0e10cSrcweir     aKeyVal[ 0 ].nKeyWord = MACROTARGET;
423*cdf0e10cSrcweir     bTargetDefined = sal_True;
424*cdf0e10cSrcweir     aError = yyparse();
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir     pExpression = pExp;
427*cdf0e10cSrcweir     //EndParser() wuerde pExp loeschen
428*cdf0e10cSrcweir     if( pExp )
429*cdf0e10cSrcweir         pExp = NULL;
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir     EndParser();
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir     // yyparser gibt 0 zurueck, wenn erfolgreich
434*cdf0e10cSrcweir     if( 0 == aError )
435*cdf0e10cSrcweir         aError.Clear();
436*cdf0e10cSrcweir     if( rFileInst.pTypCont->pEH->nErrors )
437*cdf0e10cSrcweir         aError = ERR_ERROR;
438*cdf0e10cSrcweir     rFileInst.SetError( aError );
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir     //im Fehlerfall pExpression loeschen
441*cdf0e10cSrcweir     if( aError.IsError() && pExpression ){
442*cdf0e10cSrcweir         delete pExpression;
443*cdf0e10cSrcweir         pExpression = NULL;
444*cdf0e10cSrcweir     };
445*cdf0e10cSrcweir     return( pExpression );
446*cdf0e10cSrcweir }
447*cdf0e10cSrcweir 
448