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