xref: /aoo42x/main/idl/source/cmptools/lex.cxx (revision 724893d4)
1*724893d4SAndrew Rist /**************************************************************
2*724893d4SAndrew Rist  *
3*724893d4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*724893d4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*724893d4SAndrew Rist  * distributed with this work for additional information
6*724893d4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*724893d4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*724893d4SAndrew Rist  * "License"); you may not use this file except in compliance
9*724893d4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*724893d4SAndrew Rist  *
11*724893d4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*724893d4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*724893d4SAndrew Rist  * software distributed under the License is distributed on an
15*724893d4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*724893d4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*724893d4SAndrew Rist  * specific language governing permissions and limitations
18*724893d4SAndrew Rist  * under the License.
19*724893d4SAndrew Rist  *
20*724893d4SAndrew Rist  *************************************************************/
21*724893d4SAndrew Rist 
22*724893d4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_idl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <ctype.h>
29cdf0e10cSrcweir #include <stdio.h>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <char.hxx>
32cdf0e10cSrcweir #include <hash.hxx>
33cdf0e10cSrcweir #include <lex.hxx>
34cdf0e10cSrcweir #include <globals.hxx>
35cdf0e10cSrcweir #include <tools/bigint.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /****************** SvToken **********************************************/
38cdf0e10cSrcweir /*************************************************************************
39cdf0e10cSrcweir |*
40cdf0e10cSrcweir |*    SvToken::Print()
41cdf0e10cSrcweir |*
42cdf0e10cSrcweir |*    Beschreibung
43cdf0e10cSrcweir |*
44cdf0e10cSrcweir *************************************************************************/
45cdf0e10cSrcweir ByteString SvToken::GetTokenAsString() const
46cdf0e10cSrcweir {
47cdf0e10cSrcweir     ByteString aStr;
48cdf0e10cSrcweir     switch( nType )
49cdf0e10cSrcweir     {
50cdf0e10cSrcweir         case SVTOKEN_EMPTY:
51cdf0e10cSrcweir             break;
52cdf0e10cSrcweir         case SVTOKEN_COMMENT:
53cdf0e10cSrcweir             aStr = aString;
54cdf0e10cSrcweir             break;
55cdf0e10cSrcweir         case SVTOKEN_INTEGER:
56cdf0e10cSrcweir             aStr = ByteString::CreateFromInt64(nLong);
57cdf0e10cSrcweir             break;
58cdf0e10cSrcweir         case SVTOKEN_STRING:
59cdf0e10cSrcweir             aStr = aString;
60cdf0e10cSrcweir             break;
61cdf0e10cSrcweir         case SVTOKEN_BOOL:
62cdf0e10cSrcweir             aStr = bBool ? "TRUE" : "FALSE";
63cdf0e10cSrcweir             break;
64cdf0e10cSrcweir         case SVTOKEN_IDENTIFIER:
65cdf0e10cSrcweir             aStr = aString;
66cdf0e10cSrcweir             break;
67cdf0e10cSrcweir         case SVTOKEN_CHAR:
68cdf0e10cSrcweir             aStr = cChar;
69cdf0e10cSrcweir             break;
70cdf0e10cSrcweir         case SVTOKEN_RTTIBASE:
71cdf0e10cSrcweir             aStr = "RTTIBASE";//(ULONG)pComplexObj;
72cdf0e10cSrcweir             break;
73cdf0e10cSrcweir         case SVTOKEN_EOF:
74cdf0e10cSrcweir         case SVTOKEN_HASHID:
75cdf0e10cSrcweir             break;
76cdf0e10cSrcweir     }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     return aStr;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir /*************************************************************************
82cdf0e10cSrcweir |*
83cdf0e10cSrcweir |*    SvToken::SvToken()
84cdf0e10cSrcweir |*
85cdf0e10cSrcweir |*    Beschreibung
86cdf0e10cSrcweir |*
87cdf0e10cSrcweir *************************************************************************/
88cdf0e10cSrcweir SvToken::SvToken( const SvToken & rObj )
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	nLine = rObj.nLine;
91cdf0e10cSrcweir 	nColumn = rObj.nColumn;
92cdf0e10cSrcweir 	nType = rObj.nType;
93cdf0e10cSrcweir 	aString = rObj.aString;
94cdf0e10cSrcweir /*
95cdf0e10cSrcweir     if( SVTOKEN_RTTIBASE = nType )
96cdf0e10cSrcweir 	{
97cdf0e10cSrcweir 	    pComplexObj = rObj.pComplexObj;
98cdf0e10cSrcweir 		pComplexObj->AddRef();
99cdf0e10cSrcweir 	}
100cdf0e10cSrcweir 	else
101cdf0e10cSrcweir */
102cdf0e10cSrcweir 	    nLong = rObj.nLong;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir /*************************************************************************
106cdf0e10cSrcweir |*
107cdf0e10cSrcweir |*    SvToken::operator = ()
108cdf0e10cSrcweir |*
109cdf0e10cSrcweir |*    Beschreibung
110cdf0e10cSrcweir |*
111cdf0e10cSrcweir *************************************************************************/
112cdf0e10cSrcweir SvToken & SvToken::operator = ( const SvToken & rObj )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir 	if( this != &rObj )
115cdf0e10cSrcweir 	{
116cdf0e10cSrcweir /*
117cdf0e10cSrcweir         if( SVTOKEN_RTTIBASE = nType )
118cdf0e10cSrcweir 	    	pComplexObj->ReleaseRef();
119cdf0e10cSrcweir */
120cdf0e10cSrcweir 	    nLine = rObj.nLine;
121cdf0e10cSrcweir 	    nColumn = rObj.nColumn;
122cdf0e10cSrcweir 	    nType = rObj.nType;
123cdf0e10cSrcweir 	    aString = rObj.aString;
124cdf0e10cSrcweir /*
125cdf0e10cSrcweir         if( SVTOKEN_RTTIBASE = nType )
126cdf0e10cSrcweir 		{
127cdf0e10cSrcweir 	    	pComplexObj = rObj.pComplexObj;
128cdf0e10cSrcweir 			pComplexObj->AddRef();
129cdf0e10cSrcweir 		}
130cdf0e10cSrcweir 		else
131cdf0e10cSrcweir */
132cdf0e10cSrcweir 		    nLong = rObj.nLong;
133cdf0e10cSrcweir 	}
134cdf0e10cSrcweir     return *this;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir /****************** SvTokenStream ****************************************/
138cdf0e10cSrcweir /*************************************************************************
139cdf0e10cSrcweir |*    SvTokenStream::InitCtor()
140cdf0e10cSrcweir |*
141cdf0e10cSrcweir |*    Beschreibung
142cdf0e10cSrcweir *************************************************************************/
143cdf0e10cSrcweir void SvTokenStream::InitCtor()
144cdf0e10cSrcweir {
145cdf0e10cSrcweir     SetCharSet( gsl_getSystemTextEncoding() );
146cdf0e10cSrcweir 	aStrTrue	= "TRUE";
147cdf0e10cSrcweir 	aStrFalse	= "FALSE";
148cdf0e10cSrcweir     nLine       = nColumn = 0;
149cdf0e10cSrcweir     nBufPos     = 0;
150cdf0e10cSrcweir     nTabSize    = 4;
151cdf0e10cSrcweir 	pCurToken	= NULL;
152cdf0e10cSrcweir 	nMaxPos		= 0;
153cdf0e10cSrcweir     c           = GetNextChar();
154cdf0e10cSrcweir 	FillTokenList();
155cdf0e10cSrcweir }
156cdf0e10cSrcweir 
157cdf0e10cSrcweir /*************************************************************************
158cdf0e10cSrcweir |*    SvTokenStream::SvTokenStream()
159cdf0e10cSrcweir |*
160cdf0e10cSrcweir |*    Beschreibung
161cdf0e10cSrcweir *************************************************************************/
162cdf0e10cSrcweir SvTokenStream::SvTokenStream( const String & rFileName )
163cdf0e10cSrcweir     : pInStream( new SvFileStream( rFileName, STREAM_STD_READ | STREAM_NOCREATE ) )
164cdf0e10cSrcweir     , rInStream( *pInStream )
165cdf0e10cSrcweir     , aFileName( rFileName )
166cdf0e10cSrcweir 	, aTokList( 0x8000, 0x8000 )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir     InitCtor();
169cdf0e10cSrcweir }
170cdf0e10cSrcweir 
171cdf0e10cSrcweir /*************************************************************************
172cdf0e10cSrcweir |*    SvTokenStream::SvTokenStream()
173cdf0e10cSrcweir |*
174cdf0e10cSrcweir |*    Beschreibung
175cdf0e10cSrcweir *************************************************************************/
176cdf0e10cSrcweir SvTokenStream::SvTokenStream( SvStream & rStream, const String & rFileName )
177cdf0e10cSrcweir     : pInStream( NULL )
178cdf0e10cSrcweir     , rInStream( rStream )
179cdf0e10cSrcweir     , aFileName( rFileName )
180cdf0e10cSrcweir 	, aTokList( 0x8000, 0x8000 )
181cdf0e10cSrcweir {
182cdf0e10cSrcweir     InitCtor();
183cdf0e10cSrcweir }
184cdf0e10cSrcweir 
185cdf0e10cSrcweir /*************************************************************************
186cdf0e10cSrcweir |*    SvTokenStream::~SvTokenStream()
187cdf0e10cSrcweir |*
188cdf0e10cSrcweir |*    Beschreibung
189cdf0e10cSrcweir *************************************************************************/
190cdf0e10cSrcweir SvTokenStream::~SvTokenStream()
191cdf0e10cSrcweir {
192cdf0e10cSrcweir     delete pInStream;
193cdf0e10cSrcweir     SvToken * pTok = aTokList.Last();
194cdf0e10cSrcweir     while( pTok )
195cdf0e10cSrcweir 	{
196cdf0e10cSrcweir         delete pTok;
197cdf0e10cSrcweir 		pTok = aTokList.Prev();
198cdf0e10cSrcweir 	}
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
201cdf0e10cSrcweir /*************************************************************************
202cdf0e10cSrcweir |*    SvTokenStream::FillTokenList()
203cdf0e10cSrcweir |*
204cdf0e10cSrcweir |*    Beschreibung
205cdf0e10cSrcweir *************************************************************************/
206cdf0e10cSrcweir void SvTokenStream::FillTokenList()
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	SvToken * pToken = new SvToken();
209cdf0e10cSrcweir 	aTokList.Insert( pToken, LIST_APPEND );
210cdf0e10cSrcweir 	do
211cdf0e10cSrcweir 	{
212cdf0e10cSrcweir 	    if( !MakeToken( *pToken ) )
213cdf0e10cSrcweir 		{
214cdf0e10cSrcweir 			SvToken * p = aTokList.Prev();
215cdf0e10cSrcweir 	        *pToken = SvToken();
216cdf0e10cSrcweir 			if( p )
217cdf0e10cSrcweir 			{
218cdf0e10cSrcweir 				pToken->SetLine( p->GetLine() );
219cdf0e10cSrcweir 				pToken->SetColumn( p->GetColumn() );
220cdf0e10cSrcweir 			}
221cdf0e10cSrcweir 			break;
222cdf0e10cSrcweir 		}
223cdf0e10cSrcweir 		else if( pToken->IsComment() )
224cdf0e10cSrcweir 			*pToken = SvToken();
225cdf0e10cSrcweir 		else if( pToken->IsEof() )
226cdf0e10cSrcweir 			break;
227cdf0e10cSrcweir 		else
228cdf0e10cSrcweir 		{
229cdf0e10cSrcweir 			pToken = new SvToken();
230cdf0e10cSrcweir 			aTokList.Insert( pToken, LIST_APPEND );
231cdf0e10cSrcweir 		}
232cdf0e10cSrcweir 	}
233cdf0e10cSrcweir 	while( !pToken->IsEof() );
234cdf0e10cSrcweir 	pCurToken = aTokList.First();
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir /*************************************************************************
238cdf0e10cSrcweir |*    SvTokenStrem::SetCharSet()
239cdf0e10cSrcweir |*
240cdf0e10cSrcweir |*    Beschreibung
241cdf0e10cSrcweir *************************************************************************/
242cdf0e10cSrcweir void SvTokenStream::SetCharSet( CharSet nSet )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     nCharSet = nSet;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir     pCharTab = SvChar::GetTable( nSet, gsl_getSystemTextEncoding() );
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir /*************************************************************************
250cdf0e10cSrcweir |*    SvTokeStream::GetNextChar()
251cdf0e10cSrcweir |*
252cdf0e10cSrcweir |*    Beschreibung
253cdf0e10cSrcweir *************************************************************************/
254cdf0e10cSrcweir int SvTokenStream::GetNextChar()
255cdf0e10cSrcweir {
256cdf0e10cSrcweir     int nChar;
257cdf0e10cSrcweir     if( (int)aBufStr.Len() < nBufPos )
258cdf0e10cSrcweir     {
259cdf0e10cSrcweir         if( rInStream.ReadLine( aBufStr ) )
260cdf0e10cSrcweir         {
261cdf0e10cSrcweir             nLine++;
262cdf0e10cSrcweir             nColumn = 0;
263cdf0e10cSrcweir             nBufPos = 0;
264cdf0e10cSrcweir         }
265cdf0e10cSrcweir         else
266cdf0e10cSrcweir 		{
267cdf0e10cSrcweir 			aBufStr.Erase();
268cdf0e10cSrcweir             nColumn = 0;
269cdf0e10cSrcweir             nBufPos = 0;
270cdf0e10cSrcweir 			return '\0';
271cdf0e10cSrcweir 		}
272cdf0e10cSrcweir     }
273cdf0e10cSrcweir     nChar = aBufStr.GetChar( (sal_uInt16)nBufPos++ );
274cdf0e10cSrcweir     nColumn += nChar == '\t' ? nTabSize : 1;
275cdf0e10cSrcweir     return nChar;
276cdf0e10cSrcweir }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir /*************************************************************************
279cdf0e10cSrcweir |*    SvTokenStrem::GetNumber()
280cdf0e10cSrcweir |*
281cdf0e10cSrcweir |*    Beschreibung
282cdf0e10cSrcweir *************************************************************************/
283cdf0e10cSrcweir sal_uLong SvTokenStream::GetNumber()
284cdf0e10cSrcweir {
285cdf0e10cSrcweir     sal_uLong   l = 0;
286cdf0e10cSrcweir     short   nLog = 10;
287cdf0e10cSrcweir 
288cdf0e10cSrcweir     if( '0' == c )
289cdf0e10cSrcweir     {
290cdf0e10cSrcweir         c = GetFastNextChar();
291cdf0e10cSrcweir         if( 'x' == c )
292cdf0e10cSrcweir         {
293cdf0e10cSrcweir             nLog = 16;
294cdf0e10cSrcweir             c = GetFastNextChar();
295cdf0e10cSrcweir         }
296cdf0e10cSrcweir     };
297cdf0e10cSrcweir 
298cdf0e10cSrcweir     if( nLog == 16 )
299cdf0e10cSrcweir     {
300cdf0e10cSrcweir         while( isxdigit( c ) )
301cdf0e10cSrcweir         {
302cdf0e10cSrcweir             if( isdigit( c ) )
303cdf0e10cSrcweir                 l = l * nLog + (c - '0');
304cdf0e10cSrcweir             else
305cdf0e10cSrcweir                 l = l * nLog + (toupper( c ) - 'A' + 10 );
306cdf0e10cSrcweir             c = GetFastNextChar();
307cdf0e10cSrcweir         }
308cdf0e10cSrcweir     }
309cdf0e10cSrcweir     else
310cdf0e10cSrcweir     {
311cdf0e10cSrcweir         while( isdigit( c ) || 'x' == c )
312cdf0e10cSrcweir         {
313cdf0e10cSrcweir             l = l * nLog + (c - '0');
314cdf0e10cSrcweir             c = GetFastNextChar();
315cdf0e10cSrcweir         }
316cdf0e10cSrcweir     }
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     return( l );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir /*************************************************************************
322cdf0e10cSrcweir |*    SvTokenStream::MakeToken()
323cdf0e10cSrcweir |*
324cdf0e10cSrcweir |*    Beschreibung
325cdf0e10cSrcweir *************************************************************************/
326cdf0e10cSrcweir sal_Bool SvTokenStream::MakeToken( SvToken & rToken )
327cdf0e10cSrcweir {
328cdf0e10cSrcweir     int             c1;
329cdf0e10cSrcweir     sal_uInt16          i;
330cdf0e10cSrcweir 
331cdf0e10cSrcweir 	do
332cdf0e10cSrcweir 	{
333cdf0e10cSrcweir 		if( 0 == c )
334cdf0e10cSrcweir 	        c = GetNextChar();
335cdf0e10cSrcweir 	    // Leerzeichen ueberlesen
336cdf0e10cSrcweir 	    while( isspace( c ) || 26 == c )
337cdf0e10cSrcweir 		{
338cdf0e10cSrcweir 	        c = GetFastNextChar();
339cdf0e10cSrcweir 		    nColumn += c == '\t' ? nTabSize : 1;
340cdf0e10cSrcweir 		}
341cdf0e10cSrcweir 	}
342cdf0e10cSrcweir 	while( 0 == c && !IsEof() && ( SVSTREAM_OK == rInStream.GetError() ) );
343cdf0e10cSrcweir 
344cdf0e10cSrcweir     sal_uLong nLastLine		= nLine;
345cdf0e10cSrcweir     sal_uLong nLastColumn	= nColumn;
346cdf0e10cSrcweir     // Kommentar
347cdf0e10cSrcweir     if( '/' == c )
348cdf0e10cSrcweir     {
349cdf0e10cSrcweir 		// Zeit Optimierung, keine Kommentare
350cdf0e10cSrcweir         //ByteString aComment( (char)c );
351cdf0e10cSrcweir         c1 = c;
352cdf0e10cSrcweir         c = GetFastNextChar();
353cdf0e10cSrcweir         if( '/' == c )
354cdf0e10cSrcweir         {
355cdf0e10cSrcweir             while( '\0' != c )
356cdf0e10cSrcweir             {
357cdf0e10cSrcweir                 //aComment += (char)c;
358cdf0e10cSrcweir                 c = GetFastNextChar();
359cdf0e10cSrcweir             }
360cdf0e10cSrcweir             c = GetNextChar();
361cdf0e10cSrcweir             rToken.nType 	= SVTOKEN_COMMENT;
362cdf0e10cSrcweir 			//rToken.aString	= aComment;
363cdf0e10cSrcweir         }
364cdf0e10cSrcweir         else if( '*' == c )
365cdf0e10cSrcweir         {
366cdf0e10cSrcweir             //aComment += (char)c;
367cdf0e10cSrcweir             c = GetFastNextChar();
368cdf0e10cSrcweir             do
369cdf0e10cSrcweir 			{
370cdf0e10cSrcweir                 //aComment += (char)c;
371cdf0e10cSrcweir                 while( '*' != c )
372cdf0e10cSrcweir                 {
373cdf0e10cSrcweir 	                if( '\0' == c )
374cdf0e10cSrcweir 					{
375cdf0e10cSrcweir 	                	c = GetNextChar();
376cdf0e10cSrcweir 	                	if( IsEof() )
377cdf0e10cSrcweir 	                    	return sal_False;
378cdf0e10cSrcweir 					}
379cdf0e10cSrcweir 					else
380cdf0e10cSrcweir                     	c = GetFastNextChar();
381cdf0e10cSrcweir                     //aComment += (char)c;
382cdf0e10cSrcweir                 }
383cdf0e10cSrcweir                 c = GetFastNextChar();
384cdf0e10cSrcweir             }
385cdf0e10cSrcweir             while( '/' != c && !IsEof() && ( SVSTREAM_OK == rInStream.GetError() ) );
386cdf0e10cSrcweir             if( IsEof() || ( SVSTREAM_OK != rInStream.GetError() ) )
387cdf0e10cSrcweir                 return sal_False;
388cdf0e10cSrcweir             //aComment += (char)c;
389cdf0e10cSrcweir             c = GetNextChar();
390cdf0e10cSrcweir             rToken.nType = SVTOKEN_COMMENT;
391cdf0e10cSrcweir 			//rToken.aString = aComment;
392cdf0e10cSrcweir 			CalcColumn();
393cdf0e10cSrcweir         }
394cdf0e10cSrcweir         else
395cdf0e10cSrcweir 		{
396cdf0e10cSrcweir 			rToken.nType = SVTOKEN_CHAR;
397cdf0e10cSrcweir             rToken.cChar = (char)c1;
398cdf0e10cSrcweir 		}
399cdf0e10cSrcweir     }
400cdf0e10cSrcweir     else if( c == '"' )
401cdf0e10cSrcweir     {
402cdf0e10cSrcweir         ByteString          aStr;
403cdf0e10cSrcweir         i = 0;
404cdf0e10cSrcweir         sal_Bool bDone = sal_False;
405cdf0e10cSrcweir         while( !bDone && !IsEof() && c )
406cdf0e10cSrcweir         {
407cdf0e10cSrcweir             c = GetFastNextChar();
408cdf0e10cSrcweir 	        if( '\0' == c )
409cdf0e10cSrcweir 			{
410cdf0e10cSrcweir 				// Strings auch "uber das Zeilenende hinauslesen
411cdf0e10cSrcweir 				aStr += '\n';
412cdf0e10cSrcweir 	            c = GetNextChar();
413cdf0e10cSrcweir 	            if( IsEof() )
414cdf0e10cSrcweir 					return sal_False;
415cdf0e10cSrcweir 			}
416cdf0e10cSrcweir             if( c == '"' )
417cdf0e10cSrcweir             {
418cdf0e10cSrcweir                 c = GetFastNextChar();
419cdf0e10cSrcweir                 if( c == '"' )
420cdf0e10cSrcweir                 {
421cdf0e10cSrcweir                     aStr += '"';
422cdf0e10cSrcweir                     aStr += '"';
423cdf0e10cSrcweir                 }
424cdf0e10cSrcweir                 else
425cdf0e10cSrcweir                     bDone = sal_True;
426cdf0e10cSrcweir             }
427cdf0e10cSrcweir             else if( c == '\\' )
428cdf0e10cSrcweir             {
429cdf0e10cSrcweir                 aStr += '\\';
430cdf0e10cSrcweir                 c = GetFastNextChar();
431cdf0e10cSrcweir                 if( c )
432cdf0e10cSrcweir                     aStr += (char)c;
433cdf0e10cSrcweir             }
434cdf0e10cSrcweir             else
435cdf0e10cSrcweir                 aStr += (char)c;
436cdf0e10cSrcweir         }
437cdf0e10cSrcweir         if( IsEof() || ( SVSTREAM_OK != rInStream.GetError() ) )
438cdf0e10cSrcweir             return sal_False;
439cdf0e10cSrcweir         char * pStr = (char *)aStr.GetBuffer();
440cdf0e10cSrcweir         while( *pStr )
441cdf0e10cSrcweir         {
442cdf0e10cSrcweir             *pStr = pCharTab[ (unsigned char)*pStr ];
443cdf0e10cSrcweir             pStr++;
444cdf0e10cSrcweir         };
445cdf0e10cSrcweir         rToken.nType   = SVTOKEN_STRING;
446cdf0e10cSrcweir 		rToken.aString = aStr;
447cdf0e10cSrcweir     }
448cdf0e10cSrcweir     else if( isdigit( c ) )
449cdf0e10cSrcweir     {
450cdf0e10cSrcweir         rToken.nType = SVTOKEN_INTEGER;
451cdf0e10cSrcweir         rToken.nLong = GetNumber();
452cdf0e10cSrcweir 
453cdf0e10cSrcweir     }
454cdf0e10cSrcweir     else if( isalpha (c) || (c == '_') )
455cdf0e10cSrcweir     {
456cdf0e10cSrcweir         ByteString aStr;
457cdf0e10cSrcweir 
458cdf0e10cSrcweir         while( isalnum( c ) || c == '_' )
459cdf0e10cSrcweir         {
460cdf0e10cSrcweir             aStr += (char)c;
461cdf0e10cSrcweir             c = GetFastNextChar();
462cdf0e10cSrcweir         }
463cdf0e10cSrcweir         if( aStr.EqualsIgnoreCaseAscii( aStrTrue ) )
464cdf0e10cSrcweir 		{
465cdf0e10cSrcweir             rToken.nType = SVTOKEN_BOOL;
466cdf0e10cSrcweir 			rToken.bBool = sal_True;
467cdf0e10cSrcweir         }
468cdf0e10cSrcweir         else if( aStr.EqualsIgnoreCaseAscii( aStrFalse ) )
469cdf0e10cSrcweir 		{
470cdf0e10cSrcweir             rToken.nType = SVTOKEN_BOOL;
471cdf0e10cSrcweir 			rToken.bBool = sal_False;
472cdf0e10cSrcweir         }
473cdf0e10cSrcweir         else
474cdf0e10cSrcweir         {
475cdf0e10cSrcweir             sal_uInt32 nHashId;
476cdf0e10cSrcweir             if( IDLAPP->pHashTable->Test( aStr, &nHashId ) )
477cdf0e10cSrcweir                 rToken.SetHash( IDLAPP->pHashTable->Get( nHashId ) );
478cdf0e10cSrcweir 			else
479cdf0e10cSrcweir 			{
480cdf0e10cSrcweir             	rToken.nType   = SVTOKEN_IDENTIFIER;
481cdf0e10cSrcweir 				rToken.aString = aStr;
482cdf0e10cSrcweir 			}
483cdf0e10cSrcweir         }
484cdf0e10cSrcweir     }
485cdf0e10cSrcweir     else if( IsEof() )
486cdf0e10cSrcweir     {
487cdf0e10cSrcweir         rToken.nType = SVTOKEN_EOF;
488cdf0e10cSrcweir     }
489cdf0e10cSrcweir     else
490cdf0e10cSrcweir     {
491cdf0e10cSrcweir         rToken.nType = SVTOKEN_CHAR;
492cdf0e10cSrcweir 		rToken.cChar = (char)c;
493cdf0e10cSrcweir         c = GetFastNextChar();
494cdf0e10cSrcweir     }
495cdf0e10cSrcweir     rToken.SetLine( nLastLine );
496cdf0e10cSrcweir     rToken.SetColumn( nLastColumn );
497cdf0e10cSrcweir 	return rInStream.GetError() == SVSTREAM_OK;
498cdf0e10cSrcweir }
499cdf0e10cSrcweir 
500