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 + ""
補(bǔ)充valueToNode
3.type系列
補(bǔ)充:
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
在抽象語(yǔ)法樹(shù) (AST) 中,語(yǔ)句(Statement)和表達(dá)式(Expression)是兩個(gè)重要的概念菠劝。
語(yǔ)句通常包括:
塊語(yǔ)句 (BlockStatement) - 代碼塊 { }
if語(yǔ)句 (IfStatement)
switch語(yǔ)句 (SwitchStatement)
while語(yǔ)句 (WhileStatement)
do-while語(yǔ)句 (DoWhileStatement)
for語(yǔ)句 (ForStatement)
continue語(yǔ)句 (ContinueStatement)
break語(yǔ)句 (BreakStatement)
return語(yǔ)句 (ReturnStatement)
throw語(yǔ)句 (ThrowStatement)
try-catch語(yǔ)句 (TryStatement)
表達(dá)式語(yǔ)句 (ExpressionStatement)
空語(yǔ)句 (EmptyStatement)
表達(dá)式包括:
字面量 (Literal) - 如字符串凡蜻、數(shù)字准浴、布爾值
標(biāo)識(shí)符 (Identifier) - 如變量名
一元表達(dá)式 (UnaryExpression) - 如 !a
二元表達(dá)式 (BinaryExpression) - 如 a + b
賦值表達(dá)式 (AssignmentExpression) - 如 a = 1
函數(shù)調(diào)用 (CallExpression) - 如 fn()
對(duì)象表達(dá)式 (ObjectExpression) - 如 {a: 1}
數(shù)組表達(dá)式 (ArrayExpression) - 如 [1, 2]
判斷表達(dá)式 (ConditionalExpression) - 如 a ? b : c
語(yǔ)句主要用于控制代碼執(zhí)行流程,表達(dá)式用于描述值。在AST中識(shí)別語(yǔ)句和表達(dá)式類型,可以幫助分析語(yǔ)法并轉(zhuǎn)換代碼尝丐。