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