本文整理汇总了PHP中Environment::standard方法的典型用法代码示例。如果您正苦于以下问题:PHP Environment::standard方法的具体用法?PHP Environment::standard怎么用?PHP Environment::standard使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment::standard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: expand
/**
* @test
* @dataProvider provideExpand
*/
public function expand($expected, $sexpr, array $macros = [])
{
$walker = new Walker();
$env = Environment::standard();
foreach ($macros as $name => $pair) {
list($argsSexpr, $bodySexpr) = $pair;
$macroArgs = $this->parseSexpr($argsSexpr);
$macroBody = $this->parseSexpr($bodySexpr);
$env[$name] = new SpecialOp\MacroOp($macroArgs, $macroBody);
}
$form = $this->parseSexpr($sexpr);
$expanded = $walker->expand($env, $form);
$this->assertEquals($expected, $expanded->getAst());
}
示例2: exit
<?php
// example call:
// php examples/macro-expand.php
// "(defmacro when (condition a b c) (list 'if condition (list 'begin a b c)))"
// "(when (> x 10) 1 2 3)"
namespace Igorw\Ilias;
require __DIR__ . '/../vendor/autoload.php';
if ($argc < 3) {
echo "Usage: php examples/macro-expand.php MACROS CODE\n";
exit(1);
}
list($_, $macros, $code) = $argv;
$program = new Program(new Lexer(), new Reader(), new FormTreeBuilder(), new Walker());
$env = Environment::standard();
$program->evaluate($env, $macros);
$expandedForms = expand($env, $code);
foreach ($expandedForms as $expanded) {
echo encode($expanded->getAst()) . "\n";
}
function buildForms($code)
{
$lexer = new Lexer();
$reader = new Reader();
$builder = new FormTreeBuilder();
$tokens = $lexer->tokenize($code);
$ast = $reader->parse($tokens);
return $builder->parseAst($ast);
}
function expand(Environment $env, $code)