db 指令,就直接写入就行了。注意,是构造语法树相应的数据类型的节点,而不是直接输入数据。
/**
* 读取数据
* @param string|int $data
* @throws \Exception
*/
protected function _db($data)
{
if (is_string($data)) {
$this->ast[$this->astp] = new String_($data);
} elseif (is_numeric($data)) {
$this->ast[$this->astp] = new LNumber($data);
} elseif (is_array($data)) {
$this->ast[$this->astp] = new Array_($data);
} else {
throw new \Exception('Move invalid data.');
}
}
protected function _call($argCount)
{
$args = [];
for ($i = $argCount - 1; $i >= 0; --$i) {
$args[] = new \PhpParser\Node\Arg($this->ast[$this->astp - $i]);
}
$this->ast[$this->astp - $argCount] = new FuncCall(
new Name($this->ast[$this->astp - $argCount]->value),
$args
);
}
not 就是在外面再套一层 Not
protected function _not()
{
$this->ast[$this->astp] = new BooleanNot($this->ast[$this->astp]);
}
现在你应该已经基本了解如何根据指令堆栈的操作来构造语法树了。php语法基础接下来我们来分析一下条件分支结构。

if [esp]
pop
else
pop
$this->ast[$this->astp] = new If_($this->ast[$this->astp]);
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-67089-5.html
是跟踪还是护航