1.scope系列
scope.block
scope.getBinding
scope.getOwnBinding
scope.rename
scope.rename
scope.hasBinding
scope.hasownBinding
scope.getAllBindings
scope.hasReference
scope.getBindingIdentifier
scope.generateUidIdentifier
2.path系列
path.get
path.find
path.parentPath
path.findparent
path.getFunctionParent
path.getStatementParent
path.insertBefore
path.insertAfter
path.replacewith
path.replaceWithmultiple
path.replaceLine
path.replacewithSouceString
path.inList
path.key
path.container
path.listKey
path.getSibing
path.remove
path.stop
path + ""
补充valueToNode
3.type系列
补充:
objectExpression
objectproperty
4.其他系列
body
type
argument
declarations
kind
id
name
init
properties
extra
method
key
computed
value
directives
left
right
operator
container
parent
hub
contexts
data
state
opts
skipkey
parentpath
node
listkey
key
node
scope
constantviolations
contant
referencepaths
referenced
references
在抽象语法树 (AST) 中,语句(Statement)和表达式(Expression)是两个重要的概念。
语句通常包括:
块语句 (BlockStatement) - 代码块 { }
if语句 (IfStatement)
switch语句 (SwitchStatement)
while语句 (WhileStatement)
do-while语句 (DoWhileStatement)
for语句 (ForStatement)
continue语句 (ContinueStatement)
break语句 (BreakStatement)
return语句 (ReturnStatement)
throw语句 (ThrowStatement)
try-catch语句 (TryStatement)
表达式语句 (ExpressionStatement)
空语句 (EmptyStatement)
表达式包括:
字面量 (Literal) - 如字符串、数字、布尔值
标识符 (Identifier) - 如变量名
一元表达式 (UnaryExpression) - 如 !a
二元表达式 (BinaryExpression) - 如 a + b
赋值表达式 (AssignmentExpression) - 如 a = 1
函数调用 (CallExpression) - 如 fn()
对象表达式 (ObjectExpression) - 如 {a: 1}
数组表达式 (ArrayExpression) - 如 [1, 2]
判断表达式 (ConditionalExpression) - 如 a ? b : c
语句主要用于控制代码执行流程,表达式用于描述值。在AST中识别语句和表达式类型,可以帮助分析语法并转换代码。