public function parseString($string)
    {
        $tokens = $this->tokenize($string);

        $tokens = array_filter(
            $tokens,
            function ($token) {
                return !($token['type'] === TransformationProcessor::T_WHITESPACE ||
                          $token['type'] === TransformationProcessor::T_COMMENT);
            }
        );

        $ast = array();
        $section = null;
        while ($token = array_shift($tokens)) {
            if ($token['type'] === TransformationProcessor::T_SECTION) {
                $section = $token['data']['section'];
                continue;
            }

            if ($section === null) {
                throw new RuntimeException('Expected section.');
            }

            $ast[$section][] = $token;
        }

        return $ast;
    }
public function parseString($string)
    {
        $tokens = $this->tokenize($string);

        $tokens = array_filter(
            $tokens,
            function ($token) {
                return !($token['type'] === TransformationProcessor::T_WHITESPACE ||
                          $token['type'] === TransformationProcessor::T_COMMENT);
            }
        );

        $ast = array();
        $section = null;
        while ($token = array_shift($tokens)) {
            if ($token['type'] === TransformationProcessor::T_SECTION) {
                $section = $token['data']['section'];
                continue;
            }

            if ($section === null) {
                throw new RuntimeException('Expected section.');
            }

            $ast[$section][] = $token;
        }

        return $ast;
    }
public function parseString ( $ string ) { $ tokens = $ this -> tokenize ( $ string ) ; $ tokens = array_filter ( $ tokens , function ( $ token ) { return ! ( $ token [ 'type' ] === TransformationProcessor :: T_WHITESPACE || $ token [ 'type' ] === TransformationProcessor :: T_COMMENT ) ; } ) ; $ ast = array ( ) ; $ section = null ; while ( $ token = array_shift ( $ tokens ) ) { if ( $ token [ 'type' ] === TransformationProcessor :: T_SECTION ) { $ section = $ token [ 'data' ] [ 'section' ] ; continue ; } if ( $ section === null ) { throw new RuntimeException ( 'Expected section.' ) ; } $ ast [ $ section ] [ ] = $ token ; } return $ ast ; }
Parse the given string into an AST.

@param string $string

@return array
Parse the given string into an AST .