protected function runActionHandler($action, TreeNodeInterface $node)
    {
        if ($node instanceof Token) {
            try {
                return $action($node->getContent());
            } catch (AbortParsingException $e) {
                if (null === $e->getOffset()) {
                    throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e);
                }
                throw $e;
            } catch (AbortNodeException $e) {
                throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e);
            } catch (\Throwable $e) {
                throw new \RuntimeException("Action failure in `{$this::buildActionName($node)}`", 0, $e);
            }
        }

        $args = [];
        foreach ($node->getChildren() as $child) {
            $args[] = $child->made();
        }

        try {
             $result = $action(...$args);
        } catch (AbortNodeException $e) {
            throw new AbortParsingException(
                $e->getMessage(),
                $node->getChild($e->getNodeIndex() - 1)->getOffset(),
                $e
            );
        } catch (AbortParsingException $e) {
            if (null === $e->getOffset()) {
                throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e);
            }
            throw $e;
        } catch (\Throwable $e) {
            throw new \RuntimeException("Action failure in `{$this::buildActionName($node)}`", 0, $e);
        }

        if ($this->prune) {
            $node->prune();
        }

        return $result;
    }
protected function runActionHandler($action, TreeNodeInterface $node)
    {
        if ($node instanceof Token) {
            try {
                return $action($node->getContent());
            } catch (AbortParsingException $e) {
                if (null === $e->getOffset()) {
                    throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e);
                }
                throw $e;
            } catch (AbortNodeException $e) {
                throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e);
            } catch (\Throwable $e) {
                throw new \RuntimeException("Action failure in `{$this::buildActionName($node)}`", 0, $e);
            }
        }

        $args = [];
        foreach ($node->getChildren() as $child) {
            $args[] = $child->made();
        }

        try {
             $result = $action(...$args);
        } catch (AbortNodeException $e) {
            throw new AbortParsingException(
                $e->getMessage(),
                $node->getChild($e->getNodeIndex() - 1)->getOffset(),
                $e
            );
        } catch (AbortParsingException $e) {
            if (null === $e->getOffset()) {
                throw new AbortParsingException($e->getMessage(), $node->getOffset(), $e);
            }
            throw $e;
        } catch (\Throwable $e) {
            throw new \RuntimeException("Action failure in `{$this::buildActionName($node)}`", 0, $e);
        }

        if ($this->prune) {
            $node->prune();
        }

        return $result;
    }
protected function runActionHandler ( $ action , TreeNodeInterface $ node ) { if ( $ node instanceof Token ) { try { return $ action ( $ node -> getContent ( ) ) ; } catch ( AbortParsingException $ e ) { if ( null === $ e -> getOffset ( ) ) { throw new AbortParsingException ( $ e -> getMessage ( ) , $ node -> getOffset ( ) , $ e ) ; } throw $ e ; } catch ( AbortNodeException $ e ) { throw new AbortParsingException ( $ e -> getMessage ( ) , $ node -> getOffset ( ) , $ e ) ; } catch ( \ Throwable $ e ) { throw new \ RuntimeException ( "Action failure in `{$this::buildActionName($node)}`" , 0 , $ e ) ; } } $ args = [ ] ; foreach ( $ node -> getChildren ( ) as $ child ) { $ args [ ] = $ child -> made ( ) ; } try { $ result = $ action ( ... $ args ) ; } catch ( AbortNodeException $ e ) { throw new AbortParsingException ( $ e -> getMessage ( ) , $ node -> getChild ( $ e -> getNodeIndex ( ) - 1 ) -> getOffset ( ) , $ e ) ; } catch ( AbortParsingException $ e ) { if ( null === $ e -> getOffset ( ) ) { throw new AbortParsingException ( $ e -> getMessage ( ) , $ node -> getOffset ( ) , $ e ) ; } throw $ e ; } catch ( \ Throwable $ e ) { throw new \ RuntimeException ( "Action failure in `{$this::buildActionName($node)}`" , 0 , $ e ) ; } if ( $ this -> prune ) { $ node -> prune ( ) ; } return $ result ; }
Run action handler and return its result
@param callable $action Action callback from the map
@param TreeNodeInterface $node Subject node
@return mixed Result of the action call
@since 1.5.0
@throws AbortParsingException
Run action handler and return its result