File dsl/ast/DslFunction.class.php

Last commit: Sun Jun 26 15:47:05 2022 +0200	Jan Dankert	Fetched from upstream.
1 <?php 2 3 namespace dsl\ast; 4 5 use dsl\DslParserException; 6 use dsl\DslRuntimeException; 7 use dsl\DslToken; 8 9 class DslFunction extends DslElement implements DslStatement 10 { 11 /** 12 * @var String[] 13 */ 14 public $parameters; 15 16 /** 17 * @var DslStatementList 18 */ 19 public $body; 20 21 /** 22 * creates the function. 23 * 24 * @param array $context 25 * @return mixed|void 26 * @throws DslRuntimeException 27 */ 28 public function execute( & $context ) { 29 30 $clonedContext = $context; 31 return $this->body->execute( $context ); 32 } 33 34 /** 35 * DslFunction constructor. 36 * 37 * @param $functionParameter DslToken[] 38 * @param $functionBody DslStatement 39 * @throws DslParserException 40 */ 41 public function __construct( $functionParameter, $functionBody ) 42 { 43 $this->parameters = []; 44 foreach( $this->splitByComma( $functionParameter ) as $parameter ) { 45 if ( sizeof($parameter) != 1 ) 46 throw new DslParserException('function parameter must be a single name'); 47 $nameToken = $parameter[0]; 48 if ( $nameToken->type == DslToken::T_NONE ) // no parameter 49 continue; 50 if ( $nameToken->type != DslToken::T_STRING ) 51 throw new DslParserException('function parameter must be a name'); 52 53 $this->parameters[] = $nameToken->value; 54 } 55 56 $this->body = new DslStatementList( $functionBody ); 57 } 58 59 public function parse($tokens) 60 { 61 } 62 63 }
Download dsl/ast/DslFunction.class.php
History Sun, 26 Jun 2022 15:47:05 +0200 Jan Dankert Fetched from upstream. Mon, 6 Jun 2022 14:06:46 +0200 Jan Dankert First commit after fetching from upstream repo.