Class Trees Index phpDocumentor Project Page

Class Parser

(line 71)

Located in File: Program_Root/Parser.php


Class for parsing Excel formulas

Class Variable Summary


Inherited Class Variable Summary


Method Summary

void

parse ( $formula )


The parsing method. It parses a formula.
void

constructor Parser ( [$byte_order = 0] )


The class constructor
void

to_reverse_polish ( [$tree = array()] )


Builds a string containing the tree in reverse polish notation (What you would use in a HP calculator stack).
void

_advance ( )


Advance to the next valid token.
void

_cell_to_packed_rowcol ( $cell )


pack() row and column into the required 3 byte format.
void

_cell_to_rowcol ( $cell )


Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero indexed row and column number. Also returns two boolean values to indicate whether the row or column are relative references.
void

_convert ( $token )


Convert a token to the proper ptg value.
void

_convert_function ( $token, $num_args )


Convert a function to a ptgFunc or ptgFuncVarV depending on the number of args that it takes.
void

_convert_number ( $num )


Convert a number token to ptgInt or ptgNum
void

_convert_range2d ( $range )


Convert an Excel range such as A1:D4 to a ptgRefV.
void

_convert_ref2d ( $cell )


Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV.
void

_create_tree ( $value, $left, $right )


Creates a tree. In fact an array which may have one or two arrays (sub-trees) as elements.
mixed

_expression ( )


It parses a expression. It assumes the following rule: Expr -> Term [("+" | "-") Term]
mixed

_fact ( )


It parses a factor. It assumes the following rule:
void

_func ( )


It parses a function call. It assumes the following rule:
void

_initialize_hashes ( )


Initialize the ptg and function hashes.
void

_match ( $token )


Checks if it's a valid token.
mixed

_parenthesized_expression ( )


This function just introduces a ptgParen element in the tree, so that Excel doesn't get confused when working with a parenthesized formula afterwards.
mixed

_term ( )


It parses a term. It assumes the following rule: Term -> Fact [("*" | "/") Fact]

Inherited Method Summary


Method Detail

parse (line 764)

void

parse ( $formula )

The parsing method. It parses a formula.
Function Info:
Access - public

[ Top ]


Parser (line 79)

void

constructor Parser ( [$byte_order = 0] )

The class constructor
Function Info:

[ Top ]


to_reverse_polish (line 969)

void

to_reverse_polish ( [$tree = array()] )

Builds a string containing the tree in reverse polish notation (What you would use in a HP calculator stack).

The following tree:

+ / \ 2 3

produces: "23+"

The following tree:

+ / \ 3 * / \ 6 A1

produces: "36A1*+"

In fact all operands, functions, references, etc... are written as ptg's

Function Info:
Access - public

[ Top ]


_advance (line 659)

void

_advance ( )

Advance to the next valid token.
Function Info:

[ Top ]


_cell_to_packed_rowcol (line 604)

void

_cell_to_packed_rowcol ( $cell )

pack() row and column into the required 3 byte format.
Function Info:

[ Top ]


_cell_to_rowcol (line 631)

void

_cell_to_rowcol ( $cell )

Convert an Excel cell reference such as A1 or $B2 or C$3 or $D$4 to a zero indexed row and column number. Also returns two boolean values to indicate whether the row or column are relative references.
Function Info:

[ Top ]


_convert (line 444)

void

_convert ( $token )

Convert a token to the proper ptg value.
Function Info:

[ Top ]


_convert_function (line 510)

void

_convert_function ( $token, $num_args )

Convert a function to a ptgFunc or ptgFuncVarV depending on the number of args that it takes.
Function Info:

[ Top ]


_convert_number (line 487)

void

_convert_number ( $num )

Convert a number token to ptgInt or ptgNum
Function Info:

[ Top ]


_convert_range2d (line 535)

void

_convert_range2d ( $range )

Convert an Excel range such as A1:D4 to a ptgRefV.
Function Info:

[ Top ]


_convert_ref2d (line 576)

void

_convert_ref2d ( $cell )

Convert an Excel reference such as A1, $B2, C$3 or $D$4 to a ptgRefV.
Function Info:

[ Top ]


_create_tree (line 938)

void

_create_tree ( $value, $left, $right )

Creates a tree. In fact an array which may have one or two arrays (sub-trees) as elements.
Function Info:

[ Top ]


_expression (line 779)

mixed

_expression ( )

It parses a expression. It assumes the following rule: Expr -> Term [("+" | "-") Term]
Function Info:
Return - The parsed ptg'd tree

[ Top ]


_fact (line 846)

mixed

_fact ( )

It parses a factor. It assumes the following rule:

Fact -> ( Expr ) | CellRef | CellRange | Number | Function

Function Info:
Return - The parsed ptg'd tree

[ Top ]


_func (line 895)

void

_func ( )

It parses a function call. It assumes the following rule:

Func -> ( Expr [,Expr]* )

Function Info:

[ Top ]


_initialize_hashes (line 95)

void

_initialize_hashes ( )

Initialize the ptg and function hashes.
Function Info:

[ Top ]


_match (line 699)

void

_match ( $token )

Checks if it's a valid token.
Function Info:

[ Top ]


_parenthesized_expression (line 805)

mixed

_parenthesized_expression ( )

This function just introduces a ptgParen element in the tree, so that Excel doesn't get confused when working with a parenthesized formula afterwards.
Function Info:
Return - The parsed ptg'd tree
See - _fact">_fact

[ Top ]


_term (line 817)

mixed

_term ( )

It parses a term. It assumes the following rule: Term -> Fact [("*" | "/") Fact]
Function Info:
Return - The parsed ptg'd tree

[ Top ]



Variable Detail



Documention generated on Wed, 30 Apr 2003 11:14:31 -0400 by phpDocumentor 1.2.0