PHP Class Haanga_Generator_PHP

This class takes the generated AST structure (arrays), and generated the PHP represantion.
Mostrar archivo Open project: crodas/haanga

Protected Properties

Property Type Description
$ident
$scopeVariableName
$tab

Public Methods

Method Description
getCode ( array $op_code, $scope ) : string Transform the AST generated by the Haanga_Compiler class and return the equivalent PHP code.
php_comment ( $op ) : string Return code for "comments"
php_function ( $op ) : string Return the function declaration of the class, for now it has fixed params, this should change soon to generate any sort of functions
php_global ( $op ) php_global($op) {{{

Protected Methods

Method Description
ident ( ) : string Get the string for the current tabulation
php_append_var ( $op ) : string Return code to append something to a variable
php_declare ( $op, $assign = ' =' ) : string Return a variable declaration
php_else ( ) : string Return code for "else"
php_end_block ( ) : string Finish the current block (if, for, function, etc), return the final "}", and decrease $this->ident
php_end_for ( ) : string Return code to end a for
php_end_foreach ( ) : string Return code to end a foreach
php_end_function ( ) : string Return code to end a function
php_end_if ( ) : string Return code to end a if
php_exec ( $op ) : string Return code for a function calling.
php_expr ( $op ) : string Return a stand-alone statement
php_for ( $op )
php_foreach ( $op ) : string Return the declaration of a "foreach" statement.
php_generate_expr ( $expr ) : string Return an expression
php_generate_list ( $array ) : string Return a list of expressions for parameters of a function
php_generate_stmt ( $op, $concat = '.' ) : string Return the representation of a statement
php_get_varname ( mixed $var ) : string Return a variable
php_if ( $op ) : string Return the "if" declaration and increase $this->ident
php_inc ( $op ) : string Return increment a variable ($var++)
php_print ( $op ) : string Return an echo of an stmt
php_return ( $op ) : string Return "return"

Method Details

getCode() final public method

@param array $op_code
final public getCode ( array $op_code, $scope ) : string
$op_code array
return string

ident() protected method

@return string
protected ident ( ) : string
return string

php_append_var() protected method

@return string
protected php_append_var ( $op ) : string
return string

php_comment() public method

@return string
public php_comment ( $op ) : string
return string

php_declare() protected method

@return string
protected php_declare ( $op, $assign = ' =' ) : string
return string

php_else() protected method

@return string
protected php_else ( ) : string
return string

php_end_block() protected method

@return string
protected php_end_block ( ) : string
return string

php_end_for() protected method

@return string
protected php_end_for ( ) : string
return string

php_end_foreach() protected method

@return string
protected php_end_foreach ( ) : string
return string

php_end_function() protected method

@return string
protected php_end_function ( ) : string
return string

php_end_if() protected method

@return string
protected php_end_if ( ) : string
return string

php_exec() protected method

@return string
protected php_exec ( $op ) : string
return string

php_expr() protected method

@return string
protected php_expr ( $op ) : string
return string

php_for() protected method

protected php_for ( $op )

php_foreach() protected method

@return string
protected php_foreach ( $op ) : string
return string

php_function() public method

@return string
public php_function ( $op ) : string
return string

php_generate_expr() protected method

@return string
protected php_generate_expr ( $expr ) : string
return string

php_generate_list() protected method

@return string
protected php_generate_list ( $array ) : string
return string

php_generate_stmt() protected method

@return string
protected php_generate_stmt ( $op, $concat = '.' ) : string
return string

php_get_varname() protected method

@param mixed $var
protected php_get_varname ( mixed $var ) : string
$var mixed
return string

php_global() public method

php_global($op) {{{
public php_global ( $op )

php_if() protected method

@return string
protected php_if ( $op ) : string
return string

php_inc() protected method

@return string
protected php_inc ( $op ) : string
return string

php_print() protected method

@return string
protected php_print ( $op ) : string
return string

php_return() protected method

@return string
protected php_return ( $op ) : string
return string

Property Details

$ident protected_oe property

protected $ident

$scopeVariableName protected_oe property

protected $scopeVariableName

$tab protected_oe property

protected $tab