2 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of the LibreOffice project.
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 * This file incorporates work covered by the following license notice:
12 * Licensed to the Apache Software Foundation (ASF) under one or more
13 * contributor license agreements. See the NOTICE file distributed
14 * with this work for additional information regarding copyright
15 * ownership. The ASF licenses this file to you under the Apache
16 * License, Version 2.0 (the "License"); you may not use this file
17 * except in compliance with the License. You may obtain a copy of
18 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "sal/config.h"
27 #include <rtl/strbuf.hxx>
30 #include <rsctools.hxx>
31 #include <rscclass.hxx>
32 #include <rsccont.hxx>
33 #include <rsctree.hxx>
45 RSCINST GetVarInst
( const RSCINST
& rInst
, const char * pVarName
)
49 aInst
= rInst.pClass
->GetVariable
( rInst
, pHS
->getID
( pVarName
),
53 pTC
->pEH
->Error
( ERR_NOVARIABLENAME
, rInst.pClass
, RscId
() );
58 void SetNumber
( const RSCINST
& rInst
, const char * pVarName
, sal_Int32 lValue
)
62 aInst
= GetVarInst
( rInst
, pVarName
);
67 aError
= aInst.pClass
->SetNumber
( aInst
, lValue
);
69 if
( aError.IsError
() )
70 pTC
->pEH
->Error
( aError
, aInst.pClass
, RscId
() );
74 void SetConst
( const RSCINST
& rInst
, const char * pVarName
,
75 Atom nValueId
, sal_Int32 nVal
)
79 aInst
= GetVarInst
( rInst
, pVarName
);
83 aError
= aInst.pClass
->SetConst
( aInst
, nValueId
, nVal
);
85 if
( aError.IsError
() )
86 pTC
->pEH
->Error
( aError
, aInst.pClass
, RscId
() );
90 void SetString
( const RSCINST
& rInst
, const char * pVarName
, const char * pStr
)
94 aInst
= GetVarInst
( rInst
, pVarName
);
97 aError
= aInst.pClass
->SetString
( aInst
, pStr
);
99 if
( aError.IsError
() )
100 pTC
->pEH
->Error
( aError
, aInst.pClass
, RscId
() );
104 RscId MakeRscId
( RscExpType aExpType
)
106 if
( !aExpType.IsNothing
() )
110 if
( !aExpType.Evaluate
( &lValue
) )
111 pTC
->pEH
->Error
( ERR_ZERODIVISION
, NULL
, RscId
() );
112 if
( lValue
< 1 || lValue
> (sal_Int32
)0x7FFF )
114 pTC
->pEH
->Error
( ERR_IDRANGE
, NULL
, RscId
(),
115 rtl
::OString
::number
(lValue
).getStr
() );
118 if
( aExpType.IsDefinition
() )
119 return RscId
( aExpType.aExp.pDef
);
121 return RscId
( lValue
);
126 bool DoClassHeader
( RSCHEADER
* pHeader
, bool bMember
)
129 RscId aName1
= MakeRscId
( pHeader
->nName1
);
130 RscId aName2
= MakeRscId
( pHeader
->nName2
);
132 if
( pHeader
->pRefClass
)
133 aCopyInst.pClass
= pHeader
->pRefClass
;
135 aCopyInst.pClass
= pHeader
->pClass
;
137 if
( TYPE_COPY
== pHeader
->nTyp
)
139 ObjNode
* pCopyObj
= aCopyInst.pClass
->GetObjNode
( aName2
);
143 rtl
::OStringBuffer aMsg
( pHS
->getString
( aCopyInst.pClass
->GetId
() ) );
145 aMsg.append
(aName2.GetName
());
146 pTC
->pEH
->Error
( ERR_NOCOPYOBJ
, pHeader
->pClass
, aName1
,
150 aCopyInst.pData
= pCopyObj
->GetRscObj
();
155 // Angabe von Superklassen oder abgeleiteten Klassen ist jetzt erlaubt
156 if
( S.Top
().pClass
->InHierarchy
( pHeader
->pClass
) ||
157 pHeader
->pClass
->InHierarchy
( S.Top
().pClass
) )
159 if
( aCopyInst.IsInst
() )
161 RSCINST aTmpI
( S.Top
() );
162 aTmpI.pClass
->Destroy
( aTmpI
);
163 aTmpI.pClass
->Create
( &aTmpI
, aCopyInst
);
167 pTC
->pEH
->Error
( ERR_FALSETYPE
, S.Top
().pClass
, aName1
,
168 pHS
->getString
( pHeader
->pClass
->GetId
() ).getStr
() );
174 if
( (sal_Int32
)aName1
< 256 )
175 pTC
->pEH
->Error
( WRN_GLOBALID
, pHeader
->pClass
, aName1
);
177 if
( aCopyInst.IsInst
() )
178 S.Push
( pHeader
->pClass
->Create
( NULL
, aCopyInst
) );
180 S.Push
( pHeader
->pClass
->Create
( NULL
, RSCINST
() ) );
182 pTC
->pEH
->StdOut
( ".", RscVerbosityVerbose
);
185 pTC
->pEH
->Error
( ERR_IDEXPECTED
, pHeader
->pClass
, aName1
);
188 ObjNode
* pNode
= new ObjNode
( aName1
, S.Top
().pData
,
189 pFI
->GetFileIndex
() );
190 if
( !pHeader
->pClass
->PutObjNode
( pNode
) )
191 pTC
->pEH
->Error
( ERR_DOUBLEID
, pHeader
->pClass
, aName1
);
199 if
( (sal_Int32
)aName1
>= 256 && aName1.IsId
() )
200 pTC
->pEH
->Error
( WRN_LOCALID
, pHeader
->pClass
, aName1
);
202 aError
= S.Top
().pClass
->GetElement
( S.Top
(), aName1
,
203 pHeader
->pClass
, aCopyInst
, &aTmpI
);
205 if
( aError.IsWarning
() )
207 pTC
->pEH
->Error
( aError
, pHeader
->pClass
, aName1
);
209 else if
( aError.IsError
() )
211 if
( ERR_CONT_INVALIDTYPE
== aError
)
212 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, aName1
,
213 pHS
->getString
( pHeader
->pClass
->GetId
() ).getStr
() );
215 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, aName1
);
217 S.Top
().pClass
->GetElement
( S.Top
(), RscId
(),
218 pHeader
->pClass
, RSCINST
(), &aTmpI
);
220 if
( !aTmpI.IsInst
() )
226 if
( TYPE_REF
== pHeader
->nTyp
)
230 aError
= S.Top
().pClass
->SetRef
( S.Top
(), aName2
);
231 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, aName1
);
237 RSCINST GetFirstTupelEle
( const RSCINST
& rTop
)
238 { // Aufwaertskompatible, Tupel probieren
242 aErr
= rTop.pClass
->GetElement
( rTop
, RscId
(), NULL
, RSCINST
(), &aInst
);
243 if
( !aErr.IsError
() )
244 aInst
= aInst.pClass
->GetTupelVar
( aInst
, 0, RSCINST
() );
251 #define YYMAXDEPTH 2000
253 #define YYMAXDEPTH 800
257 #pragma warning(push, 1)
258 #pragma warning(disable:4129 4273 4701 4702)
261 #pragma GCC diagnostic ignored "-Wwrite-strings"
285 RscDefine
* defineele
;
286 rtl_TextEncoding charset
;
287 RscExpType macrostruct
;
291 %token
<value
> NUMBER
292 %token
<string> SYMBOL
293 %token
<defineele
> RSCDEFINE
294 %token
<string> STRING
295 %token
<string> INCLUDE_STRING
296 %token
<character
> CHARACTER
297 %token
<svbool
> BOOLEAN
308 %token INZOOMOUTPUTSIZE
316 %token
<pClass
> CLASSNAME
317 %token
<varid
> VARNAME
318 %token
<constname
> CONSTNAME
324 %type
<macrostruct
> macro_expression
325 %type
<macrostruct
> id_expression
326 %type
<value
> long_expression
327 %type
<string> string_multiline
330 %type
<pClass
> type_base
331 %type
<header
> class_header_body
332 %type
<header
> class_header
333 %type
<header
> var_header_class
334 %type
<copyref
> copy_ref
335 %type
<ushort
> type_flags
340 %left LEFTSHIFT RIGHTSHIFT
351 %start resource_definitions
357 | resource_definitions resource_definition
358 | MACROTARGET macro_expression
363 aExpType.cUnused
= false
;
364 aExpType.cType
= RSCEXP_NOTHING
;
365 pExp
= new RscExpression
( aExpType
, '+', $2 );
366 if
( !pExp
->Evaluate
( &lValue
) )
368 pTC
->pEH
->Error
( ERR_ZERODIVISION
, NULL
, RscId
() );
376 |
'#' DEFINE SYMBOL macro_expression
382 if
( !pTC
->aFileTab.NewDef
( pFI
->GetFileIndex
(),
384 $4.GetLong
(), ULONG_MAX
) )
387 else if
( $4.IsDefinition
() )
390 RscExpression
* pExpr
;
392 aExpType.cUnused
= false
;
393 aExpType.cType
= RSCEXP_NOTHING
;
394 aExpType.SetLong
( 0 );
395 aExpType.cType
= RSCEXP_LONG
;
396 pExpr
= new RscExpression
( aExpType
, '+', $4 );
398 if
( !pTC
->aFileTab.NewDef
( pFI
->GetFileIndex
(),
399 rtl
::OString
( $3 ), pExpr
, ULONG_MAX
) )
404 else if
( $4.IsExpression
() )
406 if
( !pTC
->aFileTab.NewDef
( pFI
->GetFileIndex
(),
407 rtl
::OString
( $3 ), $4.aExp.pExp
,
416 pTC
->pEH
->Error
( ERR_DECLAREDEFINE
, NULL
, RscId
(), $3 );
419 |
'#' DEFINE RSCDEFINE macro_expression
421 pTC
->pEH
->Error
( ERR_DOUBLEDEFINE
, NULL
, RscId
(), $3->GetName
().getStr
() );
426 |
'#' INCLUDE INCLUDE_STRING
429 | class_definition
';'
433 pMem
= rtl_allocateMemory
( 20000 );
434 rtl_freeMemory
( pMem
);
437 | new_class_definition_header
'{' new_class_definition_body
'}' ';'
438 | new_class_definition_header
';'
441 new_class_definition_header
442 : CLASS SYMBOL id_expression
':' CLASSNAME
446 $3.Evaluate
( &lType
);
449 Atom nId
= pHS
->getID
( $2 );
450 pCurClass
= new RscClass
( nId
, lType
, $5 );
452 pTC
->aNmTb.Put
( nId
, CLASSNAME
, pCurClass
);
453 pTC
->GetRoot
()->Insert
( pCurClass
);
455 | CLASS CLASSNAME id_expression
':' CLASSNAME
462 new_class_definition_body
464 | property_definition
';' new_class_definition_body
468 : type_flags type SYMBOL
471 Atom nId
= pTC
->aNmTb.Put
( $3, VARNAME
);
472 pCurClass
->SetVariable
( nId
, $2, NULL
, $1, nCurMask
);
475 | type_flags type VARNAME
477 pCurClass
->SetVariable
( $3, $2, NULL
, $1, nCurMask
);
483 : type_flags EXTENDABLE
485 $$
= $1 | VAR_EXTENDABLE
;
487 | type_flags WRITEIFSET
489 $$
= $1 | VAR_SVDYNAMIC
;
506 rtl
::OString aTypeName
= rtl
::OStringBuffer
(pHS
->getString
($1->GetId
())).
507 append
("[]").makeStringAndClear
();
508 $$
= pTC
->SearchType
( pHS
->getID
( aTypeName.getStr
(), true
) );
512 pCont
= new RscCont
( pHS
->getID
( aTypeName.getStr
() ), RSC_NOTYPE
);
513 pCont
->SetTypeClass
( $1 );
514 pTC
->InsertType
( pCont
);
532 RscTop
* pType
= pTC
->SearchType
( pHS
->getID
( $1, true
) );
534 pTC
->pEH
->Error
( ERR_NOTYPE
, pCurClass
, RscId
() );
540 : class_header class_body
542 if
( TYPE_REF
== $1.nTyp
)
544 pTC
->pEH
->Error
( ERR_REFNOTALLOWED
, S.Top
().pClass
,
545 RscId
( $1.nName1
) );
552 RscId aRscId
( $1.nName1
);
554 if
( TYPE_NOTHING
== $1.nTyp
&& aRscId.IsId
() )
555 aError
= S.Top
().pClass
->SetRef
( S.Top
(), aRscId
);
556 else if
( TYPE_COPY
== $1.nTyp
)
557 aError
= ERR_COPYNOTALLOWED
;
558 if
( aError.IsError
() || aError.IsWarning
() )
559 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, aRscId
);
567 if
( !DoClassHeader
( &$1, false
) )
585 : CLASSNAME id_expression copy_ref CLASSNAME id_expression
593 | CLASSNAME id_expression copy_ref id_expression
601 | CLASSNAME id_expression
605 $$.nTyp
= TYPE_NOTHING
;
607 $$.nName2.cType
= RSCEXP_NOTHING
;
609 | CLASSNAME copy_ref id_expression
612 $$.nName1.cType
= RSCEXP_NOTHING
;
617 | CLASSNAME copy_ref CLASSNAME id_expression
620 $$.nName1.cType
= RSCEXP_NOTHING
;
628 $$.nName1.cType
= RSCEXP_NOTHING
;
629 $$.nTyp
= TYPE_NOTHING
;
630 $$.nName2.cType
= RSCEXP_NOTHING
;
635 : '{' var_definitions
'}'
639 SetString
( S.Top
(), "TEXT", $1 );
645 | var_definitions var_definition
651 SetConst
( S.Top
(), "_XYMAPMODE", $1.hashid
, $1.nValue
);
659 SetConst
( S.Top
(), "_WHMAPMODE", $1.hashid
, $1.nValue
);
667 SetConst
( S.Top
(), "_XYMAPMODE", $1.hashid
, $1.nValue
);
668 SetConst
( S.Top
(), "_WHMAPMODE", $1.hashid
, $1.nValue
);
675 | var_header var_body
';'
679 | class_definition
';'
680 | var_header_class class_body
';'
682 if
( TYPE_REF
== $1.nTyp
)
683 pTC
->pEH
->Error
( ERR_REFNOTALLOWED
, S.Top
().pClass
,
684 RscId
( $1.nName1
) );
686 if
( S.Top
().pClass
->GetCount
( S.Top
() ) )
687 pTC
->pEH
->Error
( WRN_SUBINMEMBER
, S.Top
().pClass
,
688 RscId
( $1.nName1
) );
692 | var_header_class
';'
695 RscId aRscId
( $1.nName1
);
697 if
( TYPE_NOTHING
== $1.nTyp
&& aRscId.IsId
() )
698 aError
= S.Top
().pClass
->SetRef
( S.Top
(), aRscId
);
699 else if
( TYPE_COPY
== $1.nTyp
)
700 aError
= ERR_COPYNOTALLOWED
;
701 if
( S.Top
().pClass
->GetCount
( S.Top
() ) )
702 aError
= WRN_SUBINMEMBER
;
703 if
( aError.IsError
() || aError.IsWarning
() )
704 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, aRscId
);
708 | XSCALE
'=' '(' long_expression
',' long_expression
')' ';'
710 SetNumber
( S.Top
(), "_XNUMERATOR", $4 );
711 SetNumber
( S.Top
(), "_XDENOMINATOR", $6 );
713 | YSCALE
'=' '(' long_expression
',' long_expression
')' ';'
715 SetNumber
( S.Top
(), "_YNUMERATOR", $4 );
716 SetNumber
( S.Top
(), "_YDENOMINATOR", $6 );
718 | RGB
'=' '(' long_expression
',' long_expression
719 ',' long_expression
')' ';'
721 SetNumber
( S.Top
(), "RED", $4 );
722 SetNumber
( S.Top
(), "GREEN", $6 );
723 SetNumber
( S.Top
(), "BLUE", $8 );
725 | GEOMETRY
'=' xywh_mapmode
'(' long_expression
',' long_expression
','
726 long_expression
',' long_expression
')' ';'
728 SetNumber
( S.Top
(), "_X", $5 );
729 SetNumber
( S.Top
(), "_Y", $7 );
730 SetNumber
( S.Top
(), "_WIDTH", $9 );
731 SetNumber
( S.Top
(), "_HEIGHT", $11 );
733 | POSITION
'=' xy_mapmode
'(' long_expression
',' long_expression
736 SetNumber
( S.Top
(), "_X", $5 );
737 SetNumber
( S.Top
(), "_Y", $7 );
739 | DIMENSION
'=' wh_mapmode
'(' long_expression
',' long_expression
742 SetNumber
( S.Top
(), "_WIDTH", $5 );
743 SetNumber
( S.Top
(), "_HEIGHT", $7 );
745 | INZOOMOUTPUTSIZE
'=' CONSTNAME
'(' long_expression
',' long_expression
748 SetConst
( S.Top
(), "_ZOOMINMAPMODE", $3.hashid
, $3.nValue
);
749 SetNumber
( S.Top
(), "_ZOOMINWIDTH", $5 );
750 SetNumber
( S.Top
(), "_ZOOMINHEIGHT", $7 );
752 | INZOOMOUTPUTSIZE
'=' '(' long_expression
',' long_expression
')' ';'
754 SetNumber
( S.Top
(), "_ZOOMINWIDTH", $4 );
755 SetNumber
( S.Top
(), "_ZOOMINHEIGHT", $6 );
757 | FLOATINGPOS
'=' CONSTNAME
'(' long_expression
',' long_expression
760 SetConst
( S.Top
(), "_FLOATINGPOSMAPMODE", $3.hashid
, $3.nValue
);
761 SetNumber
( S.Top
(), "_FLOATINGPOSX", $5 );
762 SetNumber
( S.Top
(), "_FLOATINGPOSY", $7 );
764 | FLOATINGPOS
'=' '(' long_expression
',' long_expression
')' ';'
766 SetNumber
( S.Top
(), "_FLOATINGPOSX", $4 );
767 SetNumber
( S.Top
(), "_FLOATINGPOSY", $6 );
772 : VARNAME
'=' class_header_body
776 aInst
= S.Top
().pClass
->GetVariable
( S.Top
(), $1, RSCINST
(), false
, $3.pClass
);
782 pTC
->pEH
->Error
( ERR_NOVARIABLENAME
, S.Top
().pClass
, RscId
(),
783 pHS
->getString
( $1 ).getStr
() );
787 if
( !DoClassHeader
( &$3, true
) )
791 | VARNAME
'[' CONSTNAME
']' '=' class_header_body
795 aInst
= S.Top
().pClass
->GetVariable
( S.Top
(), $1, RSCINST
() );
802 aError
= aInst.pClass
->GetArrayEle
( aInst
, $3.hashid
, NULL
, &aIdxInst
);
803 if
( aError.IsError
() || aError.IsWarning
() )
804 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
805 if
( aError.IsError
() )
811 pTC
->pEH
->Error
( ERR_NOVARIABLENAME
, S.Top
().pClass
, RscId
(),
812 pHS
->getString
( $1 ).getStr
() );
815 if
( !DoClassHeader
( &$6, true
) )
819 | VARNAME
'[' SYMBOL
']' '=' class_header_body
823 aInst
= S.Top
().pClass
->GetVariable
( S.Top
(), $1, RSCINST
() );
827 long nNewLang
= pTC
->AddLanguage
( $3 );
831 aError
= aInst.pClass
->GetArrayEle
( aInst
, nNewLang
, NULL
, &aIdxInst
);
832 if
( aError.IsError
() || aError.IsWarning
() )
833 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
834 if
( aError.IsError
() )
840 pTC
->pEH
->Error
( ERR_NOVARIABLENAME
, S.Top
().pClass
, RscId
(),
841 pHS
->getString
( $1 ).getStr
() );
844 if
( !DoClassHeader
( &$6, true
) )
855 aInst
= S.Top
().pClass
->GetVariable
( S.Top
(), $1, RSCINST
() );
861 pTC
->pEH
->Error
( ERR_NOVARIABLENAME
, S.Top
().pClass
, RscId
(),
862 pHS
->getString
( $1 ).getStr
() );
866 | VARNAME
'[' CONSTNAME
']' '='
870 aInst
= S.Top
().pClass
->GetVariable
( S.Top
(), $1, RSCINST
() );
877 aError
= aInst.pClass
->GetArrayEle
( aInst
, $3.hashid
, NULL
, &aIdxInst
);
878 if
( aError.IsError
() || aError.IsWarning
() )
879 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
880 if
( aError.IsError
() )
886 pTC
->pEH
->Error
( ERR_NOVARIABLENAME
, S.Top
().pClass
, RscId
(),
887 pHS
->getString
( $1 ).getStr
() );
891 | VARNAME
'[' SYMBOL
']' '='
895 aInst
= S.Top
().pClass
->GetVariable
( S.Top
(), $1, RSCINST
() );
899 long nNewLang
= pTC
->AddLanguage
( $3 );
903 aError
= aInst.pClass
->GetArrayEle
( aInst
, nNewLang
, NULL
, &aIdxInst
);
904 if
( aError.IsError
() || aError.IsWarning
() )
905 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
906 if
( aError.IsError
() )
912 pTC
->pEH
->Error
( ERR_NOVARIABLENAME
, S.Top
().pClass
, RscId
(),
913 pHS
->getString
( $1 ).getStr
() );
924 aInst
= S.Top
().pClass
->GetTupelVar
( S.Top
(), 0, RSCINST
() );
929 pTC
->pEH
->Error
( ERR_NOTUPELNAME
, S.Top
().pClass
, RscId
() );
940 aInst
= S.Top
().pClass
->GetTupelVar
( S.Top
(), 1, RSCINST
() );
945 pTC
->pEH
->Error
( ERR_NOTUPELNAME
, S.Top
().pClass
, RscId
() );
956 aInst
= S.Top
().pClass
->GetTupelVar
( S.Top
(), 2, RSCINST
() );
961 pTC
->pEH
->Error
( ERR_NOTUPELNAME
, S.Top
().pClass
, RscId
() );
972 aInst
= S.Top
().pClass
->GetTupelVar
( S.Top
(), 3, RSCINST
() );
975 pTC
->pEH
->Error
( ERR_NOTUPELNAME
, S.Top
().pClass
, RscId
() );
995 aError
= S.Top
().pClass
->GetElement
( S.Top
(), RscId
(),
996 NULL
, RSCINST
(), &aInst
);
997 if
( aError.IsError
() || aError.IsWarning
() )
998 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
999 if
( aError.IsError
() )
1000 { // unbedingt Instanz auf den Stack bringen
1001 aInst
= S.Top
().pClass
->Create
( NULL
, RSCINST
() );
1017 sal_uInt32 nCount
= S.Top
().pClass
->GetCount
( S.Top
() );
1020 for
( i
= nCount
; i
> 0; i
-- )
1021 S.Top
().pClass
->DeletePos
( S.Top
(), i
-1 );
1026 : list var_list_header list_body
';'
1027 | list var_bodysimple
';'
1028 | list class_definition
';'
1039 if
( !$1.Evaluate
( &l
) )
1040 pTC
->pEH
->Error
( ERR_ZERODIVISION
, NULL
, RscId
() );
1043 aError
= S.Top
().pClass
->SetRef
( S.Top
(), RscId
( $1 ) );
1044 if
( aError.IsError
() )
1047 aError
= S.Top
().pClass
->SetNumber
( S.Top
(), l
);
1049 if
( aError.IsError
() )
1050 { // Aufwaertskompatible, Tupel probieren
1051 RSCINST aInst
= GetFirstTupelEle
( S.Top
() );
1054 aError.Clear
(); // Fehler zuruecksetzen
1055 aError
= aInst.pClass
->SetRef
( aInst
, RscId
( $1 ) );
1056 if
( aError.IsError
() )
1059 aError
= aInst.pClass
->SetNumber
( aInst
, l
);
1065 if
( $1.IsExpression
() )
1066 delete
$1.aExp.pExp
;
1068 if
( aError.IsError
() || aError.IsWarning
() )
1069 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
1074 aError
= S.Top
().pClass
->SetConst
( S.Top
(), $1.hashid
, $1.nValue
);
1075 if
( aError.IsError
() )
1076 { // Aufwaertskompatible, Tupel probieren
1077 RSCINST aInst
= GetFirstTupelEle
( S.Top
() );
1080 aError.Clear
(); // Fehler zuruecksetzen
1081 aError
= aInst.pClass
->SetConst
( aInst
, $1.hashid
, $1.nValue
);
1085 if
( aError.IsError
() || aError.IsWarning
() )
1086 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
1091 aError
= S.Top
().pClass
->SetNotConst
( S.Top
(), $2.hashid
);
1092 if
( aError.IsError
() )
1093 { // Aufwaertskompatible, Tupel probieren
1094 RSCINST aInst
= GetFirstTupelEle
( S.Top
() );
1097 aError.Clear
(); // Fehler zuruecksetzen
1098 aError
= aInst.pClass
->SetNotConst
( aInst
, $2.hashid
);
1102 if
( aError.IsError
() || aError.IsWarning
() )
1103 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
1108 aError
= S.Top
().pClass
->SetBool
( S.Top
(), $1 );
1109 if
( aError.IsError
() )
1110 { // Aufwaertskompatible, Tupel probieren
1111 RSCINST aInst
= GetFirstTupelEle
( S.Top
() );
1114 aError.Clear
(); // Fehler zuruecksetzen
1115 aError
= aInst.pClass
->SetBool
( aInst
, $1 );
1119 if
( aError.IsError
() || aError.IsWarning
() )
1120 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
1125 aError
= S.Top
().pClass
->SetString
( S.Top
(), $1 );
1126 if
( aError.IsError
() )
1127 { // Aufwaertskompatible, Tupel probieren
1128 RSCINST aInst
= GetFirstTupelEle
( S.Top
() );
1131 aError.Clear
(); // Fehler zuruecksetzen
1132 aError
= aInst.pClass
->SetString
( aInst
, $1 );
1136 if
( aError.IsError
() || aError.IsWarning
() )
1137 pTC
->pEH
->Error
( aError
, S.Top
().pClass
, RscId
() );
1143 : '{' list_header list
'}'
1144 |
'<' tupel_header0 tupel_body
';' '>'
1145 |
'<' tupel_header0 tupel_body
';' tupel_header1 tupel_body
';' '>'
1146 |
'<' tupel_header0 tupel_body
';' tupel_header1 tupel_body
';'
1147 tupel_header2 tupel_body
';' '>'
1148 |
'<' tupel_header0 tupel_body
';' tupel_header1 tupel_body
';'
1149 tupel_header2 tupel_body
';' tupel_header3 tupel_body
';' '>'
1162 | string_multiline STRING
1164 rtl
::OStringBuffer aBuf
( 256 );
1167 $$
= const_cast
<char*>(pStringContainer
->putString
( aBuf.getStr
() ));
1174 if
( !$1.Evaluate
( &$$
) )
1175 pTC
->pEH
->Error
( ERR_ZERODIVISION
, NULL
, RscId
() );
1176 if
( $1.IsExpression
() )
1177 delete
$1.aExp.pExp
;
1184 $$.cType
= RSCEXP_DEF
;
1189 $$.cType
= RSCEXP_LONG
;
1192 |
'-' macro_expression %prec UNARYMINUS
1194 if
( $2.IsNumber
() ){
1195 $$.cType
= $2.cType
;
1196 $$.SetLong
( - $2.GetLong
() );
1200 RscExpType aLeftExp
;
1202 aLeftExp.cType
= RSCEXP_NOTHING
;
1203 $$.cType
= RSCEXP_EXP
;
1204 $$.aExp.pExp
= new RscExpression
( aLeftExp
, '-', $2 );
1207 |
'+' macro_expression %prec UNARYPLUS
1211 | macro_expression
'+' macro_expression
1213 if
( $1.IsNumber
() && $3.IsNumber
() )
1215 $$.cType
= RSCEXP_LONG
;
1216 $$.SetLong
( $1.GetLong
() + $3.GetLong
() );
1220 $$.cType
= RSCEXP_EXP
;
1221 $$.aExp.pExp
= new RscExpression
( $1, '+', $3 );
1224 | macro_expression
'-' macro_expression
1226 if
( $1.IsNumber
() && $3.IsNumber
() )
1228 $$.cType
= RSCEXP_LONG
;
1229 $$.SetLong
( $1.GetLong
() - $3.GetLong
() );
1233 $$.cType
= RSCEXP_EXP
;
1234 $$.aExp.pExp
= new RscExpression
( $1, '-', $3 );
1237 | macro_expression
'*' macro_expression
1239 if
( $1.IsNumber
() && $3.IsNumber
() )
1241 $$.cType
= RSCEXP_LONG
;
1242 $$.SetLong
( $1.GetLong
() * $3.GetLong
() );
1246 $$.cType
= RSCEXP_EXP
;
1247 $$.aExp.pExp
= new RscExpression
( $1, '*', $3 );
1250 | macro_expression
'/' macro_expression
1252 if
( $1.IsNumber
() && $3.IsNumber
() )
1254 if
( 0 == $3.GetLong
() )
1256 $$.cType
= RSCEXP_EXP
;
1257 $$.aExp.pExp
= new RscExpression
( $1, '/', $3 );
1261 $$.cType
= RSCEXP_LONG
;
1262 $$.SetLong
( $1.GetLong
() / $3.GetLong
() );
1267 $$.cType
= RSCEXP_EXP
;
1268 $$.aExp.pExp
= new RscExpression
( $1, '/', $3 );
1271 | macro_expression
'&' macro_expression
1273 if
( $1.IsNumber
() && $3.IsNumber
() )
1275 $$.cType
= RSCEXP_LONG
;
1276 $$.SetLong
( $1.GetLong
() & $3.GetLong
() );
1280 $$.cType
= RSCEXP_EXP
;
1281 $$.aExp.pExp
= new RscExpression
( $1, '&', $3 );
1284 | macro_expression
'|' macro_expression
1286 if
( $1.IsNumber
() && $3.IsNumber
() )
1288 $$.cType
= RSCEXP_LONG
;
1289 $$.SetLong
( $1.GetLong
() |
$3.GetLong
() );
1293 $$.cType
= RSCEXP_EXP
;
1294 $$.aExp.pExp
= new RscExpression
( $1, '|', $3 );
1297 |
'(' macro_expression
')'
1301 | macro_expression LEFTSHIFT macro_expression
1303 if
( $1.IsNumber
() && $3.IsNumber
() )
1305 $$.cType
= RSCEXP_LONG
;
1306 $$.SetLong
( $1.GetLong
() << $3.GetLong
() );
1310 $$.cType
= RSCEXP_EXP
;
1311 $$.aExp.pExp
= new RscExpression
( $1, 'l', $3 );
1314 | macro_expression RIGHTSHIFT macro_expression
1316 if
( $1.IsNumber
() && $3.IsNumber
() )
1318 $$.cType
= RSCEXP_LONG
;
1319 $$.SetLong
( $1.GetLong
() >> $3.GetLong
() );
1323 $$.cType
= RSCEXP_EXP
;
1324 $$.aExp.pExp
= new RscExpression
( $1, 'r', $3 );
1330 : id_expression line_number
1332 { // pExpession auswerten und loeschen
1333 if
( RSCEXP_EXP
== $1.cType
)
1337 if
( !$1.Evaluate
( &lValue
) )
1338 pTC
->pEH
->Error
( ERR_ZERODIVISION
, NULL
, RscId
() );
1339 delete
$1.aExp.pExp
;
1340 $$.cType
= RSCEXP_LONG
;
1341 $$.SetLong
( lValue
);
1360 : '#' LINE NUMBER STRING
1364 pFI
->SetLineNo
( $3 );
1365 pFI
->SetFileIndex
( pTC
->aFileTab.NewCodeFile
( rtl
::OString
( $4 ) ) );
1366 pFName
= pTC
->aFileTab.Get
( pFI
->GetFileIndex
() );
1367 pFName
->bLoaded
= true
;
1368 pFName
->bScanned
= true
;
1370 |
'#' NUMBER STRING DUMMY_NUMBER
1374 pFI
->SetLineNo
( $2 );
1375 pFI
->SetFileIndex
( pTC
->aFileTab.NewCodeFile
( rtl
::OString
( $3 ) ) );
1376 pFName
= pTC
->aFileTab.Get
( pFI
->GetFileIndex
() );
1377 pFName
->bLoaded
= true
;
1378 pFName
->bScanned
= true
;
1382 pFI
->SetLineNo
( $2 );
1387 #if defined _MSC_VER
1388 #pragma warning(pop)
1391 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */