1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 %{ 29 #if defined __GNUC__ 30 #pragma GCC system_header 31 #elif defined __SUNPRO_CC 32 #pragma disable_warn 33 #endif 34 %} 35 36 /* Compilerstack */ 37 38 %union { 39 Atom varid; 40 struct { 41 Atom hashid; 42 sal_Int32 nValue; 43 } constname; 44 RscTop * pClass; 45 RSCHEADER header; 46 struct { 47 CLASS_DATA pData; 48 RscTop * pClass; 49 } instance; 50 sal_Int32 value; 51 sal_uInt16 ushort; 52 short exp_short; 53 char * string; 54 sal_Bool svbool; 55 REF_ENUM copyref; 56 RscDefine * defineele; 57 CharSet charset; 58 RscExpType macrostruct; 59 } 60 61 /* Token */ 62 %token <value> NUMBER 63 %token <string> SYMBOL 64 %token <defineele> RSCDEFINE 65 %token <string> STRING 66 %token <string> INCLUDE_STRING 67 %token <character> CHARACTER 68 %token <svbool> BOOLEAN 69 70 %token LINE 71 %token AUTO_ID 72 %token NOT 73 %token XSCALE 74 %token YSCALE 75 %token RGB 76 %token GEOMETRY 77 %token POSITION 78 %token DIMENSION 79 %token INZOOMOUTPUTSIZE 80 %token FLOATINGPOS 81 %token DEFINE 82 %token INCLUDE 83 %token MACROTARGET 84 %token DEFAULT 85 86 87 %token <pClass> CLASSNAME 88 %token <varid> VARNAME 89 %token <constname> CONSTNAME 90 %token CLASS 91 %token EXTENDABLE 92 %token WRITEIFSET 93 94 95 %type <macrostruct> macro_expression 96 %type <macrostruct> id_expression 97 %type <value> long_expression 98 %type <string> string_multiline 99 100 %type <pClass> type 101 %type <pClass> type_base 102 %type <header> class_header_body 103 %type <header> class_header 104 %type <header> var_header_class 105 %type <copyref> copy_ref 106 %type <ushort> type_flags 107 108 109 %left '|' 110 %left '&' 111 %left LEFTSHIFT RIGHTSHIFT 112 %left '+' '-' 113 %left '*' '/' 114 %left UNARYMINUS 115 %left UNARYPLUS 116 %left ',' 117 %left '(' ')' 118 119 120 /* Grammatik */ 121 122 %start resource_definitions 123 124 %% 125 126 /********************** D E F I N I T I O N S ****************************/ 127 resource_definitions 128 : 129 | resource_definitions resource_definition 130 | MACROTARGET macro_expression 131 { 132 RscExpType aExpType; 133 sal_Int32 lValue; 134 135 aExpType.cType = RSCEXP_NOTHING; 136 pExp = new RscExpression( aExpType, '+', $2 ); 137 if( !pExp->Evaluate( &lValue ) ) 138 pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() ); 139 } 140 ; 141 142 resource_definition 143 : line_number 144 | '#' DEFINE SYMBOL macro_expression 145 { 146 sal_Bool bError = sal_False; 147 148 if( $4.IsNumber() ){ 149 if( !pTC->aFileTab.NewDef( pFI->GetFileIndex(), 150 ByteString( $3 ), 151 $4.GetLong(), LIST_APPEND ) ) 152 bError = sal_True; 153 } 154 else if( $4.IsDefinition() ){ 155 RscExpType aExpType; 156 RscExpression * pExpr; 157 158 aExpType.cType = RSCEXP_NOTHING; 159 aExpType.SetLong( 0 ); 160 aExpType.cType = RSCEXP_LONG; 161 pExpr = new RscExpression( aExpType, '+', $4 ); 162 163 if( !pTC->aFileTab.NewDef( pFI->GetFileIndex(), 164 ByteString( $3 ), pExpr, LIST_APPEND ) ) 165 bError = sal_True; 166 } 167 else if( $4.IsExpression() ){ 168 if( !pTC->aFileTab.NewDef( pFI->GetFileIndex(), 169 ByteString( $3 ), $4.aExp.pExp, 170 LIST_APPEND ) ) 171 bError = sal_True; 172 } 173 174 if( bError ){ 175 pTC->pEH->Error( ERR_DECLAREDEFINE, NULL, RscId(), $3 ); 176 } 177 } 178 | '#' DEFINE RSCDEFINE macro_expression 179 { 180 pTC->pEH->Error( ERR_DOUBLEDEFINE, NULL, RscId(), $3->GetName().GetBuffer() ); 181 } 182 | '#' INCLUDE STRING 183 { 184 } 185 | '#' INCLUDE INCLUDE_STRING 186 { 187 } 188 | class_definition ';' 189 { 190 #ifdef D40 191 void * pMem; 192 pMem = rtl_allocateMemory( 20000 ); 193 rtl_freeMemory( pMem ); 194 #endif 195 } 196 | new_class_definition_header '{' new_class_definition_body '}' ';' 197 | new_class_definition_header ';' 198 ; 199 200 new_class_definition_header 201 : CLASS SYMBOL id_expression ':' CLASSNAME 202 { 203 sal_Int32 lType; 204 205 $3.Evaluate( &lType ); 206 207 // Klasse anlegen 208 Atom nId = pHS->getID( $2 ); 209 pCurClass = new RscClass( nId, lType, $5 ); 210 nCurMask = 1; 211 pTC->aNmTb.Put( nId, CLASSNAME, pCurClass ); 212 pTC->GetRoot()->Insert( pCurClass ); 213 } 214 | CLASS CLASSNAME id_expression ':' CLASSNAME 215 { 216 pCurClass = $2; 217 nCurMask = 1; 218 } 219 ; 220 221 new_class_definition_body 222 : 223 | property_definition ';' new_class_definition_body 224 ; 225 226 property_definition 227 : type_flags type SYMBOL 228 { 229 // Variable anlegen 230 Atom nId = pTC->aNmTb.Put( $3, VARNAME ); 231 pCurClass->SetVariable( nId, $2, NULL, $1, nCurMask ); 232 nCurMask <<= 1; 233 } 234 | type_flags type VARNAME 235 { 236 pCurClass->SetVariable( $3, $2, NULL, $1, nCurMask ); 237 nCurMask <<= 1; 238 } 239 ; 240 241 type_flags 242 : type_flags EXTENDABLE 243 { 244 $$ = $1 | VAR_EXTENDABLE; 245 } 246 | type_flags WRITEIFSET 247 { 248 $$ = $1 | VAR_SVDYNAMIC; 249 } 250 | 251 { 252 $$ = 0; 253 } 254 ; 255 256 type 257 : type_base 258 { 259 $$ = $1; 260 } 261 | type_base '[' ']' 262 { 263 if( $1 ) 264 { 265 ByteString aTypeName = pHS->getString( $1->GetId() ); 266 aTypeName += "[]"; 267 $$ = pTC->SearchType( pHS->getID( aTypeName.GetBuffer(), true ) ); 268 if( !$$ ) 269 { 270 RscCont * pCont; 271 pCont = new RscCont( pHS->getID( aTypeName.GetBuffer() ), RSC_NOTYPE ); 272 pCont->SetTypeClass( $1 ); 273 pTC->InsertType( pCont ); 274 $$ = pCont; 275 } 276 } 277 else 278 $$ = NULL; 279 } 280 ; 281 282 type_base 283 : CLASSNAME 284 { 285 $$ = $1; 286 } 287 | SYMBOL 288 { 289 RscTop * pType = pTC->SearchType( pHS->getID( $1, true ) ); 290 if( !pType ) 291 pTC->pEH->Error( ERR_NOTYPE, pCurClass, RscId() ); 292 $$ = pType; 293 } 294 ; 295 296 class_definition 297 : class_header class_body 298 { 299 if( TYPE_REF == $1.nTyp ) 300 pTC->pEH->Error( ERR_REFNOTALLOWED, S.Top().pClass, 301 RscId( $1.nName1 ) ); 302 S.Pop(); 303 } 304 | class_header 305 { 306 ERRTYPE aError; 307 RscId aRscId( $1.nName1 ); 308 309 if( TYPE_NOTHING == $1.nTyp && aRscId.IsId() ) 310 aError = S.Top().pClass->SetRef( S.Top(), aRscId ); 311 else if( TYPE_COPY == $1.nTyp ) 312 aError = ERR_COPYNOTALLOWED; 313 if( aError.IsError() || aError.IsWarning() ) 314 pTC->pEH->Error( aError, S.Top().pClass, aRscId ); 315 S.Pop(); 316 } 317 ; 318 319 class_header 320 : class_header_body 321 { 322 if( !DoClassHeader( &$1, sal_False ) ) 323 return( ERR_ERROR ); 324 $$ = $1; 325 } 326 ; 327 328 copy_ref 329 : '<' 330 { 331 $$ = TYPE_COPY; 332 } 333 | ',' 334 { 335 $$ = TYPE_REF; 336 } 337 ; 338 339 class_header_body 340 : CLASSNAME id_expression copy_ref CLASSNAME id_expression 341 { 342 $$.pClass = $1; 343 $$.nName1 = $2; 344 $$.nTyp = $3; 345 $$.pRefClass = $4; 346 $$.nName2 = $5; 347 } 348 | CLASSNAME id_expression copy_ref id_expression 349 { 350 $$.pClass = $1; 351 $$.nName1 = $2; 352 $$.nTyp = $3; 353 $$.pRefClass = NULL; 354 $$.nName2 = $4; 355 } 356 | CLASSNAME id_expression 357 { 358 $$.pClass = $1; 359 $$.nName1 = $2; 360 $$.nTyp = TYPE_NOTHING; 361 $$.pRefClass = NULL; 362 $$.nName2.cType = RSCEXP_NOTHING; 363 } 364 | CLASSNAME copy_ref id_expression 365 { 366 $$.pClass = $1; 367 $$.nName1.cType = RSCEXP_NOTHING; 368 $$.nTyp = $2; 369 $$.pRefClass = NULL; 370 $$.nName2 = $3; 371 } 372 | CLASSNAME copy_ref CLASSNAME id_expression 373 { 374 $$.pClass = $1; 375 $$.nName1.cType = RSCEXP_NOTHING; 376 $$.nTyp = $2; 377 $$.pRefClass = $3; 378 $$.nName2 = $4; 379 } 380 | CLASSNAME 381 { 382 $$.pClass = $1; 383 $$.nName1.cType = RSCEXP_NOTHING; 384 $$.nTyp = TYPE_NOTHING; 385 $$.nName2.cType = RSCEXP_NOTHING; 386 } 387 ; 388 389 class_body 390 : '{' var_definitions '}' 391 | '{' '}' 392 | string_multiline 393 { 394 SetString( S.Top(), "TEXT", $1 ); 395 } 396 ; 397 398 var_definitions 399 : var_definition 400 | var_definitions var_definition 401 ; 402 403 xy_mapmode 404 : CONSTNAME 405 { 406 SetConst( S.Top(), "_XYMAPMODE", $1.hashid, $1.nValue ); 407 } 408 | 409 ; 410 411 wh_mapmode 412 : CONSTNAME 413 { 414 SetConst( S.Top(), "_WHMAPMODE", $1.hashid, $1.nValue ); 415 } 416 | 417 ; 418 419 xywh_mapmode 420 : CONSTNAME 421 { 422 SetConst( S.Top(), "_XYMAPMODE", $1.hashid, $1.nValue ); 423 SetConst( S.Top(), "_WHMAPMODE", $1.hashid, $1.nValue ); 424 } 425 | 426 ; 427 428 var_definition 429 : line_number 430 | var_header var_body ';' 431 { 432 S.Pop(); 433 } 434 | class_definition ';' 435 | var_header_class class_body ';' 436 { 437 if( TYPE_REF == $1.nTyp ) 438 pTC->pEH->Error( ERR_REFNOTALLOWED, S.Top().pClass, 439 RscId( $1.nName1 ) ); 440 441 if( S.Top().pClass->GetCount( S.Top() ) ) 442 pTC->pEH->Error( WRN_SUBINMEMBER, S.Top().pClass, 443 RscId( $1.nName1 ) ); 444 445 S.Pop(); 446 } 447 | var_header_class ';' 448 { 449 ERRTYPE aError; 450 RscId aRscId( $1.nName1 ); 451 452 if( TYPE_NOTHING == $1.nTyp && aRscId.IsId() ) 453 aError = S.Top().pClass->SetRef( S.Top(), aRscId ); 454 else if( TYPE_COPY == $1.nTyp ) 455 aError = ERR_COPYNOTALLOWED; 456 if( S.Top().pClass->GetCount( S.Top() ) ) 457 aError = WRN_SUBINMEMBER; 458 if( aError.IsError() || aError.IsWarning() ) 459 pTC->pEH->Error( aError, S.Top().pClass, aRscId ); 460 461 S.Pop(); 462 } 463 | XSCALE '=' '(' long_expression ',' long_expression ')' ';' 464 { 465 SetNumber( S.Top(), "_XNUMERATOR", $4 ); 466 SetNumber( S.Top(), "_XDENOMINATOR", $6 ); 467 } 468 | YSCALE '=' '(' long_expression ',' long_expression ')' ';' 469 { 470 SetNumber( S.Top(), "_YNUMERATOR", $4 ); 471 SetNumber( S.Top(), "_YDENOMINATOR", $6 ); 472 } 473 | RGB '=' '(' long_expression ',' long_expression 474 ',' long_expression ')' ';' 475 { 476 SetNumber( S.Top(), "RED", $4 ); 477 SetNumber( S.Top(), "GREEN", $6 ); 478 SetNumber( S.Top(), "BLUE", $8 ); 479 } 480 | GEOMETRY '=' xywh_mapmode '(' long_expression ',' long_expression ',' 481 long_expression ',' long_expression ')' ';' 482 { 483 SetNumber( S.Top(), "_X", $5 ); 484 SetNumber( S.Top(), "_Y", $7 ); 485 SetNumber( S.Top(), "_WIDTH", $9 ); 486 SetNumber( S.Top(), "_HEIGHT", $11 ); 487 } 488 | POSITION '=' xy_mapmode '(' long_expression ',' long_expression 489 ')' ';' 490 { 491 SetNumber( S.Top(), "_X", $5 ); 492 SetNumber( S.Top(), "_Y", $7 ); 493 } 494 | DIMENSION '=' wh_mapmode '(' long_expression ',' long_expression 495 ')' ';' 496 { 497 SetNumber( S.Top(), "_WIDTH", $5 ); 498 SetNumber( S.Top(), "_HEIGHT", $7 ); 499 } 500 | INZOOMOUTPUTSIZE '=' CONSTNAME '(' long_expression ',' long_expression 501 ')' ';' 502 { 503 SetConst( S.Top(), "_ZOOMINMAPMODE", $3.hashid, $3.nValue ); 504 SetNumber( S.Top(), "_ZOOMINWIDTH", $5 ); 505 SetNumber( S.Top(), "_ZOOMINHEIGHT", $7 ); 506 } 507 | INZOOMOUTPUTSIZE '=' '(' long_expression ',' long_expression ')' ';' 508 { 509 SetNumber( S.Top(), "_ZOOMINWIDTH", $4 ); 510 SetNumber( S.Top(), "_ZOOMINHEIGHT", $6 ); 511 } 512 | FLOATINGPOS '=' CONSTNAME '(' long_expression ',' long_expression 513 ')' ';' 514 { 515 SetConst( S.Top(), "_FLOATINGPOSMAPMODE", $3.hashid, $3.nValue ); 516 SetNumber( S.Top(), "_FLOATINGPOSX", $5 ); 517 SetNumber( S.Top(), "_FLOATINGPOSY", $7 ); 518 } 519 | FLOATINGPOS '=' '(' long_expression ',' long_expression ')' ';' 520 { 521 SetNumber( S.Top(), "_FLOATINGPOSX", $4 ); 522 SetNumber( S.Top(), "_FLOATINGPOSY", $6 ); 523 } 524 ; 525 526 var_header_class 527 : VARNAME '=' class_header_body 528 { 529 RSCINST aInst; 530 531 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST(), sal_False, $3.pClass ); 532 533 if( aInst.pData ) 534 S.Push( aInst ); 535 else 536 { 537 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), 538 pHS->getString( $1 ) ); 539 return( ERR_ERROR ); 540 }; 541 542 if( !DoClassHeader( &$3, sal_True ) ) 543 return( ERR_ERROR ); 544 $$ = $3; 545 } 546 | VARNAME '[' CONSTNAME ']' '=' class_header_body 547 { 548 RSCINST aInst; 549 550 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); 551 552 if( aInst.pData ) 553 { 554 ERRTYPE aError; 555 RSCINST aIdxInst; 556 557 aError = aInst.pClass->GetArrayEle( aInst, $3.hashid, NULL, &aIdxInst ); 558 if( aError.IsError() || aError.IsWarning() ) 559 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 560 if( aError.IsError() ) 561 return( ERR_ERROR ); 562 S.Push( aIdxInst ); 563 } 564 else 565 { 566 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), 567 pHS->getString( $1 ) ); 568 return( ERR_ERROR ); 569 }; 570 if( !DoClassHeader( &$6, sal_True ) ) 571 return( ERR_ERROR ); 572 $$ = $6; 573 } 574 | VARNAME '[' SYMBOL ']' '=' class_header_body 575 { 576 RSCINST aInst; 577 578 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); 579 580 if( aInst.pData ) 581 { 582 long nNewLang = pTC->AddLanguage( $3 ); 583 ERRTYPE aError; 584 RSCINST aIdxInst; 585 586 aError = aInst.pClass->GetArrayEle( aInst, nNewLang, NULL, &aIdxInst ); 587 if( aError.IsError() || aError.IsWarning() ) 588 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 589 if( aError.IsError() ) 590 return( ERR_ERROR ); 591 S.Push( aIdxInst ); 592 } 593 else 594 { 595 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), 596 pHS->getString( $1 ) ); 597 return( ERR_ERROR ); 598 }; 599 if( !DoClassHeader( &$6, sal_True ) ) 600 return( ERR_ERROR ); 601 $$ = $6; 602 } 603 ; 604 605 var_header 606 : VARNAME '=' 607 { 608 RSCINST aInst; 609 610 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); 611 612 if( aInst.pData ) 613 S.Push( aInst ); 614 else{ 615 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), 616 pHS->getString( $1 ) ); 617 return( ERR_ERROR ); 618 }; 619 } 620 | VARNAME '[' CONSTNAME ']' '=' 621 { 622 RSCINST aInst; 623 624 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); 625 626 if( aInst.pData ) 627 { 628 ERRTYPE aError; 629 RSCINST aIdxInst; 630 631 aError = aInst.pClass->GetArrayEle( aInst, $3.hashid, NULL, &aIdxInst ); 632 if( aError.IsError() || aError.IsWarning() ) 633 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 634 if( aError.IsError() ) 635 return( ERR_ERROR ); 636 S.Push( aIdxInst ); 637 } 638 else{ 639 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), 640 pHS->getString( $1 ) ); 641 return( ERR_ERROR ); 642 }; 643 } 644 | VARNAME '[' SYMBOL ']' '=' 645 { 646 RSCINST aInst; 647 648 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); 649 650 if( aInst.pData ) 651 { 652 long nNewLang = pTC->AddLanguage( $3 ); 653 ERRTYPE aError; 654 RSCINST aIdxInst; 655 656 aError = aInst.pClass->GetArrayEle( aInst, nNewLang, NULL, &aIdxInst ); 657 if( aError.IsError() || aError.IsWarning() ) 658 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 659 if( aError.IsError() ) 660 return( ERR_ERROR ); 661 S.Push( aIdxInst ); 662 } 663 else{ 664 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), 665 pHS->getString( $1 ) ); 666 return( ERR_ERROR ); 667 }; 668 } 669 ; 670 tupel_header0 671 : 672 { 673 RSCINST aInst; 674 675 aInst = S.Top().pClass->GetTupelVar( S.Top(), 0, RSCINST() ); 676 if( aInst.pData ) 677 S.Push( aInst ); 678 else 679 { 680 pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); 681 return( ERR_ERROR ); 682 }; 683 } 684 ; 685 686 tupel_header1 687 : 688 { 689 RSCINST aInst; 690 691 aInst = S.Top().pClass->GetTupelVar( S.Top(), 1, RSCINST() ); 692 if( aInst.pData ) 693 S.Push( aInst ); 694 else 695 { 696 pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); 697 return( ERR_ERROR ); 698 }; 699 } 700 ; 701 702 tupel_header2 703 : 704 { 705 RSCINST aInst; 706 707 aInst = S.Top().pClass->GetTupelVar( S.Top(), 2, RSCINST() ); 708 if( aInst.pData ) 709 S.Push( aInst ); 710 else 711 { 712 pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); 713 return( ERR_ERROR ); 714 }; 715 } 716 ; 717 718 tupel_header3 719 : 720 { 721 RSCINST aInst; 722 723 aInst = S.Top().pClass->GetTupelVar( S.Top(), 3, RSCINST() ); 724 if( !aInst.pData ) 725 { 726 pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); 727 return( ERR_ERROR ); 728 }; 729 S.Push( aInst ); 730 } 731 ; 732 733 tupel_body 734 : var_body 735 { 736 S.Pop(); 737 } 738 ; 739 740 var_list_header 741 : 742 { 743 ERRTYPE aError; 744 RSCINST aInst; 745 746 aError = S.Top().pClass->GetElement( S.Top(), RscId(), 747 NULL, RSCINST(), &aInst ); 748 if( aError.IsError() || aError.IsWarning() ) 749 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 750 if( aError.IsError() ) 751 { // unbedingt Instanz auf den Stack bringen 752 aInst = S.Top().pClass->Create( NULL, RSCINST() ); 753 } 754 S.Push( aInst ); 755 } 756 ; 757 758 list_body 759 : var_bodycomplex 760 { 761 S.Pop(); 762 } 763 ; 764 765 list_header 766 : 767 { 768 sal_uInt32 nCount = S.Top().pClass->GetCount( S.Top() ); 769 sal_uInt32 i; 770 771 for( i = nCount; i > 0; i-- ) 772 S.Top().pClass->DeletePos( S.Top(), i -1 ); 773 } 774 ; 775 776 list 777 : list var_list_header list_body ';' 778 | list var_bodysimple ';' 779 | list class_definition ';' 780 | list line_number 781 | 782 ; 783 784 var_bodysimple 785 : macro_expression 786 { 787 sal_Int32 l; 788 ERRTYPE aError; 789 790 if( !$1.Evaluate( &l ) ) 791 pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() ); 792 else 793 { 794 aError = S.Top().pClass->SetRef( S.Top(), RscId( $1 ) ); 795 if( aError.IsError() ) 796 { 797 aError.Clear(); 798 aError = S.Top().pClass->SetNumber( S.Top(), l ); 799 } 800 if( aError.IsError() ) 801 { // Aufwaertskompatible, Tupel probieren 802 RSCINST aInst = GetFirstTupelEle( S.Top() ); 803 if( aInst.pData ) 804 { 805 aError.Clear(); // Fehler zuruecksetzen 806 aError = aInst.pClass->SetRef( aInst, RscId( $1 ) ); 807 if( aError.IsError() ) 808 { 809 aError.Clear(); 810 aError = aInst.pClass->SetNumber( aInst, l ); 811 } 812 } 813 } 814 } 815 816 if( $1.IsExpression() ) 817 delete $1.aExp.pExp; 818 819 if( aError.IsError() || aError.IsWarning() ) 820 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 821 } 822 | CONSTNAME 823 { 824 ERRTYPE aError; 825 aError = S.Top().pClass->SetConst( S.Top(), $1.hashid, $1.nValue ); 826 if( aError.IsError() ) 827 { // Aufwaertskompatible, Tupel probieren 828 RSCINST aInst = GetFirstTupelEle( S.Top() ); 829 if( aInst.pData ) 830 { 831 aError.Clear(); // Fehler zuruecksetzen 832 aError = aInst.pClass->SetConst( aInst, $1.hashid, $1.nValue ); 833 } 834 } 835 836 if( aError.IsError() || aError.IsWarning() ) 837 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 838 } 839 | NOT CONSTNAME 840 { 841 ERRTYPE aError; 842 aError = S.Top().pClass->SetNotConst( S.Top(), $2.hashid ); 843 if( aError.IsError() ) 844 { // Aufwaertskompatible, Tupel probieren 845 RSCINST aInst = GetFirstTupelEle( S.Top() ); 846 if( aInst.pData ) 847 { 848 aError.Clear(); // Fehler zuruecksetzen 849 aError = aInst.pClass->SetNotConst( aInst, $2.hashid ); 850 } 851 } 852 853 if( aError.IsError() || aError.IsWarning() ) 854 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 855 } 856 | BOOLEAN 857 { 858 ERRTYPE aError; 859 aError = S.Top().pClass->SetBool( S.Top(), $1 ); 860 if( aError.IsError() ) 861 { // Aufwaertskompatible, Tupel probieren 862 RSCINST aInst = GetFirstTupelEle( S.Top() ); 863 if( aInst.pData ) 864 { 865 aError.Clear(); // Fehler zuruecksetzen 866 aError = aInst.pClass->SetBool( aInst, $1 ); 867 } 868 } 869 870 if( aError.IsError() || aError.IsWarning() ) 871 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 872 } 873 | string_multiline 874 { 875 ERRTYPE aError; 876 aError = S.Top().pClass->SetString( S.Top(), $1 ); 877 if( aError.IsError() ) 878 { // Aufwaertskompatible, Tupel probieren 879 RSCINST aInst = GetFirstTupelEle( S.Top() ); 880 if( aInst.pData ) 881 { 882 aError.Clear(); // Fehler zuruecksetzen 883 aError = aInst.pClass->SetString( aInst, $1 ); 884 } 885 } 886 887 if( aError.IsError() || aError.IsWarning() ) 888 pTC->pEH->Error( aError, S.Top().pClass, RscId() ); 889 } 890 | DEFAULT 891 ; 892 893 var_bodycomplex 894 : '{' list_header list '}' 895 | '<' tupel_header0 tupel_body ';' '>' 896 | '<' tupel_header0 tupel_body ';' tupel_header1 tupel_body ';' '>' 897 | '<' tupel_header0 tupel_body ';' tupel_header1 tupel_body ';' 898 tupel_header2 tupel_body ';' '>' 899 | '<' tupel_header0 tupel_body ';' tupel_header1 tupel_body ';' 900 tupel_header2 tupel_body ';' tupel_header3 tupel_body ';' '>' 901 ; 902 903 var_body 904 : var_bodysimple 905 | var_bodycomplex 906 ; 907 908 /********************** work on yacc stack *******************************/ 909 string_multiline 910 : STRING 911 { 912 $$ = $1; 913 } 914 | string_multiline STRING 915 { 916 rtl::OStringBuffer aBuf( 256 ); 917 aBuf.append( $1 ); 918 aBuf.append( $2 ); 919 $$ = (char*)pStringContainer->putString( aBuf.getStr() ); 920 } 921 ; 922 923 long_expression 924 : macro_expression 925 { 926 if( !$1.Evaluate( &$$ ) ) 927 pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() ); 928 if( $1.IsExpression() ) 929 delete $1.aExp.pExp; 930 } 931 ; 932 933 macro_expression 934 : RSCDEFINE 935 { 936 $$.cType = RSCEXP_DEF; 937 $$.aExp.pDef = $1; 938 } 939 | NUMBER 940 { 941 $$.cType = RSCEXP_LONG; 942 $$.SetLong( $1 ); 943 } 944 | '-' macro_expression %prec UNARYMINUS 945 { 946 if( $2.IsNumber() ){ 947 $$.cType = $2.cType; 948 $$.SetLong( - $2.GetLong() ); 949 } 950 else{ 951 RscExpType aLeftExp; 952 953 aLeftExp.cType = RSCEXP_NOTHING; 954 $$.cType = RSCEXP_EXP; 955 $$.aExp.pExp = new RscExpression( aLeftExp, '-', $2 ); 956 } 957 } 958 | '+' macro_expression %prec UNARYPLUS 959 { 960 $$ = $2; 961 } 962 | macro_expression '+' macro_expression 963 { 964 if( $1.IsNumber() && $3.IsNumber() ){ 965 $$.cType = RSCEXP_LONG; 966 $$.SetLong( $1.GetLong() + $3.GetLong() ); 967 } 968 else{ 969 $$.cType = RSCEXP_EXP; 970 $$.aExp.pExp = new RscExpression( $1, '+', $3 ); 971 } 972 } 973 | macro_expression '-' macro_expression 974 { 975 if( $1.IsNumber() && $3.IsNumber() ){ 976 $$.cType = RSCEXP_LONG; 977 $$.SetLong( $1.GetLong() - $3.GetLong() ); 978 } 979 else{ 980 $$.cType = RSCEXP_EXP; 981 $$.aExp.pExp = new RscExpression( $1, '-', $3 ); 982 } 983 } 984 | macro_expression '*' macro_expression 985 { 986 if( $1.IsNumber() && $3.IsNumber() ){ 987 $$.cType = RSCEXP_LONG; 988 $$.SetLong( $1.GetLong() * $3.GetLong() ); 989 } 990 else{ 991 $$.cType = RSCEXP_EXP; 992 $$.aExp.pExp = new RscExpression( $1, '*', $3 ); 993 } 994 } 995 | macro_expression '/' macro_expression 996 { 997 if( $1.IsNumber() && $3.IsNumber() ){ 998 if( 0 == $3.GetLong() ){ 999 $$.cType = RSCEXP_EXP; 1000 $$.aExp.pExp = new RscExpression( $1, '/', $3 ); 1001 } 1002 else{ 1003 $$.cType = RSCEXP_LONG; 1004 $$.SetLong( $1.GetLong() / $3.GetLong() ); 1005 } 1006 } 1007 else{ 1008 $$.cType = RSCEXP_EXP; 1009 $$.aExp.pExp = new RscExpression( $1, '/', $3 ); 1010 } 1011 } 1012 | macro_expression '&' macro_expression 1013 { 1014 if( $1.IsNumber() && $3.IsNumber() ){ 1015 $$.cType = RSCEXP_LONG; 1016 $$.SetLong( $1.GetLong() & $3.GetLong() ); 1017 } 1018 else{ 1019 $$.cType = RSCEXP_EXP; 1020 $$.aExp.pExp = new RscExpression( $1, '&', $3 ); 1021 } 1022 } 1023 | macro_expression '|' macro_expression 1024 { 1025 if( $1.IsNumber() && $3.IsNumber() ){ 1026 $$.cType = RSCEXP_LONG; 1027 $$.SetLong( $1.GetLong() | $3.GetLong() ); 1028 } 1029 else{ 1030 $$.cType = RSCEXP_EXP; 1031 $$.aExp.pExp = new RscExpression( $1, '|', $3 ); 1032 } 1033 } 1034 | '(' macro_expression ')' 1035 { 1036 $$ = $2; 1037 } 1038 | macro_expression LEFTSHIFT macro_expression 1039 { 1040 if( $1.IsNumber() && $3.IsNumber() ){ 1041 $$.cType = RSCEXP_LONG; 1042 $$.SetLong( $1.GetLong() << $3.GetLong() ); 1043 } 1044 else{ 1045 $$.cType = RSCEXP_EXP; 1046 $$.aExp.pExp = new RscExpression( $1, 'l', $3 ); 1047 } 1048 } 1049 | macro_expression RIGHTSHIFT macro_expression 1050 { 1051 if( $1.IsNumber() && $3.IsNumber() ){ 1052 $$.cType = RSCEXP_LONG; 1053 $$.SetLong( $1.GetLong() >> $3.GetLong() ); 1054 } 1055 else{ 1056 $$.cType = RSCEXP_EXP; 1057 $$.aExp.pExp = new RscExpression( $1, 'r', $3 ); 1058 } 1059 } 1060 ; 1061 1062 id_expression 1063 : id_expression line_number 1064 | macro_expression 1065 { // pExpession auswerten und loeschen 1066 if( RSCEXP_EXP == $1.cType ){ 1067 sal_Int32 lValue; 1068 1069 if( !$1.Evaluate( &lValue ) ) 1070 pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() ); 1071 delete $1.aExp.pExp; 1072 $$.cType = RSCEXP_LONG; 1073 $$.SetLong( lValue ); 1074 } 1075 else 1076 $$ = $1; 1077 } 1078 ; 1079 1080 DUMMY_NUMBER 1081 : NUMBER 1082 { 1083 } 1084 | 1085 { 1086 } 1087 ; 1088 1089 line_number 1090 : '#' LINE NUMBER STRING 1091 { 1092 RscFile * pFName; 1093 1094 pFI->SetLineNo( $3 ); 1095 pFI->SetFileIndex( pTC->aFileTab.NewCodeFile( ByteString( $4 ) ) ); 1096 pFName = pTC->aFileTab.Get( pFI->GetFileIndex() ); 1097 pFName->bLoaded = sal_True; 1098 pFName->bScanned = sal_True; 1099 } 1100 | '#' NUMBER STRING DUMMY_NUMBER 1101 { 1102 RscFile * pFName; 1103 1104 pFI->SetLineNo( $2 ); 1105 pFI->SetFileIndex( pTC->aFileTab.NewCodeFile( ByteString( $3 ) ) ); 1106 pFName = pTC->aFileTab.Get( pFI->GetFileIndex() ); 1107 pFName->bLoaded = sal_True; 1108 pFName->bScanned = sal_True; 1109 } 1110 | '#' NUMBER 1111 { 1112 pFI->SetLineNo( $2 ); 1113 } 1114 ; 1115 1116 1117 1118 1119