天天看點

AST 節點類型對照表

序号

類型原名稱

中文名稱

描述

1

Program

程式主體

整段代碼的主體

2

VariableDeclaration

變量聲明

聲明一個變量,例如 var let const

3

FunctionDeclaration

函數聲明

聲明一個函數,例如 function

4

ExpressionStatement

表達式語句

通常是調用一個函數,例如 console.log()

5

BlockStatement

塊語句

包裹在 {} 塊内的代碼,例如 if (condition){var a = 1;}

6

BreakStatement

中斷語句

通常指 break

7

ContinueStatement

持續語句

通常指 continue

8

ReturnStatement

傳回語句

通常指 return

9

SwitchStatement

Switch 語句

通常指 Switch Case 語句中的 Switch

10

IfStatement

If 控制流語句

控制流語句,通常指 if(condition){}else{}

11

Identifier

辨別符

辨別,例如聲明變量時 var identi = 5 中的 identi

12

CallExpression

調用表達式

通常指調用一個函數,例如 console.log()

13

BinaryExpression

二進制表達式

通常指運算,例如 1+2

14

MemberExpression

成員表達式

通常指調用對象的成員,例如 console 對象的 log 成員

15

ArrayExpression

數組表達式

通常指一個數組,例如 [1, 3, 5]

16

NewExpression

New 表達式

通常指使用 New 關鍵詞

17

AssignmentExpression

指派表達式

通常指将函數的傳回值指派給變量

18

UpdateExpression

更新表達式

通常指更新成員值,例如 i++

19

Literal

字面量

20

BooleanLiteral

布爾型字面量

布爾值,例如 true false

21

NumericLiteral

數字型字面量

數字,例如 100

22

StringLiteral

字元型字面量

字元串,例如 vansenb

23

SwitchCase

Case 語句

通常指 Switch 語句中的 Case