07.05.2014 Views

The Microsoft Excel File Format - OpenOffice.org

The Microsoft Excel File Format - OpenOffice.org

The Microsoft Excel File Format - OpenOffice.org

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.1 Common Formula Structure<br />

3.1.3 Token Notation<br />

Tokens are referred to by their name. All token names start with a small “t” (for “Token”). If a token contains additional<br />

information, it is appended to the token name in parentheses.<br />

Examples:<br />

<strong>The</strong> addition operator + is represented by the token tAdd. It does not contain any additional data.<br />

<strong>The</strong> integer constant 1 is represented by the token tInt(1).<br />

An absolute reference to cell $A$1 is represented by the token tRef($A$1).<br />

3.1.4 Operators<br />

<strong>The</strong>re are 3 types of operators:<br />

• Unary operators like the minus sign that negates a value. <strong>The</strong>se operators pop the topmost operand from the stack.<br />

• Binary operators like addition or multiplication. <strong>The</strong>se operators pop the two topmost operands from the stack.<br />

• Function operators represent the sheet functions of <strong>Excel</strong>. <strong>The</strong>y operate on different numbers of topmost operands on<br />

the stack. Either the function expects a fixed number of operands (for instance SIN expects one operand), or a<br />

variable number of operands given in the function token (for instance SUM is able to process 0 to 30 operands).<br />

All operators push the (single) result of their operation back onto the stack.<br />

3.1.5 Token Arrays<br />

Definition: Token array<br />

<strong>The</strong> token array represents an entire formula and contains all used tokens of the formula in a specific order.<br />

<strong>The</strong> tokens of the formula are stored in the Reverse-Polish Notation (RPN). This means, first there occur all operands of<br />

an operation, followed by the respective operator.<br />

Example: the simple term 1+2 consists of the 3 tokens “1”, “+” and “2”. Written in RPN, the formula is<br />

converted to the token list “1”, “2”, “+”.<br />

During parsing such an expression, operands are pushed onto a stack. An operator pops the needed number of operands<br />

from stack, performs the operation and pushes the result back onto the stack.<br />

29

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!