コード例 #1
0
ファイル: ToClassVisitor.php プロジェクト: scato/phpeg
    public function visitAction(ActionNode $node)
    {
        $use = $this->createUseClause();
        $this->results[] = <<<EOS
{$this->getResult()}

if (\$_success) {
    \$this->value = call_user_func(function (){$use} {
        {$node->getCode()}
    });
}
EOS;
    }
コード例 #2
0
ファイル: ToClassVisitorSpec.php プロジェクト: scato/phpeg
    function it_should_create_an_action_from_a_node()
    {
        $actionNode = new ActionNode(new LabelNode('name', new RuleReferenceNode('Foo')), 'return $name;');
        $actionCode = <<<EOS
\$_success = \$this->parseFoo();

if (\$_success) {
    \$name = \$this->value;
}

if (\$_success) {
    \$this->value = call_user_func(function () use (&\$name) {
        return \$name;
    });
}
EOS;
        $actionNode->accept($this->getWrappedObject());
        $this->getResult()->shouldBe($actionCode);
    }