当使用访问者解析 AST 时,访问者如何检测范围何时发生变化?例如,当我们在 Class 节点时,我们创建了 Class 范围,但是如何检测我们何时离开了一个 class 节点,关闭范围呢?
1: Stmt_Class(
type: 0
extends: null
implements: array(
)
stmts: array(
0: Stmt_ClassMethod(
type: 1
byRef: false
params: array(
0: Param(
name: str
default: null
type: null
byRef: false
)
)
stmts: array(
0: Stmt_Return(
expr: Expr_FuncCall(
name: Name(
parts: array(
0: mysql_real_escape_string
)
name: null
)
args: array(
0: Arg(
value: Expr_Variable(
name: str
)
byRef: false
name: null
)
)
)
name: null
)
)
name: clear
)
)
name: Filter
)