xref: /aoo41x/main/idlc/source/scanner.ll (revision e26f3242)
1*e26f3242SAndrew Rist/**************************************************************
2cdf0e10cSrcweir *
3*e26f3242SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*e26f3242SAndrew Rist * or more contributor license agreements.  See the NOTICE file
5*e26f3242SAndrew Rist * distributed with this work for additional information
6*e26f3242SAndrew Rist * regarding copyright ownership.  The ASF licenses this file
7*e26f3242SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*e26f3242SAndrew Rist * "License"); you may not use this file except in compliance
9*e26f3242SAndrew Rist * with the License.  You may obtain a copy of the License at
10*e26f3242SAndrew Rist *
11*e26f3242SAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
12*e26f3242SAndrew Rist *
13*e26f3242SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*e26f3242SAndrew Rist * software distributed under the License is distributed on an
15*e26f3242SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e26f3242SAndrew Rist * KIND, either express or implied.  See the License for the
17*e26f3242SAndrew Rist * specific language governing permissions and limitations
18*e26f3242SAndrew Rist * under the License.
19*e26f3242SAndrew Rist *
20*e26f3242SAndrew Rist *************************************************************/
21*e26f3242SAndrew Rist
22*e26f3242SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir%{
25cdf0e10cSrcweir/*
26cdf0e10cSrcweir * scanner.ll - Lexical scanner for IDLC 1.0
27cdf0e10cSrcweir */
28cdf0e10cSrcweir
29cdf0e10cSrcweir#include <ctype.h>
30cdf0e10cSrcweir#include <stdlib.h>
31cdf0e10cSrcweir#include <string.h>
32cdf0e10cSrcweir
33cdf0e10cSrcweir#ifndef _IDLC_IDLC_HXX_
34cdf0e10cSrcweir#include <idlc/idlc.hxx>
35cdf0e10cSrcweir#endif
36cdf0e10cSrcweir#ifndef _IDLC_ERRORHANDLER_HXX_
37cdf0e10cSrcweir#include <idlc/errorhandler.hxx>
38cdf0e10cSrcweir#endif
39cdf0e10cSrcweir#ifndef _IDLC_FEHELPER_HXX_
40cdf0e10cSrcweir#include <idlc/fehelper.hxx>
41cdf0e10cSrcweir#endif
42cdf0e10cSrcweir
43cdf0e10cSrcweir#include "attributeexceptions.hxx"
44cdf0e10cSrcweir
45cdf0e10cSrcweirclass AstExpression;
46cdf0e10cSrcweirclass AstArray;
47cdf0e10cSrcweirclass AstMember;
48cdf0e10cSrcweir
49cdf0e10cSrcweir#include <parser.hxx>
50cdf0e10cSrcweir
51cdf0e10cSrcweirsal_Int32		beginLine = 0;
52cdf0e10cSrcweir::rtl::OString	docu;
53cdf0e10cSrcweir
54cdf0e10cSrcweirstatic int asciiToInteger(char const * s, sal_Int64  * sval, sal_uInt64 * uval) {
55cdf0e10cSrcweir    bool neg = false;
56cdf0e10cSrcweir    if (*s == '-') {
57cdf0e10cSrcweir        neg = true;
58cdf0e10cSrcweir        ++s;
59cdf0e10cSrcweir    }
60cdf0e10cSrcweir    unsigned int base = 10;
61cdf0e10cSrcweir    if (*s == '0') {
62cdf0e10cSrcweir        base = 8;
63cdf0e10cSrcweir        ++s;
64cdf0e10cSrcweir        if (*s == 'X' || *s == 'x') {
65cdf0e10cSrcweir            base = 16;
66cdf0e10cSrcweir            ++s;
67cdf0e10cSrcweir        }
68cdf0e10cSrcweir    }
69cdf0e10cSrcweir    sal_uInt64 val = 0;
70cdf0e10cSrcweir    for (; *s != 0; ++s) {
71cdf0e10cSrcweir        unsigned int n;
72cdf0e10cSrcweir        if (*s >= '0' && *s <= '9') {
73cdf0e10cSrcweir            n = *s - '0';
74cdf0e10cSrcweir        } else {
75cdf0e10cSrcweir            switch (*s) {
76cdf0e10cSrcweir            case 'A':
77cdf0e10cSrcweir            case 'a':
78cdf0e10cSrcweir                n = 10;
79cdf0e10cSrcweir                break;
80cdf0e10cSrcweir            case 'B':
81cdf0e10cSrcweir            case 'b':
82cdf0e10cSrcweir                n = 11;
83cdf0e10cSrcweir                break;
84cdf0e10cSrcweir            case 'C':
85cdf0e10cSrcweir            case 'c':
86cdf0e10cSrcweir                n = 12;
87cdf0e10cSrcweir                break;
88cdf0e10cSrcweir            case 'D':
89cdf0e10cSrcweir            case 'd':
90cdf0e10cSrcweir                n = 13;
91cdf0e10cSrcweir                break;
92cdf0e10cSrcweir            case 'E':
93cdf0e10cSrcweir            case 'e':
94cdf0e10cSrcweir                n = 14;
95cdf0e10cSrcweir                break;
96cdf0e10cSrcweir            case 'F':
97cdf0e10cSrcweir            case 'f':
98cdf0e10cSrcweir                n = 15;
99cdf0e10cSrcweir                break;
100cdf0e10cSrcweir            default:
101cdf0e10cSrcweir                goto done;
102cdf0e10cSrcweir            }
103cdf0e10cSrcweir        }
104cdf0e10cSrcweir        // The following guarantees the invariant val <= SAL_MAX_UINT64 (because
105cdf0e10cSrcweir        // base and n are sufficiently small), *if*
106cdf0e10cSrcweir        // std::numeric_limits<sal_uInt64>::max() == SAL_MAX_UINT64:
107cdf0e10cSrcweir        sal_uInt64 nval = val * base + n;
108cdf0e10cSrcweir        if (nval < val) {
109cdf0e10cSrcweir            idlc()->error()->syntaxError(
110cdf0e10cSrcweir                PS_NoState, idlc()->getLineNumber(),
111cdf0e10cSrcweir                "integral constant too large");
112cdf0e10cSrcweir            val = 0;
113cdf0e10cSrcweir            break;
114cdf0e10cSrcweir        }
115cdf0e10cSrcweir        val = nval;
116cdf0e10cSrcweir    }
117cdf0e10cSrcweir done:
118cdf0e10cSrcweir    if (neg) {
119cdf0e10cSrcweir        if (val < SAL_CONST_UINT64(0x8000000000000000)) {
120cdf0e10cSrcweir            *sval = -static_cast< sal_Int64 >(val);
121cdf0e10cSrcweir        } else if (val == SAL_CONST_UINT64(0x8000000000000000)) {
122cdf0e10cSrcweir            *sval = SAL_MIN_INT64;
123cdf0e10cSrcweir        } else {
124cdf0e10cSrcweir            idlc()->error()->syntaxError(
125cdf0e10cSrcweir                PS_NoState, idlc()->getLineNumber(),
126cdf0e10cSrcweir                "negative integral constant too large");
127cdf0e10cSrcweir            *sval = 0;
128cdf0e10cSrcweir        }
129cdf0e10cSrcweir        return IDL_INTEGER_LITERAL;
130cdf0e10cSrcweir    } else if (val <= static_cast< sal_uInt64 >(SAL_MAX_INT64)) {
131cdf0e10cSrcweir        *sval = static_cast< sal_Int64 >(val);
132cdf0e10cSrcweir        return IDL_INTEGER_LITERAL;
133cdf0e10cSrcweir    } else {
134cdf0e10cSrcweir        *uval = val;
135cdf0e10cSrcweir        return IDL_INTEGER_ULITERAL;
136cdf0e10cSrcweir    }
137cdf0e10cSrcweir}
138cdf0e10cSrcweir
139cdf0e10cSrcweirstatic double asciiToFloat(const sal_Char *s)
140cdf0e10cSrcweir{
141cdf0e10cSrcweir   	double  	d = 0.0;
142cdf0e10cSrcweir   	double  	e, k;
143cdf0e10cSrcweir   	sal_Int32  	neg = 0, negexp = 0;
144cdf0e10cSrcweir
145cdf0e10cSrcweir   	if (*s == '-')
146cdf0e10cSrcweir   	{
147cdf0e10cSrcweir    	neg = 1;
148cdf0e10cSrcweir       	s++;
149cdf0e10cSrcweir   	}
150cdf0e10cSrcweir   	while (*s >= '0' && *s <= '9')
151cdf0e10cSrcweir   	{
152cdf0e10cSrcweir    	d = (d * 10) + *s - '0';
153cdf0e10cSrcweir       	s++;
154cdf0e10cSrcweir   	}
155cdf0e10cSrcweir   	if (*s == '.')
156cdf0e10cSrcweir   	{
157cdf0e10cSrcweir    	s++;
158cdf0e10cSrcweir       	e = 10;
159cdf0e10cSrcweir       	while (*s >= '0' && *s <= '9')
160cdf0e10cSrcweir       	{
161cdf0e10cSrcweir        	d += (*s - '0') / (e * 1.0);
162cdf0e10cSrcweir           	e *= 10;
163cdf0e10cSrcweir           	s++;
164cdf0e10cSrcweir       	}
165cdf0e10cSrcweir   	}
166cdf0e10cSrcweir   	if (*s == 'e' || *s == 'E')
167cdf0e10cSrcweir   	{
168cdf0e10cSrcweir    	s++;
169cdf0e10cSrcweir       	if (*s == '-')
170cdf0e10cSrcweir        {
171cdf0e10cSrcweir        	negexp = 1;
172cdf0e10cSrcweir           	s++;
173cdf0e10cSrcweir       	} else
174cdf0e10cSrcweir       	{
175cdf0e10cSrcweir        	if (*s == '+')
176cdf0e10cSrcweir            	s++;
177cdf0e10cSrcweir           	e = 0;
178cdf0e10cSrcweir           	while (*s >= '0' && *s <= '9')
179cdf0e10cSrcweir           	{
180cdf0e10cSrcweir            	e = (e * 10) + *s - '0';
181cdf0e10cSrcweir             	s++;
182cdf0e10cSrcweir           	}
183cdf0e10cSrcweir           	if (e > 0)
184cdf0e10cSrcweir           	{
185cdf0e10cSrcweir            	for (k = 1; e > 0; k *= 10, e--) ;
186cdf0e10cSrcweir               	if (negexp)
187cdf0e10cSrcweir                	d /= k;
188cdf0e10cSrcweir               	else
189cdf0e10cSrcweir                	d *= k;
190cdf0e10cSrcweir           	}
191cdf0e10cSrcweir		}
192cdf0e10cSrcweir   	}
193cdf0e10cSrcweir   	if (neg) d *= -1.0;
194cdf0e10cSrcweir   	return d;
195cdf0e10cSrcweir}
196cdf0e10cSrcweir
197cdf0e10cSrcweirstatic void	idlParsePragma(sal_Char* pPragma)
198cdf0e10cSrcweir{
199cdf0e10cSrcweir	::rtl::OString pragma(pPragma);
200cdf0e10cSrcweir	sal_Int32 index = pragma.indexOf("include");
201cdf0e10cSrcweir	sal_Char* begin = pPragma + index + 8;
202cdf0e10cSrcweir	sal_Char* offset = begin;
203cdf0e10cSrcweir	while (*offset != ',') offset++;
204cdf0e10cSrcweir	//::rtl::OString include = pragma.copy(index + 8, offset - begin);
205cdf0e10cSrcweir	idlc()->insertInclude(pragma.copy(index + 8, (sal_Int32)(offset - begin)));
206cdf0e10cSrcweir}
207cdf0e10cSrcweir
208cdf0e10cSrcweirstatic void parseLineAndFile(sal_Char* pBuf)
209cdf0e10cSrcweir{
210cdf0e10cSrcweir	sal_Char	*r = pBuf;
211cdf0e10cSrcweir	sal_Char    *h;
212cdf0e10cSrcweir	sal_Bool	bIsInMain = sal_False;
213cdf0e10cSrcweir
214cdf0e10cSrcweir	/* Skip initial '#' */
215cdf0e10cSrcweir	if (*r != '#')
216cdf0e10cSrcweir		return;
217cdf0e10cSrcweir
218cdf0e10cSrcweir	/* Find line number */
219cdf0e10cSrcweir	for (r++; *r == ' ' || *r == '\t' || isalpha(*r); r++) ;
220cdf0e10cSrcweir	h = r;
221cdf0e10cSrcweir	for (; *r != '\0' && *r != ' ' && *r != '\t'; r++) ;
222cdf0e10cSrcweir	*r++ = 0;
223cdf0e10cSrcweir	idlc()->setLineNumber((sal_uInt32)atol(h));
224cdf0e10cSrcweir
225cdf0e10cSrcweir	/* Find file name, if present */
226cdf0e10cSrcweir	for (; *r != '"'; r++)
227cdf0e10cSrcweir	{
228cdf0e10cSrcweir		if (*r == '\n' || *r == '\0')
229cdf0e10cSrcweir			return;
230cdf0e10cSrcweir	}
231cdf0e10cSrcweir	h = ++r;
232cdf0e10cSrcweir	for (; *r != '"'; r++) ;
233cdf0e10cSrcweir	*r = 0;
234cdf0e10cSrcweir	if (*h == '\0')
235cdf0e10cSrcweir		idlc()->setFileName(::rtl::OString("standard input"));
236cdf0e10cSrcweir	else
237cdf0e10cSrcweir		idlc()->setFileName(::rtl::OString(h));
238cdf0e10cSrcweir
239cdf0e10cSrcweir	bIsInMain = (idlc()->getFileName() == idlc()->getRealFileName()) ? sal_True : sal_False;
240cdf0e10cSrcweir	idlc()->setInMainfile(bIsInMain);
241cdf0e10cSrcweir}
242cdf0e10cSrcweir
243cdf0e10cSrcweir// Suppress any warnings from generated code:
244cdf0e10cSrcweir#if defined __GNUC__
245cdf0e10cSrcweir#pragma GCC system_header
246cdf0e10cSrcweir#elif defined __SUNPRO_CC
247cdf0e10cSrcweir#pragma disable_warn
248cdf0e10cSrcweir#elif defined _MSC_VER
249cdf0e10cSrcweir#pragma warning(push, 1)
250cdf0e10cSrcweir/**/
251cdf0e10cSrcweir#ifdef yywrap
252cdf0e10cSrcweir#undef  yywrap
253cdf0e10cSrcweir#define yywrap() 1
254cdf0e10cSrcweir#endif
255cdf0e10cSrcweir/**/
256cdf0e10cSrcweir#endif
257cdf0e10cSrcweir%}
258cdf0e10cSrcweir
259cdf0e10cSrcweir%option noyywrap
260cdf0e10cSrcweir%option never-interactive
261cdf0e10cSrcweir
262cdf0e10cSrcweir%x DOCU
263cdf0e10cSrcweir%x COMMENT
264cdf0e10cSrcweir
265cdf0e10cSrcweirDIGIT           [0-9]
266cdf0e10cSrcweirOCT_DIGIT       [0-7]
267cdf0e10cSrcweirHEX_DIGIT       [a-fA-F0-9]
268cdf0e10cSrcweirCAPITAL         [A-Z]
269cdf0e10cSrcweirALPHA           [a-zA-Z]
270cdf0e10cSrcweirINT_LITERAL     [1-9][0-9]*
271cdf0e10cSrcweirOCT_LITERAL     0{OCT_DIGIT}*
272cdf0e10cSrcweirHEX_LITERAL     (0x|0X){HEX_DIGIT}*
273cdf0e10cSrcweir
274cdf0e10cSrcweirIDENTIFIER_NEW  ({ALPHA}({ALPHA}|{DIGIT})*)|({CAPITAL}("_"?({ALPHA}|{DIGIT})+)*)
275cdf0e10cSrcweirIDENTIFIER      ("_"?({ALPHA}|{DIGIT})+)*
276cdf0e10cSrcweir
277cdf0e10cSrcweir%%
278cdf0e10cSrcweir
279cdf0e10cSrcweir[ \t\r]+	; /* eat up whitespace */
280cdf0e10cSrcweir[\n] 		{
281cdf0e10cSrcweir	idlc()->incLineNumber();
282cdf0e10cSrcweir}
283cdf0e10cSrcweir
284cdf0e10cSrcweirattribute       return IDL_ATTRIBUTE;
285cdf0e10cSrcweirbound           return IDL_BOUND;
286cdf0e10cSrcweircase            return IDL_CASE;
287cdf0e10cSrcweirconst           return IDL_CONST;
288cdf0e10cSrcweirconstants       return IDL_CONSTANTS;
289cdf0e10cSrcweirconstrained     return IDL_CONSTRAINED;
290cdf0e10cSrcweirdefault         return IDL_DEFAULT;
291cdf0e10cSrcweirenum            return IDL_ENUM;
292cdf0e10cSrcweirexception       return IDL_EXCEPTION;
293cdf0e10cSrcweirinterface       return IDL_INTERFACE;
294cdf0e10cSrcweirmaybeambiguous  return IDL_MAYBEAMBIGUOUS;
295cdf0e10cSrcweirmaybedefault    return IDL_MAYBEDEFAULT;
296cdf0e10cSrcweirmaybevoid       return IDL_MAYBEVOID;
297cdf0e10cSrcweirmodule          return IDL_MODULE;
298cdf0e10cSrcweirneeds           return IDL_NEEDS;
299cdf0e10cSrcweirobserves        return IDL_OBSERVES;
300cdf0e10cSrcweiroptional        return IDL_OPTIONAL;
301cdf0e10cSrcweirproperty        return IDL_PROPERTY;
302cdf0e10cSrcweirraises          return IDL_RAISES;
303cdf0e10cSrcweirreadonly        return IDL_READONLY;
304cdf0e10cSrcweirremovable       return IDL_REMOVEABLE;
305cdf0e10cSrcweirservice         return IDL_SERVICE;
306cdf0e10cSrcweirsequence        return IDL_SEQUENCE;
307cdf0e10cSrcweirsingleton       return IDL_SINGLETON;
308cdf0e10cSrcweirstruct          return IDL_STRUCT;
309cdf0e10cSrcweirswitch          return IDL_SWITCH;
310cdf0e10cSrcweirtransient       return IDL_TRANSIENT;
311cdf0e10cSrcweirtypedef         return IDL_TYPEDEF;
312cdf0e10cSrcweirunion           return IDL_UNION;
313cdf0e10cSrcweir
314cdf0e10cSrcweirany             return IDL_ANY;
315cdf0e10cSrcweirboolean         return IDL_BOOLEAN;
316cdf0e10cSrcweirbyte            return IDL_BYTE;
317cdf0e10cSrcweirchar            return IDL_CHAR;
318cdf0e10cSrcweirdouble          return IDL_DOUBLE;
319cdf0e10cSrcweirfloat           return IDL_FLOAT;
320cdf0e10cSrcweirhyper           return IDL_HYPER;
321cdf0e10cSrcweirlong            return IDL_LONG;
322cdf0e10cSrcweirshort           return IDL_SHORT;
323cdf0e10cSrcweirstring          return IDL_STRING;
324cdf0e10cSrcweirtype            return IDL_TYPE;
325cdf0e10cSrcweirunsigned        return IDL_UNSIGNED;
326cdf0e10cSrcweirvoid            return IDL_VOID;
327cdf0e10cSrcweir
328cdf0e10cSrcweirTRUE            return IDL_TRUE;
329cdf0e10cSrcweirTrue            return IDL_TRUE;
330cdf0e10cSrcweirFALSE           return IDL_FALSE;
331cdf0e10cSrcweirFalse           return IDL_FALSE;
332cdf0e10cSrcweir
333cdf0e10cSrcweirin              return IDL_IN;
334cdf0e10cSrcweirout             return IDL_OUT;
335cdf0e10cSrcweirinout           return IDL_INOUT;
336cdf0e10cSrcweironeway          return IDL_ONEWAY;
337cdf0e10cSrcweir
338cdf0e10cSrcweirget             return IDL_GET;
339cdf0e10cSrcweirset             return IDL_SET;
340cdf0e10cSrcweir
341cdf0e10cSrcweirpublished       return IDL_PUBLISHED;
342cdf0e10cSrcweir
343cdf0e10cSrcweir"..."           return IDL_ELLIPSIS;
344cdf0e10cSrcweir
345cdf0e10cSrcweir("-")?{INT_LITERAL}+(l|L|u|U)?    {
346cdf0e10cSrcweir            	return asciiToInteger(yytext, &yylval.ival, &yylval.uval);
347cdf0e10cSrcweir            }
348cdf0e10cSrcweir
349cdf0e10cSrcweir("-")?{OCT_LITERAL}+(l|L|u|U)?    {
350cdf0e10cSrcweir            	return asciiToInteger(yytext, &yylval.ival, &yylval.uval);
351cdf0e10cSrcweir            }
352cdf0e10cSrcweir
353cdf0e10cSrcweir("-")?{HEX_LITERAL}+(l|L|u|U)?    {
354cdf0e10cSrcweir            	return asciiToInteger(yytext, &yylval.ival, &yylval.uval);
355cdf0e10cSrcweir            }
356cdf0e10cSrcweir
357cdf0e10cSrcweir("-")?{DIGIT}+(e|E){1}(("+"|"-")?{DIGIT}+)+(f|F)?	|
358cdf0e10cSrcweir("-")?"."{DIGIT}+((e|E)("+"|"-")?{DIGIT}+)?(f|F)?	|
359cdf0e10cSrcweir("-")?{DIGIT}*"."{DIGIT}+((e|E)("+"|"-")?{DIGIT}+)?(f|F)?        {
360cdf0e10cSrcweir            	yylval.dval = asciiToFloat( yytext );
361cdf0e10cSrcweir				return IDL_FLOATING_PT_LITERAL;
362cdf0e10cSrcweir            }
363cdf0e10cSrcweir
364cdf0e10cSrcweir{IDENTIFIER}	{
365cdf0e10cSrcweir				yylval.sval = new ::rtl::OString(yytext);
366cdf0e10cSrcweir				return IDL_IDENTIFIER;
367cdf0e10cSrcweir			}
368cdf0e10cSrcweir
369cdf0e10cSrcweir\<\<  	{
370cdf0e10cSrcweir		yylval.strval = yytext;
371cdf0e10cSrcweir		return IDL_LEFTSHIFT;
372cdf0e10cSrcweir	}
373cdf0e10cSrcweir\>\>	{
374cdf0e10cSrcweir		yylval.strval = yytext;
375cdf0e10cSrcweir		return IDL_RIGHTSHIFT;
376cdf0e10cSrcweir	}
377cdf0e10cSrcweir\:\:	{
378cdf0e10cSrcweir		yylval.strval = yytext;
379cdf0e10cSrcweir		return IDL_SCOPESEPARATOR;
380cdf0e10cSrcweir	}
381cdf0e10cSrcweir
382cdf0e10cSrcweir"/*"	{
383cdf0e10cSrcweir			BEGIN( COMMENT );
384cdf0e10cSrcweir			docu = ::rtl::OString();
385cdf0e10cSrcweir			beginLine = idlc()->getLineNumber();
386cdf0e10cSrcweir		}
387cdf0e10cSrcweir
388cdf0e10cSrcweir"/***"	{
389cdf0e10cSrcweir			BEGIN( COMMENT );
390cdf0e10cSrcweir			docu = ::rtl::OString();
391cdf0e10cSrcweir			beginLine = idlc()->getLineNumber();
392cdf0e10cSrcweir		}
393cdf0e10cSrcweir
394cdf0e10cSrcweir<COMMENT>[^*]+	{
395cdf0e10cSrcweir				docu += ::rtl::OString(yytext);
396cdf0e10cSrcweir			}
397cdf0e10cSrcweir
398cdf0e10cSrcweir<COMMENT>"*"[^*/]+ 	{
399cdf0e10cSrcweir				docu += ::rtl::OString(yytext);
400cdf0e10cSrcweir			}
401cdf0e10cSrcweir
402cdf0e10cSrcweir<COMMENT>"**" 	{
403cdf0e10cSrcweir				docu += ::rtl::OString(yytext);
404cdf0e10cSrcweir			}
405cdf0e10cSrcweir
406cdf0e10cSrcweir<COMMENT>[*]+"/"  {
407cdf0e10cSrcweir				docu = docu.trim();
408cdf0e10cSrcweir                sal_Int32 nIndex = 0;
409cdf0e10cSrcweir                int count = 0;
410cdf0e10cSrcweir                do { docu.getToken( 0, '\n', nIndex ); count++; } while( nIndex != -1 );
411cdf0e10cSrcweir				idlc()->setLineNumber( beginLine + count - 1);
412cdf0e10cSrcweir			  	BEGIN( INITIAL );
413cdf0e10cSrcweir			}
414cdf0e10cSrcweir
415cdf0e10cSrcweir"/**"	{
416cdf0e10cSrcweir			BEGIN( DOCU );
417cdf0e10cSrcweir			docu = ::rtl::OString();
418cdf0e10cSrcweir			beginLine = idlc()->getLineNumber();
419cdf0e10cSrcweir		}
420cdf0e10cSrcweir
421cdf0e10cSrcweir<DOCU>[^*\n]+	{
422cdf0e10cSrcweir				docu += ::rtl::OString(yytext);
423cdf0e10cSrcweir			}
424cdf0e10cSrcweir
425cdf0e10cSrcweir<DOCU>"\n"[ \t]*"*"{1} 	{
426cdf0e10cSrcweir				idlc()->setLineNumber( idlc()->getLineNumber()  + 1);
427cdf0e10cSrcweir				docu += ::rtl::OString("\n");
428cdf0e10cSrcweir			}
429cdf0e10cSrcweir
430cdf0e10cSrcweir<DOCU>"\n"	{
431cdf0e10cSrcweir				idlc()->setLineNumber( idlc()->getLineNumber()  + 1);
432cdf0e10cSrcweir				docu += ::rtl::OString(yytext);
433cdf0e10cSrcweir			}
434cdf0e10cSrcweir
435cdf0e10cSrcweir<DOCU>"*"[^*^/\n]* 	{
436cdf0e10cSrcweir				docu += ::rtl::OString(yytext);
437cdf0e10cSrcweir			}
438cdf0e10cSrcweir
439cdf0e10cSrcweir<DOCU>"\n"[ \t]*"*/" 	{
440cdf0e10cSrcweir				docu = docu.trim();
441cdf0e10cSrcweir				sal_Int32 nIndex = 0;
442cdf0e10cSrcweir				int count = 0;
443cdf0e10cSrcweir				do { docu.getToken( 0, '\n', nIndex ); count++; } while( nIndex != -1 );
444cdf0e10cSrcweir				idlc()->setLineNumber( beginLine + count - 1);
445cdf0e10cSrcweir				if ( (nIndex = docu.indexOf("/*")) >= 0 || (nIndex = docu.indexOf("///")) >= 0 )
446cdf0e10cSrcweir				{
447cdf0e10cSrcweir                    if ( 0 != nIndex &&
448cdf0e10cSrcweir                         (docu.getStr()[nIndex - 1] != '"' && docu.getStr()[nIndex - 1] != ':') )
449cdf0e10cSrcweir                        idlc()->error()->syntaxError(PS_NoState, idlc()->getLineNumber(),
450cdf0e10cSrcweir                                                     "nested documentation strings are not allowed!");
451cdf0e10cSrcweir				}
452cdf0e10cSrcweir				idlc()->setDocumentation(docu);
453cdf0e10cSrcweir			  	BEGIN( INITIAL );
454cdf0e10cSrcweir			}
455cdf0e10cSrcweir
456cdf0e10cSrcweir<DOCU>"*/"	{
457cdf0e10cSrcweir				docu = docu.trim();
458cdf0e10cSrcweir				sal_Int32 nIndex = 0;
459cdf0e10cSrcweir				int count = 0;
460cdf0e10cSrcweir				do { docu.getToken( 0, '\n', nIndex ); count++; } while( nIndex != -1 );
461cdf0e10cSrcweir				idlc()->setLineNumber( beginLine + count - 1);
462cdf0e10cSrcweir				if ( docu.indexOf("/*") >= 0 || docu.indexOf("//") >= 0 )
463cdf0e10cSrcweir				{
464cdf0e10cSrcweir                    if ( 0 != nIndex &&
465cdf0e10cSrcweir                         (docu.getStr()[nIndex - 1] != '"' && docu.getStr()[nIndex - 1] != ':') )
466cdf0e10cSrcweir                        idlc()->error()->syntaxError(PS_NoState, idlc()->getLineNumber(),
467cdf0e10cSrcweir                                                     "nested documentation strings are not allowed!");
468cdf0e10cSrcweir				}
469cdf0e10cSrcweir				idlc()->setDocumentation(docu);
470cdf0e10cSrcweir			  	BEGIN( INITIAL );
471cdf0e10cSrcweir			}
472cdf0e10cSrcweir
473cdf0e10cSrcweir"//"[^/]{1}.*"\n" {
474cdf0e10cSrcweir				/* only a comment */
475cdf0e10cSrcweir				::rtl::OString docStr(yytext);
476cdf0e10cSrcweir				docStr = docStr.copy( 0, docStr.lastIndexOf('\n') );
477cdf0e10cSrcweir				docStr = docStr.copy( docStr.lastIndexOf('/')+1 );
478cdf0e10cSrcweir				docStr = docStr.trim();
479cdf0e10cSrcweir				idlc()->incLineNumber();
480cdf0e10cSrcweir			}
481cdf0e10cSrcweir
482cdf0e10cSrcweir"///".*"\n"  {
483cdf0e10cSrcweir				::rtl::OString docStr(yytext);
484cdf0e10cSrcweir				docStr = docStr.copy( 0, docStr.lastIndexOf('\n') );
485cdf0e10cSrcweir				docStr = docStr.copy( docStr.lastIndexOf('/')+1 );
486cdf0e10cSrcweir				docStr = docStr.trim();
487cdf0e10cSrcweir				idlc()->incLineNumber();
488cdf0e10cSrcweir				idlc()->setDocumentation(docStr);
489cdf0e10cSrcweir			}
490cdf0e10cSrcweir
491cdf0e10cSrcweir.	return yytext[0];
492cdf0e10cSrcweir
493cdf0e10cSrcweir^#[ \t]*line[ \t]*[0-9]*" ""\""[^\"]*"\""\n    {
494cdf0e10cSrcweir	parseLineAndFile(yytext);
495cdf0e10cSrcweir}
496cdf0e10cSrcweir
497cdf0e10cSrcweir^#[ \t]*[0-9]*" ""\""[^\"]*"\""" "[0-9]*\n {
498cdf0e10cSrcweir	parseLineAndFile(yytext);
499cdf0e10cSrcweir}
500cdf0e10cSrcweir
501cdf0e10cSrcweir^#[ \t]*[0-9]*" ""\""[^\"]*"\""\n {
502cdf0e10cSrcweir	parseLineAndFile(yytext);
503cdf0e10cSrcweir}
504cdf0e10cSrcweir
505cdf0e10cSrcweir^#[ \t]*[0-9]*\n {
506cdf0e10cSrcweir	parseLineAndFile(yytext);
507cdf0e10cSrcweir}
508cdf0e10cSrcweir
509cdf0e10cSrcweir^#[ \t]*ident.*\n {
510cdf0e10cSrcweir	/* ignore cpp ident */
511cdf0e10cSrcweir	idlc()->incLineNumber();
512cdf0e10cSrcweir}
513cdf0e10cSrcweir
514cdf0e10cSrcweir^#[ \t]*pragma[ \t].*\n        {       /* remember pragma */
515cdf0e10cSrcweir	idlParsePragma(yytext);
516cdf0e10cSrcweir	idlc()->incLineNumber();
517cdf0e10cSrcweir}
518cdf0e10cSrcweir
519cdf0e10cSrcweir%%
520