Class PhpMyCellScript

Description

The PhpMyCellScript interpreter.

Call run() to start the interpreter.

Located in /PhpMyCellScript.php (line 30)


	
			
Class Constant Summary
Variable Summary
Method Summary
static string createStringFromCellArray ( $cell_array, [ $row_separator = null], [ $cell_separator = null], [ $prefix = null], [ $suffix = null], array $cell_array:, string $row_separator:, string $cell_separator:, string $prefix:, string $suffix:)
static the processVariableNumberOfStringArguments ( $arguments,  $output_variable,  $expanded_strings)
static the processVariableNumberOfValueArguments ( $arguments,  $output_variable,  $values)
PhpMyCellScript __construct ()
void cmd_ARGV ( $argument_variables,  $code_to_eval)
void cmd_BREAK ( $num_of_loops_to_break, PhpMyCellScript $interpreter)
void cmd_C ()
void cmd_CALL ( $sheet_name,  $arguments,  $output_variable,  $values, PhpMyCellScript $interpreter)
void cmd_CATCH ( $exception_type,  $inner_exception,  $sheet_name,  $instruction_name,  $row_number, PhpMyCellScript $interpreter)
void cmd_COMMENT ()
void cmd_CONTINUE ( $loop_index, PhpMyCellScript $interpreter)
void cmd_ELSE (PhpMyCellScript $interpreter)
void cmd_ELSEIF ( $condition, PhpMyCellScript $interpreter)
void cmd_EVAL ( $php_code,  $code_to_eval)
void cmd_FOREACH ( $iterator_string,  $value_variable,  $key_variable, PhpMyCellScript $interpreter,  $values)
void cmd_IF ( $condition, PhpMyCellScript $interpreter)
void cmd_INCLUDE ( $sheet_name, PhpMyCellScript $interpreter)
void cmd_RETURN ( $return_value, PhpMyCellScript $interpreter)
void cmd_THROW ( $exception)
void cmd_TRACE_START ( $code_to_eval_on_start,  $code_to_eval_per_instruction,  $code_to_eval, PhpMyCellScript $interpreter)
void cmd_TRACE_STOP ( $code_to_eval_on_stop,  $code_to_eval, PhpMyCellScript $interpreter)
void cmd_TRY (PhpMyCellScript $interpreter)
void cmd_WHILE ( $condition, PhpMyCellScript $interpreter)
array collectCellValues ([boolean $keep_empty_row = false])
void enterCatchBlock ()
void enteredIfBranch ()
boolean enterElseBranchConditionally ([boolean $condition = true])
void enterIfBranch ()
void enterTryBlock ()
void enterWhileLoop ()
array &findLastInstructionData (string $full_instruction_name)
void registerAddon (object $addon)
void registerAddonByName (string $addon_name)
mixed run (Excel.Application $excel, Excel.Worksheet $worksheet, array $argv)
void __clone ()
Variables
array $addons = array() (line 65)

The addons, which may support new instructions.

If multiple addons support an instruction, the instruction will be processed by the last addon.

  • access: protected
mixed $addon_output (line 52)

May be used by the addons to return values.

  • access: public
string $code_to_eval_per_instruction (line 58)

The code to evaluate before interpreting an instruction. For program trace/debug purpose.

  • access: public
Excel.Application $excel (line 71)

The current Excel document.

  • access: protected
array $if_like_instructions = array('IF', 'ELSEIF', 'FOREACH') (line 39)

The IF-like instructions which support the ELSE instruction.

To be read by the PhpMyCellScript interpreter.

  • access: public
array $while_like_instructions = array('WHILE', 'FOREACH') (line 46)

The WHILE-like instructions.

To be read by the PhpMyCellScript interpreter.

  • access: public
array $working_sheet_names (line 83)

The INCLUDE instruction will add a working sheet after switched to a new sheet.

  • access: protected
array $working_sheet_states (line 77)

The INCLUDE instruction will save the state of the current sheet before processing a new sheet.

  • access: protected
Methods
static method createStringFromCellArray (line 430)

Utility: Form a string from strings in a cell array.

Trailing empty cells in each row will be ignored.

  • return: The output string.
static string createStringFromCellArray ( $cell_array, [ $row_separator = null], [ $cell_separator = null], [ $prefix = null], [ $suffix = null], array $cell_array:, string $row_separator:, string $cell_separator:, string $prefix:, string $suffix:)
  • array $cell_array:: a cell array with strings.
  • string $row_separator:: the separator to add between rows, like \n.
  • string $cell_separator:: the separator to add between cells, like \t.
  • string $prefix:: the prefix string to add before the first row.
  • string $suffix:: the suffix string to add after the last row.
  • $cell_array
  • $row_separator
  • $cell_separator
  • $prefix
  • $suffix
static method processVariableNumberOfStringArguments (line 232)

Utility: Used by instruction methods to process a variable argument list of string arguments:

argument1 argument2 ... argumentn output_variable

  • return: arguments (excluding the output variable), where variables are expanded; false if multi-phase process is needed.
static the processVariableNumberOfStringArguments ( $arguments,  $output_variable,  $expanded_strings)
  • array $arguments: the argument list to process. The last non-empty element is the name of the output variable.
  • DynamicOutputVariable $output_variable: For requesting the output variable dynamically.
  • DynamicVariableExpandedStrings $expanded_strings: For requesting strings to expand dynamically.
static method processVariableNumberOfValueArguments (line 269)

Utility: Used by instruction methods to process a variable argument list of value arguments:

argument1 argument2 ... argumentn output_variable

  • return: arguments (excluding the output variable), where expressions are evaluated; false if multi-phase process is needed.
static the processVariableNumberOfValueArguments ( $arguments,  $output_variable,  $values)
  • array $arguments: the argument list to process. The last non-empty element is the name of the output variable.
  • DynamicOutputVariable $output_variable: For requesting the output variable dynamically.
  • DynamicPhpExpressionValues $values: For requesting expressions to evaluate dynamically.
Constructor __construct (line 106)

Constructor

PhpMyCellScript __construct ()
cmd_ARGV (line 907)

This instruction assigns argument values in $argv to the given variables.

This instruction makes it more convenient to obtain arguments passed by the CALL instruction.

Syntax: ARGV [argument_variable1] [argument_variable2] ... [argument_variablen]

  • argument_variable1..n: the variables for returning the arguments. (optional)

void cmd_ARGV ( $argument_variables,  $code_to_eval)
cmd_BREAK (line 799)

This instruction breaks a WHILE-like loop.

Syntax: BREAK [num_of_loops_to_break]

  • num_of_loops_to_break: The number of loops to break. Default: 1. (optional)

void cmd_BREAK ( $num_of_loops_to_break, PhpMyCellScript $interpreter)
cmd_C (line 943)

This instruction marks a comment.

It should be clearer and more convenient to use a short instruction name to mark a comment.

Syntax: C [comment]

void cmd_C ()
cmd_CALL (line 888)

This instruction runs the instructions in a sheet in another variable scope.

Syntax: CALL sheet_name [argument1 argument2 ... argumentn output_variable]

  • sheet_name: the name of the sheet to call, where variables will be parsed.
  • argument1..n: the arguments of the sheet. (optional)
  • output_variable: a variable for returning the output of the sheet. This is in the last non-empty cell. Optional if no argument is given.

void cmd_CALL ( $sheet_name,  $arguments,  $output_variable,  $values, PhpMyCellScript $interpreter)
cmd_CATCH (line 1005)

This instruction tries to handle an exception.

Syntax: CATCH exception_type inner_exception sheet_name instruction_name row_number

If the exception can be handled, then the instructions in the next column will be processed.

void cmd_CATCH ( $exception_type,  $inner_exception,  $sheet_name,  $instruction_name,  $row_number, PhpMyCellScript $interpreter)
cmd_COMMENT (line 934)

This instruction marks a comment.

Syntax: COMMENT [comment]

void cmd_COMMENT ()
cmd_CONTINUE (line 827)

This instruction continues a WHILE-like loop.

Syntax: CONTINUE [loop_index]

  • loop_index: identify which loop to continue (one-based). Default: 1. (optional)

void cmd_CONTINUE ( $loop_index, PhpMyCellScript $interpreter)
cmd_ELSE (line 726)

This instruction supports an alternative branch for the IF and some other instructions.

Syntax: ELSE

If no previous branch is executed, then the instructions in the next column will be processed.

void cmd_ELSE (PhpMyCellScript $interpreter)
cmd_ELSEIF (line 715)

This instruction supports alternative branches for the IF and some other instructions.

Syntax: ELSEIF condition

  • condition: The condition to evaluate.
If no previous branch is executed and the condition is evaluated to a true value, then the instructions in the next column will be processed.

void cmd_ELSEIF ( $condition, PhpMyCellScript $interpreter)
cmd_EVAL (line 687)

This instruction evaluates some PHP code, which makes it easier to run PHP code in the spreadsheet.

Syntax: EVAL php_code

  • php_code: the PHP code to pass to the eval() function.

void cmd_EVAL ( $php_code,  $code_to_eval)
cmd_FOREACH (line 755)

This instruction provides the PHP foreach construct to the spreadsheet.

Syntax: FOREACH array/iterator [value_variable] [key_variable]

  • array/iterator: The array or object or Iterator to be iterated on.
  • value_variable: a variable for returning the current element in each iteration. (optional)
  • key_variable: a variable for returning the key of the current element in each iteration. (optional)
The instructions in the next column will be processed for each element.

void cmd_FOREACH ( $iterator_string,  $value_variable,  $key_variable, PhpMyCellScript $interpreter,  $values)
cmd_IF (line 700)

This instruction provides the IF construct to the spreadsheet.

Syntax: IF condition

  • condition: the condition to evaluate.
If the condition is evaluated to a true value, then the instructions in the next column will be processed.

void cmd_IF ( $condition, PhpMyCellScript $interpreter)
cmd_INCLUDE (line 865)

This instruction enables the instructions in another sheet to be processed, which makes it possible to share instructions in the spreadsheet.

Syntax: INCLUDE sheet_name

  • sheet_name: the name of the sheet to include, where variables will be parsed.

void cmd_INCLUDE ( $sheet_name, PhpMyCellScript $interpreter)
cmd_RETURN (line 922)

This instruction ends the process of the current sheet.

Syntax: RETURN [return_value]

  • return_value: the value to return. (optional)

void cmd_RETURN ( $return_value, PhpMyCellScript $interpreter)
cmd_THROW (line 980)

This instruction throws an exception.

Syntax: THROW exception

  • exception: the exception to throw.

void cmd_THROW ( $exception)
  • $exception
cmd_TRACE_START (line 954)

This instruction injects some PHP code to the interpreter to evaluate, before each instruction is interpreted.

This instruction may be used for program trace/debug purpose.

Syntax: TRACE_START [code_to_eval_on_start] [code_to_eval_per_instruction]

  • code_to_eval_on_start: the PHP code to evaluate on trace start. May be used to initialize some variables. (optional)
  • code_to_eval_per_instruction: the PHP code to inject to the interpreter. The interpreter state will be printed by default. (optional)

void cmd_TRACE_START ( $code_to_eval_on_start,  $code_to_eval_per_instruction,  $code_to_eval, PhpMyCellScript $interpreter)
cmd_TRACE_STOP (line 968)

This instruction removes the code injected by TRACE_START.

Syntax: TRACE_STOP [code_to_eval_on_stop]

  • code_to_eval_on_stop: the PHP code to evaluate on trace stop. May be used to summarize the trace result. (optional)

void cmd_TRACE_STOP ( $code_to_eval_on_stop,  $code_to_eval, PhpMyCellScript $interpreter)
cmd_TRY (line 994)

This instruction indicates that the following code in the next column may throw exceptions.

Syntax: TRY

void cmd_TRY (PhpMyCellScript $interpreter)
cmd_WHILE (line 738)

This instruction provides WHILE loop support to the spreadsheet.

Syntax: WHILE condition

  • condition: the condition to evaluate.
If the condition is evaluated to a true value, then the instructions in the next column will be processed.

void cmd_WHILE ( $condition, PhpMyCellScript $interpreter)
collectCellValues (line 398)

Collect the cell values after the current row and the current column.

The current row will be updated after a row is processed.

  • return: The cell values.
array collectCellValues ([boolean $keep_empty_row = false])
  • boolean $keep_empty_row: Indicate whether to keep the empty rows.
enterCatchBlock (line 365)

Used by the CATCH instruction to enter the exception handling code.

void enterCatchBlock ()
enteredIfBranch (line 351)

Used by the interpreter to indicate whether the IF branch has been entered, used by the ELSE-like instructions.

void enteredIfBranch ()
enterElseBranchConditionally (line 330)

Used by an addon instruction method for an ELSE-like instruction to enter the ELSE branch conditionally.

  • return: Return true if the ELSE branch will be entered, false otherwise.
boolean enterElseBranchConditionally ([boolean $condition = true])
  • boolean $condition: The ELSE branch will be entered if the condition is true, and if no previous branch is entered before.
enterIfBranch (line 320)

Used by an addon instruction method for an IF-like instruction to enter the IF branch.

void enterIfBranch ()
enterTryBlock (line 358)

Used by the TRY instruction to enter the code which may throw exceptions.

void enterTryBlock ()
enterWhileLoop (line 309)

Used by an addon instruction method for a WHILE-like instruction to enter the while loop.

void enterWhileLoop ()
findLastInstructionData (line 383)

Find the last instruction data of an instruction before the current column.

  • return: The reference to the last instruction data of the instruction.
array &findLastInstructionData (string $full_instruction_name)
  • string $full_instruction_name: The full name of the instruction to find.
getCurrentInstructionData (line 374)

Get the reference to the instruction data of the instruction in the current column.

  • return: The reference to the instruction data of the instruction.
array &getCurrentInstructionData ()
getCurrentSheetState (line 302)

Get the interpreter states for the current working sheet.

  • return: null if no working sheet.
InterpreterSheetState getCurrentSheetState ()
registerAddon (line 128)

Register a PhpMyCellScript addon.

void registerAddon (object $addon)
  • object $addon
registerAddonByName (line 139)

Register a PhpMyCellScript addon, by its name.

Assume that the addon is put in the directory and namespace PhpMyCellScript\Addons.

void registerAddonByName (string $addon_name)
  • string $addon_name
run (line 447)

Start the PhpMyCellScript interpreter.

  • return: The value returned by the RETURN instruction of the ending sheet.
mixed run (Excel.Application $excel, Excel.Worksheet $worksheet, array $argv)
  • Excel.Application $excel
  • Excel.Worksheet $worksheet
  • array $argv: Code generator specific arguments.
__clone (line 113)
void __clone ()
Class Constants
version = 2 (line 31)
version_minor = 19 (line 32)

Documentation generated on Sun, 01 Mar 2015 08:43:49 +0000 by phpDocumentor 1.4.3