2.5.198.104 Rgce
The Rgce structure specifies a set of Ptgs, laid out sequentially in the file.
The sequence of Ptgs MUST adhere to the following grammar.
EXPRESSION_SIZE is the sum of the sizes of a contiguous set of Ptgs in bytes.
The ACTUAL_PTG_SIZE of a Ptg is as follows:

Ptg
ACTUAL_PTG_SIZE
1 + (stringsize + 1) * 2
where stringsize is the string.cch field of the PtgStr structure
15
7
13
7
13
7
13
9
15
9
16
Any other Ptg
Size of the Ptg in bytes
The ACTUAL_EXPRESSION_SIZE of a contiguous set of Ptgs is the sum of ACTUAL_PTG_SIZEs of those Ptgs. The ACTUAL_EXPRESSION_SIZE of all Ptgs in an Rgce MUST be less than or equal to 1800.
rgce = PtgExp / PtgTbl / [PtgAttrBaxcel / PtgAttrSemi / PtgAttrSpaceSemi] expression
expression = *PtgAttrSpace baseexpression

The value of the type field of each PtgAttrSpace in an expression MUST be 0, 1, or 6.
baseexpression = operand / unaryexpression / binaryreferenceexpression / binaryvalueexpression / displayprecedencespecifier / memareaexpression / functioncall
operand = PtgMissArg / PtgStr / PtgErr / PtgBool / PtgInt / PtgNum / PtgArray / PtgName / PtgRef / PtgArea / PtgRefErr / PtgAreaErr / PtgRefN / PtgAreaN / PtgNameX / PtgRef3d / PtgArea3d / PtgRefErr3d / PtgAreaErr3d / PtgElfLel / PtgElfRw / PtgElfCol / PtgElfRwV / PtgElfColV / PtgElfRadical PtgArea / PtgElfRadical PtgAreaErr / PtgElfRadicalS PtgArea / PtgElfRadicalS PtgAreaErr / PtgElfColS / PtgElfColSV / PtgElfRadicalLel PtgArea / PtgElfRadicalLel PtgAreaErr / PtgSxName

Each Ptg in this definition is an operand token.
unaryexpression = val unaryoperator

Each Ptg in this definition is an operator token.
binaryreferenceexpression = 2ref binaryreferenceoperator

Each Ptg in this definition is an operator token.
binaryvalueexpression = 2val binaryvalueoperator
binaryvalueoperator = PtgAdd / PtgSub / PtgMul / PtgDiv / PtgPower / PtgConcat / PtgLt / PtgLe / PtgEq / PtgGe / PtgGt / PtgNe

Each Ptg in this definition is an operator token.
displayprecedencespecifier = expression [PtgAttrSpace] PtgParen

The value of the type field of a PtgAttrSpace MUST be between 2 and 5 inclusive.

PtgAttrSpace and PtgParen are display tokens.
memareaexpression = memptg binaryreferenceexpression

The cce field in the Ptg of the memptg rule MUST be equal to the EXPRESSION_SIZE of the Ptgs that comprise the binaryreferenceexpression.

If memptg is not PtgMemFunc then the expression elements in the binaryreferenceexpression MUST NOT contain any memptg elements, PtgFunc, PtgFuncVar, PtgName, PtgNameX, PtgRef3d, PtgArea3d, PtgRefErr3d, or PtgAreaErr3d.
memptg = PtgMemArea / PtgMemErr / PtgMemNoMem / PtgMemFunc

Each Ptg in this definition is a mem token.
functioncall = ifexpression / chooseexpression / [paramsfixed] PtgFunc / paramsvariable PtgFuncVar / paramscetab PtgFuncVar / expression PtgAttrSum

The paramsfixed element MUST NOT be specified if PtgFunc specifies a function that takes no parameters. Otherwise, it MUST conform to the ABNF rule for the function specified by PtgFunc.
ifexpression = expression PtgAttrIf 1*2(expression PtgAttrGoto) PtgFuncVar

The value of the offset field in the PtgAttrIf MUST be equal to the EXPRESSION_SIZE of all Ptgs in the ifexpression after the PtgAttrIf through the first PtgAttrGoto.

The value of the offset field in each PtgAttrGoto MUST be equal to one less than the EXPRESSION_SIZE of all Ptgs remaining in the ifexpression after that PtgAttrGoto.

The value of the fCeFunc field of the PtgFuncVar MUST be zero. The value of the tab field of the PtgFuncVar MUST be 0x0001, which represents the IF function.
chooseexpression = expression PtgAttrChoose 1*29(expression PtgAttrGoto) PtgFuncVar

The value of the cOffset field in the PtgAttrChoose MUST be equal to the number of times the expression in the repeated sequence group appears.

The first offset in the array of offsets in the rgOffset field in the PtgAttrChoose MUST be equal to four less than the size of the PtgAttrChoose in bytes.

For the n^{th} occurrence of the repeated sequence group, the (n+1)^{th} offset in the array of offsets in the rgOffset field in the PtgAttrChoose MUST be equal to the EXPRESSION_SIZE of all Ptgs in the chooseexpression after the PtgAttrChoose through the n^{th} PtgAttrGoto.

The value of the offset field in each PtgAttrGoto MUST equal one less than the EXPRESSION_SIZE of all Ptgs remaining in the chooseexpression after that PtgAttrGoto.

The value of the fCeFunc field of the PtgFuncVar MUST be zero. The value of the tab field of the PtgFuncVar MUST be 0x0064, which represents the CHOOSE function.
val = expression

Additional restrictions are specified under VALUE_TYPE. The paramsfixed, paramsvariable and paramscetab rules also use val.
ref = expression

Additional restrictions are specified under VALUE_TYPE. The paramsfixed, paramsvariable and paramscetab rules also use ref.
If the value of the useselfs field of the UsesELFs record is zero then an Rgce MUST NOT contain PtgElfLel, PtgElfRw, PtgElfCol, PtgElfRwV, PtgElfColV, PtgElfRadical, PtgElfRadicalS, PtgElfColS, PtgElfColSV, and PtgElfRadicalLel.
PtgElfLel, PtgElfRw, PtgElfCol, PtgElfRwV, PtgElfColV, PtgElfRadical, PtgElfRadicalS, PtgElfColS, PtgElfColSV, and PtgElfRadicalLel SHOULD NOT<178> be used.
Additional restrictions on the contents of this structure are specified in terms of a parse tree. For this purpose, a parse tree is a means of organizing the components of an Rgce. Each node in the parse tree represents a Ptg or an ABNF rule described previously. Nonleaf nodes represent rules and have one child node for each element in the rule. Leaf nodes represent only a Ptg.
For a leaf node in the parse tree, NESTING_DEPTH is the number of functioncall nodes in the path from the root node to that leaf.
For a node in the parse tree, OPERAND_COUNT is as follows:
The OPERAND_COUNT of each Ptg appearing in the operand rule definition is one.
The OPERAND_COUNT of all other Ptgs is zero.
The OPERAND_COUNT of a node that has n child nodes with nonzero OPERAND_COUNT is equal to the maximum, across all the n child nodes, of (n1) plus the OPERAND_COUNT of the n^{th} child that has nonzero OPERAND_COUNT.
For a node in the parse tree, VALUE_TYPE is a state indicating that the node represents a single value of a simple type or an array of such values. A node that is not a VALUE_TYPE represents a reference to a range. Elements in an expression MUST represent either values or references, based on the specific Ptgs used in the expression. The following rules specify how to traverse the parse tree from the bottom up and determine whether each node is a VALUE_TYPE, which determines whether the sequence of Ptgs comprising the formula correctly satisfies the requirements of each expression in the formula. A node is determined to be a VALUE_TYPE as follows:
Leaf nodes:
PtgMissArg, PtgStr, PtgSxName, PtgErr, PtgBool, PtgInt, PtgNum, PtgArray, PtgRefErr, PtgAreaErr, PtgRefErr3d, PtgAreaErr3d, PtgElfLel, PtgElfRwV, PtgElfColV, PtgElfColSV, PtgElfRadicalLel, PtgUplus, PtgUminus, PtgPercent, PtgAdd, PtgSub, PtgMul, PtgDiv, PtgPower, PtgConcat, PtgLt, PtgLe, PtgEq, PtgGe, PtgGt, and PtgNe leaf nodes are VALUE_TYPEs.
PtgName, PtgRef, PtgArea, PtgRefN, PtgAreaN, PtgNameX, PtgRef3d, PtgArea3d, PtgFunc, PtgFuncVar, PtgMemArea, PtgMemErr, PtgMemNoMem, and PtgMemFunc leaf nodes are VALUE_TYPEs if and only if the value of the type field is value or array.
All other leaf nodes are not VALUE_TYPEs.
Nonleaf nodes:
Any nonleaf node with a single child node MUST be a VALUE_TYPE if and only if the child node is a VALUE_TYPE.
Any nonleaf node with a memptg, unaryoperator, binaryvalueoperator, binaryreferenceoperator, PtgAttrSum, PtgFunc or PtgFuncVar child node is a VALUE_TYPE if and only if that child node is a VALUE_TYPE. Other child nodes are ignored for the purposes of determining whether the nonleaf node is a VALUE_TYPE.
Any nonleaf node corresponding to a val rule MUST be a VALUE_TYPE.
Any nonleaf node corresponding to a ref rule MUST NOT be a VALUE_TYPE.
Otherwise, a nonleaf node with an expression child node is a VALUE_TYPE if and only if that expression child node is a VALUE_TYPE.
A parse tree for an Rgce MUST meet the following conditions:
The NESTING_DEPTH of each leaf node MUST NOT exceed 8.
The OPERAND_COUNT of the root node MUST NOT exceed 40.










1 









2 









3 


sequence (variable) 

... 
sequence (variable): An array of Ptg that specifies the sequence of Ptgs.