2.5.98.88 Rgce

The Rgce structure specifies a set of Ptgs, laid out sequentially in the file.

The sequence of Ptg (section 2.5.98.16) structures MUST adhere to the following grammar.

EXPRESSION_SIZE is the sum of the sizes of a contiguous set of Ptgs in bytes.

rgce = PtgExp / [PtgAttrBaxcel / PtgAttrSemi / PtgAttrSpaceSemi] expression

expression = (*(PtgAttrSpace) base-expression) / solo-function

The value of the type field of each PtgAttrSpace (section 2.5.98.30) in an expression MUST be 0, 1, or 6.

solo-function = PtgName py-params PtgFuncVar

            The PtgName (section 2.5.98.60) MUST contain a nameindex field that specifies a BrtName (section 2.4.711) record that has a fFutureFunction field with value 1 and a name field with value “_xlfn._xlws.PY” (case-insensitive).

solo-function MUST match the function-call rule.

base-expression = operand / unary-expression / binary-reference-expression / binary-value-expression / display-precedence-specifier / mem-area-expression / function-call

operand = PtgMissArg / PtgStr / PtgErr / PtgBool / PtgInt / PtgNum / PtgArray / PtgName / PtgRef / PtgArea / PtgRefErr / PtgAreaErr / PtgRefN / PtgAreaN / PtgNameX / PtgRef3d / PtgArea3d / PtgRefErr3d / PtgAreaErr3d / PtgList / PtgSxName

Each Ptg in this definition is an operand token (section 2.2.2.2).

unary-expression = val unary-operator

unary-operator = PtgUPlus / PtgUMinus / PtgPercent

Each Ptg in this definition is a unary operator token.

binary-reference-expression = 2ref binary-reference-operator

binary-reference-operator = PtgIsect / PtgUnion / PtgRange

Each Ptg in this definition is a binary operator token.

binary-value-expression = 2val binary-value-operator

binary-value-operator = PtgAdd / PtgSub / PtgMul / PtgDiv / PtgPower / PtgConcat / PtgLt / PtgLe / PtgEq / PtgGe / PtgGt / PtgNe

Each Ptg in this definition is a binary operator token.

display-precedence-specifier = expression [PtgAttrSpace] PtgParen

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

PtgAttrSpace and PtgParen (section 2.5.98.64) are display tokens (section 2.2.2.4).

mem-area-expression = mem-ptg binary-reference-expression

The cce field in the Ptg of the mem-ptg rule MUST be equal to the EXPRESSION_SIZE of the Ptgs that comprise the binary-reference-expression.

If mem-ptg is not equal to PtgMemFunc (section 2.5.98.56), then both expression elements in the binary-reference-expression MUST NOT contain any mem-ptg elements, PtgFunc (section 2.5.98.45), PtgFuncVar (section 2.5.98.46), PtgName (section 2.5.98.60), PtgNameX (section 2.5.98.61), PtgList (section 2.5.98.52), PtgRef3d (section 2.5.98.69), PtgArea3d (section 2.5.98.19), PtgRefErr3d (section 2.5.98.71), or PtgAreaErr3d (section 2.5.98.21).

mem-ptg = PtgMemArea / PtgMemErr / PtgMemNoMem / PtgMemFunc

Each Ptg in this definition is a mem token (section 2.2.2.5).

function-call = if-expression / iferror-expression / choose-expression / [params-fixed] PtgFunc / params-variable PtgFuncVar / params-cetab PtgFuncVar / expression PtgAttrSum

The params-fixed (section 2.5.98.10) 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.

if-expression = expression PtgAttrIf 1*2(expression PtgAttrGoTo) PtgFuncVar

The value of the offset field in the PtgAttrIf (section 2.5.98.27) MUST be equal to the EXPRESSION_SIZE of all Ptgs in the if-expression after the PtgAttrIf through the first PtgAttrGoTo (section 2.5.98.26).

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 if-expression after that PtgAttrGoTo.

The value of the fCeFunc field of the PtgFuncVar MUST be 0. The value of the tab field of the PtgFuncVar MUST be 0x0001, which represents the IF function.

iferror-expression = expression PtgAttrIfError expression PtgAttrGoTo PtgFunc

The value of the offset field in the PtgAttrIfError (section 2.5.98.28) MUST be equal to the EXPRESSION_SIZE of all Ptgs in the iferror-expression after the PtgAttrIfError through the first PtgAttrGoTo.

The value of the offset field in the PtgAttrGoTo MUST be equal to one less than the EXPRESSION_SIZE of the PtgFunc.

The value of the iftab field of the PtgFunc MUST be 0x01E0, which represents the IFERROR function.

choose-expression = expression PtgAttrChoose 1*254(expression PtgAttrGoTo) PtgFuncVar

The value of the cOffset field in the PtgAttrChoose (section 2.5.98.25) 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 nth 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 choose-expression after the PtgAttrChoose through the nth PtgAttrGoTo.

The value of the offset field in each PtgAttrGoTo MUST equal one less than the EXPRESSION_SIZE of all Ptgs remaining in the choose-expression after that PtgAttrGoTo.

The value of the fCeFunc field of the PtgFuncVar MUST be 0. 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 params-fixed, params-variable (section 2.5.98.10), and params-cetab (section 2.5.98.5) rules also use val.

ref = expression

Additional restrictions are specified under VALUE_TYPE. The params-fixed, params-variable, and params-cetab rules also use ref.

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 earlier. Non-leaf 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 function-call 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 0.

  • 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 (n-1) plus the OPERAND_COUNT of the nth 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 Ptg structures comprising the formula (section 2.2.2) correctly satisfies the requirements of each expression in the formula. A node is determined to be a VALUE_TYPE as follows:

  • Leaf nodes:

    • PtgMissArg (section 2.5.98.58), PtgStr (section 2.5.98.74), PtgSxName (section 2.5.98.76), PtgErr (section 2.5.98.39), PtgBool (section 2.5.98.34), PtgInt (section 2.5.98.49), PtgNum (section 2.5.98.63), PtgArray (section 2.5.98.23), PtgRefErr (section 2.5.98.70), PtgAreaErr (section 2.5.98.20), PtgRefErr3d (section 2.5.98.71), PtgAreaErr3d (section 2.5.98.21), PtgUPlus (section 2.5.98.79), PtgUMinus (section 2.5.98.77), PtgPercent (section 2.5.98.65), PtgAdd (section 2.5.98.17), PtgSub (section 2.5.98.75), PtgMul (section 2.5.98.59), PtgDiv (section 2.5.98.37), PtgPower (section 2.5.98.66), PtgConcat (section 2.5.98.35), PtgLt (section 2.5.98.53), PtgLe (section 2.5.98.51), PtgEq (section 2.5.98.38), PtgGe (section 2.5.98.47), PtgGt (section 2.5.98.48), and PtgNe leaf nodes are VALUE_TYPEs.

    • PtgName (section 2.5.98.60), PtgRef (section 2.5.98.68), PtgArea (section 2.5.98.18), PtgRefN (section 2.5.98.72), PtgAreaN (section 2.5.98.22), PtgNameX (section 2.5.98.61), PtgRef3d (section 2.5.98.69), PtgArea3d (section 2.5.98.19), PtgFunc (section 2.5.98.45), PtgFuncVar (section 2.5.98.46), PtgMemArea (section 2.5.98.54), PtgMemErr (section 2.5.98.55), PtgMemNoMem (section 2.5.98.57), and PtgMemFunc (section 2.5.98.56) leaf nodes are VALUE_TYPEs if and only if the value of the type field is value or array.

    • PtgList leaf nodes are VALUE_TYPEs if and only if the type field equals 1.

    • All other leaf nodes are not VALUE_TYPEs.

  • Non-leaf nodes:

    • Any non-leaf node with a single child node MUST be a VALUE_TYPE if and only if the child node is a VALUE_TYPE.

    • Any non-leaf node with a mem-ptg, unary-operator, binary-value-operator, binary-reference-operator, PtgAttrSum (section 2.5.98.33), 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 non-leaf node is a VALUE_TYPE.

    • Any non-leaf node corresponding to a val rule MUST be a VALUE_TYPE.

    • Any non-leaf node corresponding to a ref rule MUST NOT be a VALUE_TYPE.

    • Otherwise, a non-leaf 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 65.

  • The OPERAND_COUNT of the root node MUST NOT exceed 1024.


0


1


2


3


4


5


6


7


8


9

1
0


1


2


3


4


5


6


7


8


9

2
0


1


2


3


4


5


6


7


8


9

3
0


1

sequence (variable)

...

sequence (variable): An array of Ptg that specifies the sequence of Ptg structures. sequence of Ptg (section 2.5.98.16) structures