openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

DslSequence.class.php (668B)


      1 <?php
      2 
      3 namespace dsl\ast;
      4 
      5 use dsl\DslRuntimeException;
      6 
      7 class DslSequence implements DslStatement
      8 {
      9 	public $left;
     10 	public $right;
     11 
     12 
     13 	/**
     14 	 * DslSequence constructor.
     15 	 * @param $left
     16 	 * @param $right
     17 	 */
     18 	public function __construct($left, $right)
     19 	{
     20 		$this->left  = $left;
     21 		$this->right = $right;
     22 	}
     23 
     24 
     25 	public function execute( & $context ) {
     26 
     27 		// Creating a sequence
     28 		$left  = $this->left->execute( $context );
     29 		$right = $this->right->execute( $context );
     30 
     31 		// cast to array
     32 		if   ( !is_array( $left ) )  $left  = [$left ];
     33 		if   ( !is_array( $right) )  $right = [$right];
     34 
     35 		return array_merge( $left,$right);
     36 	}
     37 
     38 	public function parse($tokens)
     39 	{
     40 	}
     41 }