Skip to content

Commit

Permalink
ENHANCEMENT: Add a finalise method to complement construct
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamish Friedlander committed Feb 14, 2011
1 parent eb29fe2 commit 53c58a4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Compiler.php
Expand Up @@ -672,7 +672,7 @@ function compile() {
'$result = $this->construct( "'.$function_name.'" );',
'$substack = array();',
$this->parsed->compile()->replace(array(
'MATCH' => 'return $result ;',
'MATCH' => 'return $this->finalise( "'.$function_name.'", $result );',
'FAIL' => 'return FALSE;'
))
);
Expand Down
9 changes: 9 additions & 0 deletions Parser.php
Expand Up @@ -173,6 +173,15 @@ function construct( $name ) {
return $result ;
}

function finalise( $name, &$result ) {
$callback = array( $this, "{$name}__finalise" ) ;
if ( is_callable( $callback ) ) {
call_user_func_array( $callback, array( &$result ) ) ;
}

return $result ;
}

function store ( &$result, $subres, $storetag = NULL ) {
$result['text'] .= $subres['text'] ;

Expand Down

0 comments on commit 53c58a4

Please sign in to comment.