Moodle  2.2.1
http://www.collinsharper.com
Parser Class Reference
Inheritance diagram for Parser:

Public Member Functions

 Parser ($byte_order=0)
 _initialize_hashes ()
 _convert ($token)
 _convert_number ($num)
 _convert_function ($token, $num_args)
 _convert_range2d ($range)
 _convert_ref2d ($cell)
 _cell_to_packed_rowcol ($cell)
 _cell_to_rowcol ($cell)
 _advance ()
 _match ($token)
 parse ($formula)
 _expression ()
 _parenthesized_expression ()
 _term ()
 _fact ()
 _func ()
 _create_tree ($value, $left, $right)
 to_reverse_polish ($tree=array())
 __construct ()
 parse ($filename)
 getLine ()
 getLineType ()
 getLineTypeStr ($lineType)
 getTotalLines ()
 getCoveredLines ()
 getUncoveredLines ()

Protected Member Functions

 processLine ($line)
 openFileReadOnly ()

Protected Attributes

 $totalLines
 $coveredLines
 $uncoveredLines
 $fileRef
 $filename
 $line
 $logger

Detailed Description

Definition at line 71 of file Parser.php.


Constructor & Destructor Documentation

Constructor public

Definition at line 50 of file Parser.php.


Member Function Documentation

_advance ( )

Advance to the next valid token.

Definition at line 659 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Parameters:
string$cellThe Excel cell reference to be packed

Definition at line 604 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

_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.

Parameters:
string$cellThe Excel cell reference in A1 format.

Definition at line 631 of file Parser.php.

Here is the caller graph for this function:

_convert ( token)

Convert a token to the proper ptg value.

Parameters:
mixed$tokenThe token to convert.

Definition at line 444 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

_convert_function ( token,
num_args 
)

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

Parameters:
string$tokenThe name of the function for convertion to ptg value.
integer$num_argsThe number of arguments the function recieves.

Definition at line 510 of file Parser.php.

Here is the caller graph for this function:

_convert_number ( num)

Convert a number token to ptgInt or ptgNum

Parameters:
mixed$numan integer or double for conersion to its ptg value

Definition at line 487 of file Parser.php.

Here is the caller graph for this function:

_convert_range2d ( range)

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

Parameters:
string$rangeAn Excel range in the A1:A2 or A1..A2 format.

Definition at line 535 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

_convert_ref2d ( cell)

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

Parameters:
string$cellAn Excel cell reference

Definition at line 576 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

_create_tree ( value,
left,
right 
)

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

Parameters:
mixed$valueThe value of this node.
mixed$leftThe left array (sub-tree) or a final node.
mixed$rightThe right array (sub-tree) or a final node.

Definition at line 938 of file Parser.php.

Here is the caller graph for this function:

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

Returns:
mixed The parsed ptg'd tree

Definition at line 779 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

_fact ( )

It parses a factor. It assumes the following rule: Fact -> ( Expr ) | CellRef | CellRange | Number | Function

Returns:
mixed The parsed ptg'd tree

Definition at line 846 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

_func ( )

It parses a function call. It assumes the following rule: Func -> ( Expr [,Expr]* )

Definition at line 895 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Initialize the ptg and function hashes.

Definition at line 95 of file Parser.php.

Here is the caller graph for this function:

_match ( token)

Checks if it's a valid token.

Parameters:
mixed$tokenThe token to check.

Definition at line 699 of file Parser.php.

Here is the caller graph for this function:

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

See also:
_fact
Returns:
mixed The parsed ptg'd tree

Definition at line 805 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

_term ( )

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

Returns:
mixed The parsed ptg'd tree

Definition at line 817 of file Parser.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the number of covered PHP lines

Returns:
Number of covered lines public

Definition at line 194 of file Parser.php.

getLine ( )

Returns the next line from file.

Returns:
Next line from file public

Definition at line 103 of file Parser.php.

Here is the call graph for this function:

getLineType ( ) [abstract]

Returns the type of last line read.

The type can be either * LINE_TYPE_EXEC Line that can be executed. * LINE_TYPE_NOEXEC Line that cannot be executed. This includes the variable and function definitions (without initialization), blank lines, non-PHP lines, etc.

Returns:
Type of last line public

Reimplemented in PHPParser.

getLineTypeStr ( lineType)

Returns the string representation of LINE_TYPE

Parameters:
$lineType
Returns:
Type of line public

Definition at line 143 of file Parser.php.

Here is the caller graph for this function:

Returns the total lines (PHP, non-PHP) from a file

Returns:
Number of lines public

Definition at line 181 of file Parser.php.

Returns the number of uncovered PHP lines

Note that the sum of covered and uncovered lines may not be equal to total lines.

Returns:
Number of uncovered lines public

Definition at line 210 of file Parser.php.

openFileReadOnly ( ) [protected]

Opens the file to be parsed in Read-only mode

Returns:
FALSE on failure. protected

Reimplemented in PHPParser.

Definition at line 167 of file Parser.php.

Here is the caller graph for this function:

parse ( filename)

Parse a given file

Parameters:
$filenameFull path of the file
Returns:
FALSE on error. public

Definition at line 73 of file Parser.php.

Here is the call graph for this function:

parse ( formula)

The parsing method. It parses a formula.

public

Parameters:
string$formulaThe formula to parse, without the initial equal sign (=).

Definition at line 764 of file Parser.php.

Here is the call graph for this function:

Parser ( byte_order = 0)

The class constructor

Parameters:
integer$byte_orderThe byte order (Little endian or Big endian) of the architecture (optional). 1 => big endian, 0 (default) => little endian.

Definition at line 79 of file Parser.php.

Here is the call graph for this function:

processLine ( line) [abstract, protected]

Process the line and classify it into either covered and uncovered.

Parameters:
$line
Returns:
protected

Reimplemented in PHPParser.

Here is the caller graph for this function:

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

public

Parameters:
array$treeThe optional tree to convert.

Definition at line 969 of file Parser.php.

Here is the call graph for this function:


Field Documentation

$coveredLines [protected]

Definition at line 36 of file Parser.php.

$filename [protected]

Definition at line 39 of file Parser.php.

$fileRef [protected]

Definition at line 38 of file Parser.php.

$line [protected]

Definition at line 41 of file Parser.php.

$logger [protected]

Definition at line 42 of file Parser.php.

$totalLines [protected]

Definition at line 35 of file Parser.php.

$uncoveredLines [protected]

Definition at line 37 of file Parser.php.


The documentation for this class was generated from the following files:
 All Data Structures Namespaces Files Functions Variables Enumerations