merge the formfield patch from ooo-build
[ooovba.git] / rsc / source / parser / rscyacc.y
blob032e775177999d661986cfe4ece3ab852f42b95a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: header.hxx,v $
10 * $Revision: 1.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #if defined __GNUC__
33 #pragma GCC system_header
34 #elif defined __SUNPRO_CC
35 #pragma disable_warn
36 #endif
39 /* Compilerstack */
41 %union {
42 Atom varid;
43 struct {
44 Atom hashid;
45 INT32 nValue;
46 } constname;
47 RscTop * pClass;
48 RSCHEADER header;
49 struct {
50 CLASS_DATA pData;
51 RscTop * pClass;
52 } instance;
53 INT32 value;
54 USHORT ushort;
55 short exp_short;
56 char * string;
57 BOOL svbool;
58 REF_ENUM copyref;
59 RscDefine * defineele;
60 CharSet charset;
61 RscExpType macrostruct;
64 /* Token */
65 %token <value> NUMBER
66 %token <string> SYMBOL
67 %token <defineele> RSCDEFINE
68 %token <string> STRING
69 %token <string> INCLUDE_STRING
70 %token <character> CHARACTER
71 %token <svbool> BOOLEAN
73 %token LINE
74 %token AUTO_ID
75 %token NOT
76 %token XSCALE
77 %token YSCALE
78 %token RGB
79 %token GEOMETRY
80 %token POSITION
81 %token DIMENSION
82 %token INZOOMOUTPUTSIZE
83 %token FLOATINGPOS
84 %token DEFINE
85 %token INCLUDE
86 %token MACROTARGET
87 %token DEFAULT
90 %token <pClass> CLASSNAME
91 %token <varid> VARNAME
92 %token <constname> CONSTNAME
93 %token CLASS
94 %token EXTENDABLE
95 %token WRITEIFSET
98 %type <macrostruct> macro_expression
99 %type <macrostruct> id_expression
100 %type <value> long_expression
101 %type <string> string_multiline
103 %type <pClass> type
104 %type <pClass> type_base
105 %type <header> class_header_body
106 %type <header> class_header
107 %type <header> var_header_class
108 %type <copyref> copy_ref
109 %type <ushort> type_flags
112 %left '|'
113 %left '&'
114 %left LEFTSHIFT RIGHTSHIFT
115 %left '+' '-'
116 %left '*' '/'
117 %left UNARYMINUS
118 %left UNARYPLUS
119 %left ','
120 %left '(' ')'
123 /* Grammatik */
125 %start resource_definitions
129 /********************** D E F I N I T I O N S ****************************/
130 resource_definitions
132 | resource_definitions resource_definition
133 | MACROTARGET macro_expression
135 RscExpType aExpType;
136 INT32 lValue;
138 aExpType.cType = RSCEXP_NOTHING;
139 pExp = new RscExpression( aExpType, '+', $2 );
140 if( !pExp->Evaluate( &lValue ) )
141 pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() );
145 resource_definition
146 : line_number
147 | '#' DEFINE SYMBOL macro_expression
149 BOOL bError = FALSE;
151 if( $4.IsNumber() ){
152 if( !pTC->aFileTab.NewDef( pFI->GetFileIndex(),
153 ByteString( $3 ),
154 $4.GetLong(), LIST_APPEND ) )
155 bError = TRUE;
157 else if( $4.IsDefinition() ){
158 RscExpType aExpType;
159 RscExpression * pExpr;
161 aExpType.cType = RSCEXP_NOTHING;
162 aExpType.SetLong( 0 );
163 aExpType.cType = RSCEXP_LONG;
164 pExpr = new RscExpression( aExpType, '+', $4 );
166 if( !pTC->aFileTab.NewDef( pFI->GetFileIndex(),
167 ByteString( $3 ), pExpr, LIST_APPEND ) )
168 bError = TRUE;
170 else if( $4.IsExpression() ){
171 if( !pTC->aFileTab.NewDef( pFI->GetFileIndex(),
172 ByteString( $3 ), $4.aExp.pExp,
173 LIST_APPEND ) )
174 bError = TRUE;
177 if( bError ){
178 pTC->pEH->Error( ERR_DECLAREDEFINE, NULL, RscId(), $3 );
181 | '#' DEFINE RSCDEFINE macro_expression
183 pTC->pEH->Error( ERR_DOUBLEDEFINE, NULL, RscId(), $3->GetName().GetBuffer() );
185 | '#' INCLUDE STRING
188 | '#' INCLUDE INCLUDE_STRING
191 | class_definition ';'
193 #ifdef D40
194 void * pMem;
195 pMem = rtl_allocateMemory( 20000 );
196 rtl_freeMemory( pMem );
197 #endif
199 | new_class_definition_header '{' new_class_definition_body '}' ';'
200 | new_class_definition_header ';'
203 new_class_definition_header
204 : CLASS SYMBOL id_expression ':' CLASSNAME
206 INT32 lType;
208 $3.Evaluate( &lType );
210 // Klasse anlegen
211 Atom nId = pHS->getID( $2 );
212 pCurClass = new RscClass( nId, lType, $5 );
213 nCurMask = 1;
214 pTC->aNmTb.Put( nId, CLASSNAME, pCurClass );
215 pTC->GetRoot()->Insert( pCurClass );
217 | CLASS CLASSNAME id_expression ':' CLASSNAME
219 pCurClass = $2;
220 nCurMask = 1;
224 new_class_definition_body
226 | property_definition ';' new_class_definition_body
229 property_definition
230 : type_flags type SYMBOL
232 // Variable anlegen
233 Atom nId = pTC->aNmTb.Put( $3, VARNAME );
234 pCurClass->SetVariable( nId, $2, NULL, $1, nCurMask );
235 nCurMask <<= 1;
237 | type_flags type VARNAME
239 pCurClass->SetVariable( $3, $2, NULL, $1, nCurMask );
240 nCurMask <<= 1;
244 type_flags
245 : type_flags EXTENDABLE
247 $$ = $1 | VAR_EXTENDABLE;
249 | type_flags WRITEIFSET
251 $$ = $1 | VAR_SVDYNAMIC;
255 $$ = 0;
259 type
260 : type_base
262 $$ = $1;
264 | type_base '[' ']'
266 if( $1 )
268 ByteString aTypeName = pHS->getString( $1->GetId() );
269 aTypeName += "[]";
270 $$ = pTC->SearchType( pHS->getID( aTypeName.GetBuffer(), true ) );
271 if( !$$ )
273 RscCont * pCont;
274 pCont = new RscCont( pHS->getID( aTypeName.GetBuffer() ), RSC_NOTYPE );
275 pCont->SetTypeClass( $1 );
276 pTC->InsertType( pCont );
277 $$ = pCont;
280 else
281 $$ = NULL;
285 type_base
286 : CLASSNAME
288 $$ = $1;
290 | SYMBOL
292 RscTop * pType = pTC->SearchType( pHS->getID( $1, true ) );
293 if( !pType )
294 pTC->pEH->Error( ERR_NOTYPE, pCurClass, RscId() );
295 $$ = pType;
299 class_definition
300 : class_header class_body
302 if( TYPE_REF == $1.nTyp )
303 pTC->pEH->Error( ERR_REFNOTALLOWED, S.Top().pClass,
304 RscId( $1.nName1 ) );
305 S.Pop();
307 | class_header
309 ERRTYPE aError;
310 RscId aRscId( $1.nName1 );
312 if( TYPE_NOTHING == $1.nTyp && aRscId.IsId() )
313 aError = S.Top().pClass->SetRef( S.Top(), aRscId );
314 else if( TYPE_COPY == $1.nTyp )
315 aError = ERR_COPYNOTALLOWED;
316 if( aError.IsError() || aError.IsWarning() )
317 pTC->pEH->Error( aError, S.Top().pClass, aRscId );
318 S.Pop();
322 class_header
323 : class_header_body
325 if( !DoClassHeader( &$1, FALSE ) )
326 return( ERR_ERROR );
327 $$ = $1;
331 copy_ref
332 : '<'
334 $$ = TYPE_COPY;
336 | ','
338 $$ = TYPE_REF;
342 class_header_body
343 : CLASSNAME id_expression copy_ref CLASSNAME id_expression
345 $$.pClass = $1;
346 $$.nName1 = $2;
347 $$.nTyp = $3;
348 $$.pRefClass = $4;
349 $$.nName2 = $5;
351 | CLASSNAME id_expression copy_ref id_expression
353 $$.pClass = $1;
354 $$.nName1 = $2;
355 $$.nTyp = $3;
356 $$.pRefClass = NULL;
357 $$.nName2 = $4;
359 | CLASSNAME id_expression
361 $$.pClass = $1;
362 $$.nName1 = $2;
363 $$.nTyp = TYPE_NOTHING;
364 $$.pRefClass = NULL;
365 $$.nName2.cType = RSCEXP_NOTHING;
367 | CLASSNAME copy_ref id_expression
369 $$.pClass = $1;
370 $$.nName1.cType = RSCEXP_NOTHING;
371 $$.nTyp = $2;
372 $$.pRefClass = NULL;
373 $$.nName2 = $3;
375 | CLASSNAME copy_ref CLASSNAME id_expression
377 $$.pClass = $1;
378 $$.nName1.cType = RSCEXP_NOTHING;
379 $$.nTyp = $2;
380 $$.pRefClass = $3;
381 $$.nName2 = $4;
383 | CLASSNAME
385 $$.pClass = $1;
386 $$.nName1.cType = RSCEXP_NOTHING;
387 $$.nTyp = TYPE_NOTHING;
388 $$.nName2.cType = RSCEXP_NOTHING;
392 class_body
393 : '{' var_definitions '}'
394 | '{' '}'
395 | string_multiline
397 SetString( S.Top(), "TEXT", $1 );
401 var_definitions
402 : var_definition
403 | var_definitions var_definition
406 xy_mapmode
407 : CONSTNAME
409 SetConst( S.Top(), "_XYMAPMODE", $1.hashid, $1.nValue );
414 wh_mapmode
415 : CONSTNAME
417 SetConst( S.Top(), "_WHMAPMODE", $1.hashid, $1.nValue );
422 xywh_mapmode
423 : CONSTNAME
425 SetConst( S.Top(), "_XYMAPMODE", $1.hashid, $1.nValue );
426 SetConst( S.Top(), "_WHMAPMODE", $1.hashid, $1.nValue );
431 var_definition
432 : line_number
433 | var_header var_body ';'
435 S.Pop();
437 | class_definition ';'
438 | var_header_class class_body ';'
440 if( TYPE_REF == $1.nTyp )
441 pTC->pEH->Error( ERR_REFNOTALLOWED, S.Top().pClass,
442 RscId( $1.nName1 ) );
444 if( S.Top().pClass->GetCount( S.Top() ) )
445 pTC->pEH->Error( WRN_SUBINMEMBER, S.Top().pClass,
446 RscId( $1.nName1 ) );
448 S.Pop();
450 | var_header_class ';'
452 ERRTYPE aError;
453 RscId aRscId( $1.nName1 );
455 if( TYPE_NOTHING == $1.nTyp && aRscId.IsId() )
456 aError = S.Top().pClass->SetRef( S.Top(), aRscId );
457 else if( TYPE_COPY == $1.nTyp )
458 aError = ERR_COPYNOTALLOWED;
459 if( S.Top().pClass->GetCount( S.Top() ) )
460 aError = WRN_SUBINMEMBER;
461 if( aError.IsError() || aError.IsWarning() )
462 pTC->pEH->Error( aError, S.Top().pClass, aRscId );
464 S.Pop();
466 | XSCALE '=' '(' long_expression ',' long_expression ')' ';'
468 SetNumber( S.Top(), "_XNUMERATOR", $4 );
469 SetNumber( S.Top(), "_XDENOMINATOR", $6 );
471 | YSCALE '=' '(' long_expression ',' long_expression ')' ';'
473 SetNumber( S.Top(), "_YNUMERATOR", $4 );
474 SetNumber( S.Top(), "_YDENOMINATOR", $6 );
476 | RGB '=' '(' long_expression ',' long_expression
477 ',' long_expression ')' ';'
479 SetNumber( S.Top(), "RED", $4 );
480 SetNumber( S.Top(), "GREEN", $6 );
481 SetNumber( S.Top(), "BLUE", $8 );
483 | GEOMETRY '=' xywh_mapmode '(' long_expression ',' long_expression ','
484 long_expression ',' long_expression ')' ';'
486 SetNumber( S.Top(), "_X", $5 );
487 SetNumber( S.Top(), "_Y", $7 );
488 SetNumber( S.Top(), "_WIDTH", $9 );
489 SetNumber( S.Top(), "_HEIGHT", $11 );
491 | POSITION '=' xy_mapmode '(' long_expression ',' long_expression
492 ')' ';'
494 SetNumber( S.Top(), "_X", $5 );
495 SetNumber( S.Top(), "_Y", $7 );
497 | DIMENSION '=' wh_mapmode '(' long_expression ',' long_expression
498 ')' ';'
500 SetNumber( S.Top(), "_WIDTH", $5 );
501 SetNumber( S.Top(), "_HEIGHT", $7 );
503 | INZOOMOUTPUTSIZE '=' CONSTNAME '(' long_expression ',' long_expression
504 ')' ';'
506 SetConst( S.Top(), "_ZOOMINMAPMODE", $3.hashid, $3.nValue );
507 SetNumber( S.Top(), "_ZOOMINWIDTH", $5 );
508 SetNumber( S.Top(), "_ZOOMINHEIGHT", $7 );
510 | INZOOMOUTPUTSIZE '=' '(' long_expression ',' long_expression ')' ';'
512 SetNumber( S.Top(), "_ZOOMINWIDTH", $4 );
513 SetNumber( S.Top(), "_ZOOMINHEIGHT", $6 );
515 | FLOATINGPOS '=' CONSTNAME '(' long_expression ',' long_expression
516 ')' ';'
518 SetConst( S.Top(), "_FLOATINGPOSMAPMODE", $3.hashid, $3.nValue );
519 SetNumber( S.Top(), "_FLOATINGPOSX", $5 );
520 SetNumber( S.Top(), "_FLOATINGPOSY", $7 );
522 | FLOATINGPOS '=' '(' long_expression ',' long_expression ')' ';'
524 SetNumber( S.Top(), "_FLOATINGPOSX", $4 );
525 SetNumber( S.Top(), "_FLOATINGPOSY", $6 );
529 var_header_class
530 : VARNAME '=' class_header_body
532 RSCINST aInst;
534 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST(), FALSE, $3.pClass );
536 if( aInst.pData )
537 S.Push( aInst );
538 else
540 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(),
541 pHS->getString( $1 ) );
542 return( ERR_ERROR );
545 if( !DoClassHeader( &$3, TRUE ) )
546 return( ERR_ERROR );
547 $$ = $3;
549 | VARNAME '[' CONSTNAME ']' '=' class_header_body
551 RSCINST aInst;
553 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() );
555 if( aInst.pData )
557 ERRTYPE aError;
558 RSCINST aIdxInst;
560 aError = aInst.pClass->GetArrayEle( aInst, $3.hashid, NULL, &aIdxInst );
561 if( aError.IsError() || aError.IsWarning() )
562 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
563 if( aError.IsError() )
564 return( ERR_ERROR );
565 S.Push( aIdxInst );
567 else
569 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(),
570 pHS->getString( $1 ) );
571 return( ERR_ERROR );
573 if( !DoClassHeader( &$6, TRUE ) )
574 return( ERR_ERROR );
575 $$ = $6;
577 | VARNAME '[' SYMBOL ']' '=' class_header_body
579 RSCINST aInst;
581 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() );
583 if( aInst.pData )
585 long nNewLang = pTC->AddLanguage( $3 );
586 ERRTYPE aError;
587 RSCINST aIdxInst;
589 aError = aInst.pClass->GetArrayEle( aInst, nNewLang, NULL, &aIdxInst );
590 if( aError.IsError() || aError.IsWarning() )
591 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
592 if( aError.IsError() )
593 return( ERR_ERROR );
594 S.Push( aIdxInst );
596 else
598 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(),
599 pHS->getString( $1 ) );
600 return( ERR_ERROR );
602 if( !DoClassHeader( &$6, TRUE ) )
603 return( ERR_ERROR );
604 $$ = $6;
608 var_header
609 : VARNAME '='
611 RSCINST aInst;
613 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() );
615 if( aInst.pData )
616 S.Push( aInst );
617 else{
618 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(),
619 pHS->getString( $1 ) );
620 return( ERR_ERROR );
623 | VARNAME '[' CONSTNAME ']' '='
625 RSCINST aInst;
627 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() );
629 if( aInst.pData )
631 ERRTYPE aError;
632 RSCINST aIdxInst;
634 aError = aInst.pClass->GetArrayEle( aInst, $3.hashid, NULL, &aIdxInst );
635 if( aError.IsError() || aError.IsWarning() )
636 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
637 if( aError.IsError() )
638 return( ERR_ERROR );
639 S.Push( aIdxInst );
641 else{
642 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(),
643 pHS->getString( $1 ) );
644 return( ERR_ERROR );
647 | VARNAME '[' SYMBOL ']' '='
649 RSCINST aInst;
651 aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() );
653 if( aInst.pData )
655 long nNewLang = pTC->AddLanguage( $3 );
656 ERRTYPE aError;
657 RSCINST aIdxInst;
659 aError = aInst.pClass->GetArrayEle( aInst, nNewLang, NULL, &aIdxInst );
660 if( aError.IsError() || aError.IsWarning() )
661 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
662 if( aError.IsError() )
663 return( ERR_ERROR );
664 S.Push( aIdxInst );
666 else{
667 pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(),
668 pHS->getString( $1 ) );
669 return( ERR_ERROR );
673 tupel_header0
676 RSCINST aInst;
678 aInst = S.Top().pClass->GetTupelVar( S.Top(), 0, RSCINST() );
679 if( aInst.pData )
680 S.Push( aInst );
681 else
683 pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() );
684 return( ERR_ERROR );
689 tupel_header1
692 RSCINST aInst;
694 aInst = S.Top().pClass->GetTupelVar( S.Top(), 1, RSCINST() );
695 if( aInst.pData )
696 S.Push( aInst );
697 else
699 pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() );
700 return( ERR_ERROR );
705 tupel_header2
708 RSCINST aInst;
710 aInst = S.Top().pClass->GetTupelVar( S.Top(), 2, RSCINST() );
711 if( aInst.pData )
712 S.Push( aInst );
713 else
715 pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() );
716 return( ERR_ERROR );
721 tupel_header3
724 RSCINST aInst;
726 aInst = S.Top().pClass->GetTupelVar( S.Top(), 3, RSCINST() );
727 if( !aInst.pData )
729 pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() );
730 return( ERR_ERROR );
732 S.Push( aInst );
736 tupel_body
737 : var_body
739 S.Pop();
743 var_list_header
746 ERRTYPE aError;
747 RSCINST aInst;
749 aError = S.Top().pClass->GetElement( S.Top(), RscId(),
750 NULL, RSCINST(), &aInst );
751 if( aError.IsError() || aError.IsWarning() )
752 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
753 if( aError.IsError() )
754 { // unbedingt Instanz auf den Stack bringen
755 aInst = S.Top().pClass->Create( NULL, RSCINST() );
757 S.Push( aInst );
761 list_body
762 : var_bodycomplex
764 S.Pop();
768 list_header
771 sal_uInt32 nCount = S.Top().pClass->GetCount( S.Top() );
772 sal_uInt32 i;
774 for( i = nCount; i > 0; i-- )
775 S.Top().pClass->DeletePos( S.Top(), i -1 );
779 list
780 : list var_list_header list_body ';'
781 | list var_bodysimple ';'
782 | list class_definition ';'
783 | list line_number
787 var_bodysimple
788 : macro_expression
790 INT32 l;
791 ERRTYPE aError;
793 if( !$1.Evaluate( &l ) )
794 pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() );
795 else
797 aError = S.Top().pClass->SetRef( S.Top(), RscId( $1 ) );
798 if( aError.IsError() )
800 aError.Clear();
801 aError = S.Top().pClass->SetNumber( S.Top(), l );
803 if( aError.IsError() )
804 { // Aufwaertskompatible, Tupel probieren
805 RSCINST aInst = GetFirstTupelEle( S.Top() );
806 if( aInst.pData )
808 aError.Clear(); // Fehler zuruecksetzen
809 aError = aInst.pClass->SetRef( aInst, RscId( $1 ) );
810 if( aError.IsError() )
812 aError.Clear();
813 aError = aInst.pClass->SetNumber( aInst, l );
819 if( $1.IsExpression() )
820 delete $1.aExp.pExp;
822 if( aError.IsError() || aError.IsWarning() )
823 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
825 | CONSTNAME
827 ERRTYPE aError;
828 aError = S.Top().pClass->SetConst( S.Top(), $1.hashid, $1.nValue );
829 if( aError.IsError() )
830 { // Aufwaertskompatible, Tupel probieren
831 RSCINST aInst = GetFirstTupelEle( S.Top() );
832 if( aInst.pData )
834 aError.Clear(); // Fehler zuruecksetzen
835 aError = aInst.pClass->SetConst( aInst, $1.hashid, $1.nValue );
839 if( aError.IsError() || aError.IsWarning() )
840 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
842 | NOT CONSTNAME
844 ERRTYPE aError;
845 aError = S.Top().pClass->SetNotConst( S.Top(), $2.hashid );
846 if( aError.IsError() )
847 { // Aufwaertskompatible, Tupel probieren
848 RSCINST aInst = GetFirstTupelEle( S.Top() );
849 if( aInst.pData )
851 aError.Clear(); // Fehler zuruecksetzen
852 aError = aInst.pClass->SetNotConst( aInst, $2.hashid );
856 if( aError.IsError() || aError.IsWarning() )
857 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
859 | BOOLEAN
861 ERRTYPE aError;
862 aError = S.Top().pClass->SetBool( S.Top(), $1 );
863 if( aError.IsError() )
864 { // Aufwaertskompatible, Tupel probieren
865 RSCINST aInst = GetFirstTupelEle( S.Top() );
866 if( aInst.pData )
868 aError.Clear(); // Fehler zuruecksetzen
869 aError = aInst.pClass->SetBool( aInst, $1 );
873 if( aError.IsError() || aError.IsWarning() )
874 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
876 | string_multiline
878 ERRTYPE aError;
879 aError = S.Top().pClass->SetString( S.Top(), $1 );
880 if( aError.IsError() )
881 { // Aufwaertskompatible, Tupel probieren
882 RSCINST aInst = GetFirstTupelEle( S.Top() );
883 if( aInst.pData )
885 aError.Clear(); // Fehler zuruecksetzen
886 aError = aInst.pClass->SetString( aInst, $1 );
890 if( aError.IsError() || aError.IsWarning() )
891 pTC->pEH->Error( aError, S.Top().pClass, RscId() );
893 | DEFAULT
896 var_bodycomplex
897 : '{' list_header list '}'
898 | '<' tupel_header0 tupel_body ';' '>'
899 | '<' tupel_header0 tupel_body ';' tupel_header1 tupel_body ';' '>'
900 | '<' tupel_header0 tupel_body ';' tupel_header1 tupel_body ';'
901 tupel_header2 tupel_body ';' '>'
902 | '<' tupel_header0 tupel_body ';' tupel_header1 tupel_body ';'
903 tupel_header2 tupel_body ';' tupel_header3 tupel_body ';' '>'
906 var_body
907 : var_bodysimple
908 | var_bodycomplex
911 /********************** work on yacc stack *******************************/
912 string_multiline
913 : STRING
915 $$ = $1;
917 | string_multiline STRING
919 rtl::OStringBuffer aBuf( 256 );
920 aBuf.append( $1 );
921 aBuf.append( $2 );
922 $$ = (char*)pStringContainer->putString( aBuf.getStr() );
926 long_expression
927 : macro_expression
929 if( !$1.Evaluate( &$$ ) )
930 pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() );
931 if( $1.IsExpression() )
932 delete $1.aExp.pExp;
936 macro_expression
937 : RSCDEFINE
939 $$.cType = RSCEXP_DEF;
940 $$.aExp.pDef = $1;
942 | NUMBER
944 $$.cType = RSCEXP_LONG;
945 $$.SetLong( $1 );
947 | '-' macro_expression %prec UNARYMINUS
949 if( $2.IsNumber() ){
950 $$.cType = $2.cType;
951 $$.SetLong( - $2.GetLong() );
953 else{
954 RscExpType aLeftExp;
956 aLeftExp.cType = RSCEXP_NOTHING;
957 $$.cType = RSCEXP_EXP;
958 $$.aExp.pExp = new RscExpression( aLeftExp, '-', $2 );
961 | '+' macro_expression %prec UNARYPLUS
963 $$ = $2;
965 | macro_expression '+' macro_expression
967 if( $1.IsNumber() && $3.IsNumber() ){
968 $$.cType = RSCEXP_LONG;
969 $$.SetLong( $1.GetLong() + $3.GetLong() );
971 else{
972 $$.cType = RSCEXP_EXP;
973 $$.aExp.pExp = new RscExpression( $1, '+', $3 );
976 | macro_expression '-' macro_expression
978 if( $1.IsNumber() && $3.IsNumber() ){
979 $$.cType = RSCEXP_LONG;
980 $$.SetLong( $1.GetLong() - $3.GetLong() );
982 else{
983 $$.cType = RSCEXP_EXP;
984 $$.aExp.pExp = new RscExpression( $1, '-', $3 );
987 | macro_expression '*' macro_expression
989 if( $1.IsNumber() && $3.IsNumber() ){
990 $$.cType = RSCEXP_LONG;
991 $$.SetLong( $1.GetLong() * $3.GetLong() );
993 else{
994 $$.cType = RSCEXP_EXP;
995 $$.aExp.pExp = new RscExpression( $1, '*', $3 );
998 | macro_expression '/' macro_expression
1000 if( $1.IsNumber() && $3.IsNumber() ){
1001 if( 0 == $3.GetLong() ){
1002 $$.cType = RSCEXP_EXP;
1003 $$.aExp.pExp = new RscExpression( $1, '/', $3 );
1005 else{
1006 $$.cType = RSCEXP_LONG;
1007 $$.SetLong( $1.GetLong() / $3.GetLong() );
1010 else{
1011 $$.cType = RSCEXP_EXP;
1012 $$.aExp.pExp = new RscExpression( $1, '/', $3 );
1015 | macro_expression '&' macro_expression
1017 if( $1.IsNumber() && $3.IsNumber() ){
1018 $$.cType = RSCEXP_LONG;
1019 $$.SetLong( $1.GetLong() & $3.GetLong() );
1021 else{
1022 $$.cType = RSCEXP_EXP;
1023 $$.aExp.pExp = new RscExpression( $1, '&', $3 );
1026 | macro_expression '|' macro_expression
1028 if( $1.IsNumber() && $3.IsNumber() ){
1029 $$.cType = RSCEXP_LONG;
1030 $$.SetLong( $1.GetLong() | $3.GetLong() );
1032 else{
1033 $$.cType = RSCEXP_EXP;
1034 $$.aExp.pExp = new RscExpression( $1, '|', $3 );
1037 | '(' macro_expression ')'
1039 $$ = $2;
1041 | macro_expression LEFTSHIFT macro_expression
1043 if( $1.IsNumber() && $3.IsNumber() ){
1044 $$.cType = RSCEXP_LONG;
1045 $$.SetLong( $1.GetLong() << $3.GetLong() );
1047 else{
1048 $$.cType = RSCEXP_EXP;
1049 $$.aExp.pExp = new RscExpression( $1, 'l', $3 );
1052 | macro_expression RIGHTSHIFT macro_expression
1054 if( $1.IsNumber() && $3.IsNumber() ){
1055 $$.cType = RSCEXP_LONG;
1056 $$.SetLong( $1.GetLong() >> $3.GetLong() );
1058 else{
1059 $$.cType = RSCEXP_EXP;
1060 $$.aExp.pExp = new RscExpression( $1, 'r', $3 );
1065 id_expression
1066 : id_expression line_number
1067 | macro_expression
1068 { // pExpession auswerten und loeschen
1069 if( RSCEXP_EXP == $1.cType ){
1070 INT32 lValue;
1072 if( !$1.Evaluate( &lValue ) )
1073 pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() );
1074 delete $1.aExp.pExp;
1075 $$.cType = RSCEXP_LONG;
1076 $$.SetLong( lValue );
1078 else
1079 $$ = $1;
1083 DUMMY_NUMBER
1084 : NUMBER
1092 line_number
1093 : '#' LINE NUMBER STRING
1095 RscFile * pFName;
1097 pFI->SetLineNo( $3 );
1098 pFI->SetFileIndex( pTC->aFileTab.NewCodeFile( ByteString( $4 ) ) );
1099 pFName = pTC->aFileTab.Get( pFI->GetFileIndex() );
1100 pFName->bLoaded = TRUE;
1101 pFName->bScanned = TRUE;
1103 | '#' NUMBER STRING DUMMY_NUMBER
1105 RscFile * pFName;
1107 pFI->SetLineNo( $2 );
1108 pFI->SetFileIndex( pTC->aFileTab.NewCodeFile( ByteString( $3 ) ) );
1109 pFName = pTC->aFileTab.Get( pFI->GetFileIndex() );
1110 pFName->bLoaded = TRUE;
1111 pFName->bScanned = TRUE;
1113 | '#' NUMBER
1115 pFI->SetLineNo( $2 );