JavaScript/ast/node:修订间差异
无编辑摘要 |
|||
| (未显示同一用户的6个中间版本) | |||
| 第1行: | 第1行: | ||
== test == | == estree/es5 == | ||
Node objects | === Node objects === | ||
ESTree AST nodes are represented as Node objects, which may have any prototype inheritance but which implement the following interface: | |||
<syntaxhighlight lang="javascript"> | |||
interface Node { | |||
type: string; | |||
loc: SourceLocation | null; | |||
}</syntaxhighlight> | |||
The type field is a string representing the AST variant type. Each subtype of Node is documented below with the specific string of its type field. You can use this field to determine which interface a node implements. | |||
The loc field represents the source location information of the node. If the node contains no information about the source location, the field is null; otherwise it is an object consisting of a start position (the position of the first character of the parsed source region) and an end position (the position of the first character after the parsed source region): | |||
<syntaxhighlight lang="javascript"> | |||
interface SourceLocation { | |||
source: string | null; | |||
start: Position; | |||
end: Position; | |||
}</syntaxhighlight> | |||
Each Position object consists of a line number (1-indexed) and a column number (0-indexed): | |||
<syntaxhighlight lang="javascript"> | |||
interface Position { | |||
line: number; // >= 1 | |||
column: number; // >= 0 | |||
}</syntaxhighlight> | |||
Identifier | |||
<syntaxhighlight lang="javascript"> | |||
interface Identifier <: Expression, Pattern { | |||
type: "Identifier"; | |||
name: string; | |||
}</syntaxhighlight> | |||
An identifier. Note that an identifier may be an expression or a destructuring pattern. | |||
Literal | |||
<syntaxhighlight lang="javascript"> | |||
interface Literal <: Expression { | |||
type: "Literal"; | |||
value: string | boolean | null | number | RegExp; | |||
}</syntaxhighlight> | |||
A literal token. Note that a literal can be an expression. | |||
RegExpLiteral | |||
<syntaxhighlight lang="javascript"> | |||
interface RegExpLiteral <: Literal { | |||
regex: { | |||
pattern: string; | |||
flags: string; | |||
}; | |||
}</syntaxhighlight> | |||
The regex property allows regexes to be represented in environments that don’t support certain flags such as y or u. In environments that don't support these flags value will be null as the regex can't be represented natively. | |||
Programs | |||
<syntaxhighlight lang="javascript"> | |||
interface Program <: Node { | |||
type: "Program"; | |||
body: [ Directive | Statement ]; | |||
}</syntaxhighlight> | |||
A complete program source tree. | |||
Functions | |||
<syntaxhighlight lang="javascript"> | |||
interface Function <: Node { | |||
id: Identifier | null; | |||
params: [ Pattern ]; | |||
body: FunctionBody; | |||
}</syntaxhighlight> | |||
A function declaration or expression. | |||
Statements | |||
<syntaxhighlight lang="javascript"> | |||
interface Statement <: Node { }</syntaxhighlight> | |||
Any statement. | |||
ExpressionStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface ExpressionStatement <: Statement { | |||
type: "ExpressionStatement"; | |||
expression: Expression; | |||
}</syntaxhighlight> | |||
An expression statement, i.e., a statement consisting of a single expression. | |||
Directive | |||
<syntaxhighlight lang="javascript"> | |||
interface Directive <: ExpressionStatement { | |||
expression: Literal; | |||
directive: string; | |||
}</syntaxhighlight> | |||
A directive from the directive prologue of a script or function. The directive property is the raw string source of the directive without quotes. | |||
BlockStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface BlockStatement <: Statement { | |||
type: "BlockStatement"; | |||
body: [ Statement ]; | |||
}</syntaxhighlight> | |||
A block statement, i.e., a sequence of statements surrounded by braces. | |||
FunctionBody | |||
<syntaxhighlight lang="javascript"> | |||
interface FunctionBody <: BlockStatement { | |||
body: [ Directive | Statement ]; | |||
}</syntaxhighlight> | |||
The body of a function, which is a block statement that may begin with directives. | |||
EmptyStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface EmptyStatement <: Statement { | |||
type: "EmptyStatement"; | |||
}</syntaxhighlight> | |||
An empty statement, i.e., a solitary semicolon. | |||
DebuggerStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface DebuggerStatement <: Statement { | |||
type: "DebuggerStatement"; | |||
}</syntaxhighlight> | |||
A debugger statement. | |||
WithStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface WithStatement <: Statement { | |||
type: "WithStatement"; | |||
object: Expression; | |||
body: Statement; | |||
}</syntaxhighlight> | |||
A with statement. | |||
Control flow | |||
ReturnStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface ReturnStatement <: Statement { | |||
type: "ReturnStatement"; | |||
argument: Expression | null; | |||
}</syntaxhighlight> | |||
A return statement. | |||
LabeledStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface LabeledStatement <: Statement { | |||
type: "LabeledStatement"; | |||
label: Identifier; | |||
body: Statement; | |||
}</syntaxhighlight> | |||
A labeled statement, i.e., a statement prefixed by a break/continue label. | |||
BreakStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface BreakStatement <: Statement { | |||
type: "BreakStatement"; | |||
label: Identifier | null; | |||
}</syntaxhighlight> | |||
A break statement. | |||
ContinueStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface ContinueStatement <: Statement { | |||
type: "ContinueStatement"; | |||
label: Identifier | null; | |||
}</syntaxhighlight> | |||
A continue statement. | |||
Choice | |||
IfStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface IfStatement <: Statement { | |||
type: "IfStatement"; | |||
test: Expression; | |||
consequent: Statement; | |||
alternate: Statement | null; | |||
}</syntaxhighlight> | |||
An if statement. | |||
SwitchStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface SwitchStatement <: Statement { | |||
type: "SwitchStatement"; | |||
discriminant: Expression; | |||
cases: [ SwitchCase ]; | |||
}</syntaxhighlight> | |||
A switch statement. | |||
SwitchCase | |||
<syntaxhighlight lang="javascript"> | |||
interface SwitchCase <: Node { | |||
type: "SwitchCase"; | |||
test: Expression | null; | |||
consequent: [ Statement ]; | |||
}</syntaxhighlight> | |||
A case (if test is an Expression) or default (if test === null) clause in the body of a switch statement. | |||
Exceptions | |||
ThrowStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface ThrowStatement <: Statement { | |||
type: "ThrowStatement"; | |||
argument: Expression; | |||
}</syntaxhighlight> | |||
A throw statement. | |||
TryStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface TryStatement <: Statement { | |||
type: "TryStatement"; | |||
block: BlockStatement; | |||
handler: CatchClause | null; | |||
finalizer: BlockStatement | null; | |||
}</syntaxhighlight> | |||
A try statement. If handler is null then finalizer must be a BlockStatement. | |||
CatchClause | |||
<syntaxhighlight lang="javascript"> | |||
interface CatchClause <: Node { | |||
type: "CatchClause"; | |||
param: Pattern; | |||
body: BlockStatement; | |||
}</syntaxhighlight> | |||
A catch clause following a try block. | |||
Loops | |||
WhileStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface WhileStatement <: Statement { | |||
type: "WhileStatement"; | |||
test: Expression; | |||
body: Statement; | |||
}</syntaxhighlight> | |||
A while statement. | |||
DoWhileStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface DoWhileStatement <: Statement { | |||
type: "DoWhileStatement"; | |||
body: Statement; | |||
test: Expression; | |||
}</syntaxhighlight> | |||
A do/while statement. | |||
ForStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface ForStatement <: Statement { | |||
type: "ForStatement"; | |||
init: VariableDeclaration | Expression | null; | |||
test: Expression | null; | |||
update: Expression | null; | |||
body: Statement; | |||
}</syntaxhighlight> | |||
A for statement. | |||
ForInStatement | |||
<syntaxhighlight lang="javascript"> | |||
interface ForInStatement <: Statement { | |||
type: "ForInStatement"; | |||
left: VariableDeclaration | Pattern; | |||
right: Expression; | |||
body: Statement; | |||
}</syntaxhighlight> | |||
A for/in statement. | |||
Declarations | |||
<syntaxhighlight lang="javascript"> | |||
interface Declaration <: Statement { }</syntaxhighlight> | |||
Any declaration node. Note that declarations are considered statements; this is because declarations can appear in any statement context. | |||
FunctionDeclaration | |||
<syntaxhighlight lang="javascript"> | |||
interface FunctionDeclaration <: Function, Declaration { | |||
type: "FunctionDeclaration"; | |||
id: Identifier; | |||
}</syntaxhighlight> | |||
A function declaration. Note that unlike in the parent interface Function, the id cannot be null. | |||
VariableDeclaration | |||
<syntaxhighlight lang="javascript"> | |||
interface VariableDeclaration <: Declaration { | |||
type: "VariableDeclaration"; | |||
declarations: [ VariableDeclarator ]; | |||
kind: "var"; | |||
}</syntaxhighlight> | |||
A variable declaration. | |||
VariableDeclarator | |||
<syntaxhighlight lang="javascript"> | |||
interface VariableDeclarator <: Node { | |||
type: "VariableDeclarator"; | |||
id: Pattern; | |||
init: Expression | null; | |||
}</syntaxhighlight> | |||
A variable declarator. | |||
Expressions | |||
<syntaxhighlight lang="javascript"> | |||
interface Expression <: Node { }</syntaxhighlight> | |||
Any expression node. Since the left-hand side of an assignment may be any expression in general, an expression can also be a pattern. | |||
ThisExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface ThisExpression <: Expression { | |||
type: "ThisExpression"; | |||
}</syntaxhighlight> | |||
A this expression. | |||
ArrayExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface ArrayExpression <: Expression { | |||
type: "ArrayExpression"; | |||
elements: [ Expression | null ]; | |||
}</syntaxhighlight> | |||
An array expression. An element might be null if it represents a hole in a sparse array. E.g. [1,,2]. | |||
ObjectExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface ObjectExpression <: Expression { | |||
type: "ObjectExpression"; | |||
properties: [ Property ]; | |||
}</syntaxhighlight> | |||
An object expression. | |||
Property | |||
<syntaxhighlight lang="javascript"> | |||
interface Property <: Node { | |||
type: "Property"; | |||
key: Literal | Identifier; | |||
value: Expression; | |||
kind: "init" | "get" | "set"; | |||
}</syntaxhighlight> | |||
A literal property in an object expression can have either a string or number as its value. Ordinary property initializers have a kind value "init"; getters and setters have the kind values "get" and "set", respectively. | |||
FunctionExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface FunctionExpression <: Function, Expression { | |||
type: "FunctionExpression"; | |||
}</syntaxhighlight> | |||
A function expression. | |||
Unary operations | |||
UnaryExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface UnaryExpression <: Expression { | |||
type: "UnaryExpression"; | |||
operator: UnaryOperator; | |||
prefix: boolean; | |||
argument: Expression; | |||
}</syntaxhighlight> | |||
A unary operator expression. | |||
UnaryOperator | |||
<syntaxhighlight lang="javascript"> | |||
enum UnaryOperator { | |||
"-" | "+" | "!" | "~" | "typeof" | "void" | "delete" | |||
}</syntaxhighlight> | |||
A unary operator token. | |||
UpdateExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface UpdateExpression <: Expression { | |||
type: "UpdateExpression"; | |||
operator: UpdateOperator; | |||
argument: Expression; | |||
prefix: boolean; | |||
}</syntaxhighlight> | |||
An update (increment or decrement) operator expression. | |||
UpdateOperator | |||
<syntaxhighlight lang="javascript"> | |||
enum UpdateOperator { | |||
"++" | "--" | |||
}</syntaxhighlight> | |||
An update (increment or decrement) operator token. | |||
Binary operations | |||
BinaryExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface BinaryExpression <: Expression { | |||
type: "BinaryExpression"; | |||
operator: BinaryOperator; | |||
left: Expression; | |||
right: Expression; | |||
}</syntaxhighlight> | |||
A binary operator expression. | |||
BinaryOperator | |||
<syntaxhighlight lang="javascript"> | |||
enum BinaryOperator { | |||
"==" | "!=" | "===" | "!==" | |||
| "<" | "<=" | ">" | ">=" | |||
| "<<" | ">>" | ">>>" | |||
| "+" | "-" | "*" | "/" | "%" | |||
| "|" | "^" | "&" | "in" | |||
| "instanceof" | |||
}</syntaxhighlight> | |||
A binary operator token. | |||
AssignmentExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface AssignmentExpression <: Expression { | |||
type: "AssignmentExpression"; | |||
operator: AssignmentOperator; | |||
left: Pattern | Expression; | |||
right: Expression; | |||
}</syntaxhighlight> | |||
An assignment operator expression. | |||
AssignmentOperator | |||
<syntaxhighlight lang="javascript"> | |||
enum AssignmentOperator { | |||
"=" | "+=" | "-=" | "*=" | "/=" | "%=" | |||
| "<<=" | ">>=" | ">>>=" | |||
| "|=" | "^=" | "&=" | |||
}</syntaxhighlight> | |||
An assignment operator token. | |||
LogicalExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface LogicalExpression <: Expression { | |||
type: "LogicalExpression"; | |||
operator: LogicalOperator; | |||
left: Expression; | |||
right: Expression; | |||
}</syntaxhighlight> | |||
A logical operator expression. | |||
LogicalOperator | |||
<syntaxhighlight lang="javascript"> | |||
enum LogicalOperator { | |||
"||" | "&&" | |||
}</syntaxhighlight> | |||
A logical operator token. | |||
MemberExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface MemberExpression <: Expression, Pattern { | |||
type: "MemberExpression"; | |||
object: Expression; | |||
property: Expression; | |||
computed: boolean; | |||
}</syntaxhighlight> | |||
A member expression. If computed is true, the node corresponds to a computed (a[b]) member expression and property is an Expression. If computed is false, the node corresponds to a static (a.b) member expression and property is an Identifier. | |||
ConditionalExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface ConditionalExpression <: Expression { | |||
type: "ConditionalExpression"; | |||
test: Expression; | |||
alternate: Expression; | |||
consequent: Expression; | |||
}</syntaxhighlight> | |||
A conditional expression, i.e., a ternary ?/: expression. | |||
CallExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface CallExpression <: Expression { | |||
type: "CallExpression"; | |||
callee: Expression; | |||
arguments: [ Expression ]; | |||
}</syntaxhighlight> | |||
A function or method call expression. | |||
NewExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface NewExpression <: Expression { | |||
type: "NewExpression"; | |||
callee: Expression; | |||
arguments: [ Expression ]; | |||
}</syntaxhighlight> | |||
A new expression. | |||
SequenceExpression | |||
<syntaxhighlight lang="javascript"> | |||
interface SequenceExpression <: Expression { | |||
type: "SequenceExpression"; | |||
expressions: [ Expression ]; | |||
}</syntaxhighlight> | |||
A sequence expression, i.e., a comma-separated sequence of expressions. | |||
=== Patterns === | |||
Destructuring binding and assignment are not part of ES5, but all binding positions accept Pattern to allow for destructuring in ES6. Nevertheless, for ES5, the only Pattern subtype is Identifier. | |||
<syntaxhighlight lang="javascript"> | |||
interface Pattern <: Node { }</syntaxhighlight> | |||
== SpiderMonkey Parser API == | |||
=== Node objects === | |||
<syntaxhighlight lang="javascript"> | |||
interface Node { | interface Node { | ||
type: string; | type: string; | ||
loc: SourceLocation | null; | loc: SourceLocation | null; | ||
} | }</syntaxhighlight> | ||
<syntaxhighlight lang="javascript"> | |||
interface SourceLocation { | interface SourceLocation { | ||
source: string | null; | source: string | null; | ||
start: Position; | start: Position; | ||
end: Position; | end: Position; | ||
} | }</syntaxhighlight> | ||
<syntaxhighlight lang="javascript"> | |||
interface Position { | interface Position { | ||
line: uint32 >= 1; | line: uint32 >= 1; | ||
column: uint32 >= 0; | column: uint32 >= 0; | ||
} | }</syntaxhighlight> | ||
Programs | |||
=== Programs === | |||
A complete program source tree. | A complete program source tree. | ||
<syntaxhighlight lang="javascript"> | |||
interface Program <: Node { | interface Program <: Node { | ||
type: "Program"; | type: "Program"; | ||
| 第24行: | 第512行: | ||
program(body[, loc]) | program(body[, loc]) | ||
body: [ Statement ] | body: [ Statement ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
Functions | |||
=== Functions === | |||
A function declaration or expression. | A function declaration or expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface Function <: Node { | interface Function <: Node { | ||
id: Identifier | null; | id: Identifier | null; | ||
| 第36行: | 第526行: | ||
generator: boolean; | generator: boolean; | ||
expression: boolean; | expression: boolean; | ||
} | }</syntaxhighlight> | ||
Statements | |||
=== Statements === | |||
Any statement. | Any statement. | ||
| 第43行: | 第534行: | ||
An empty statement, i.e., a solitary semicolon. | An empty statement, i.e., a solitary semicolon. | ||
<syntaxhighlight lang="javascript"> | |||
interface EmptyStatement <: Statement { | interface EmptyStatement <: Statement { | ||
type: "EmptyStatement"; | type: "EmptyStatement"; | ||
| 第49行: | 第541行: | ||
emptyStatement([loc]) | emptyStatement([loc]) | ||
loc: SourceLocation | loc: SourceLocation | ||
</syntaxhighlight> | |||
A block statement, i.e., a sequence of statements surrounded by braces. | A block statement, i.e., a sequence of statements surrounded by braces. | ||
The builder differs from that specified in the Mozilla Parser API: body is an Array of Statements instead of a single Statement. | The builder differs from that specified in the Mozilla Parser API: body is an Array of Statements instead of a single Statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface BlockStatement <: Statement { | interface BlockStatement <: Statement { | ||
type: "BlockStatement"; | type: "BlockStatement"; | ||
| 第60行: | 第555行: | ||
blockStatement(body[, loc]) | blockStatement(body[, loc]) | ||
body: [ Statement ] | body: [ Statement ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
An expression statement, i.e., a statement consisting of a single expression. | An expression statement, i.e., a statement consisting of a single expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface ExpressionStatement <: Statement { | interface ExpressionStatement <: Statement { | ||
type: "ExpressionStatement"; | type: "ExpressionStatement"; | ||
| 第71行: | 第568行: | ||
expr: Expression | expr: Expression | ||
loc: SourceLocation | loc: SourceLocation | ||
</syntaxhighlight> | |||
An if statement. | An if statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface IfStatement <: Statement { | interface IfStatement <: Statement { | ||
type: "IfStatement"; | type: "IfStatement"; | ||
| 第84行: | 第584行: | ||
cons: Statement | cons: Statement | ||
alt: Statement | null | alt: Statement | null | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A labeled statement, i.e., a statement prefixed by a break/continue label. | A labeled statement, i.e., a statement prefixed by a break/continue label. | ||
<syntaxhighlight lang="javascript"> | |||
interface LabeledStatement <: Statement { | interface LabeledStatement <: Statement { | ||
type: "LabeledStatement"; | type: "LabeledStatement"; | ||
| 第96行: | 第598行: | ||
label: Identifier | label: Identifier | ||
body: Statement | body: Statement | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A break statement. | A break statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface BreakStatement <: Statement { | interface BreakStatement <: Statement { | ||
type: "BreakStatement"; | type: "BreakStatement"; | ||
| 第106行: | 第610行: | ||
breakStatement(label[, loc]) | breakStatement(label[, loc]) | ||
label: Identifier | null | label: Identifier | null | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A continue statement. | A continue statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface ContinueStatement <: Statement { | interface ContinueStatement <: Statement { | ||
type: "ContinueStatement"; | type: "ContinueStatement"; | ||
| 第116行: | 第622行: | ||
continueStatement(label[, loc]) | continueStatement(label[, loc]) | ||
label: Identifier | null | label: Identifier | null | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A with statement. | A with statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface WithStatement <: Statement { | interface WithStatement <: Statement { | ||
type: "WithStatement"; | type: "WithStatement"; | ||
| 第128行: | 第636行: | ||
obj: Expression | obj: Expression | ||
body: Statement | body: Statement | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A switch statement. | A switch statement. | ||
The lexical flag is metadata indicating whether the switch statement contains any unnested let declarations (and therefore introduces a new lexical scope). | The lexical flag is metadata indicating whether the switch statement contains any unnested let declarations (and therefore introduces a new lexical scope). | ||
<syntaxhighlight lang="javascript"> | |||
interface SwitchStatement <: Statement { | interface SwitchStatement <: Statement { | ||
type: "SwitchStatement"; | type: "SwitchStatement"; | ||
| 第144行: | 第654行: | ||
cases: [ SwitchCase ] | cases: [ SwitchCase ] | ||
isLexical: boolean | isLexical: boolean | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A return statement. | A return statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface ReturnStatement <: Statement { | interface ReturnStatement <: Statement { | ||
type: "ReturnStatement"; | type: "ReturnStatement"; | ||
| 第154行: | 第666行: | ||
returnStatement(arg[, loc]) | returnStatement(arg[, loc]) | ||
arg: Expression | null | arg: Expression | null | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A throw statement. | A throw statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface ThrowStatement <: Statement { | interface ThrowStatement <: Statement { | ||
type: "ThrowStatement"; | type: "ThrowStatement"; | ||
| 第164行: | 第678行: | ||
throwStatement(arg[, loc]) | throwStatement(arg[, loc]) | ||
arg: Expression | arg: Expression | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A try statement. | A try statement. | ||
The builder in the Mozilla Parser API accepts multiple handlers. This only accepts a single handler. | The builder in the Mozilla Parser API accepts multiple handlers. This only accepts a single handler. | ||
<syntaxhighlight lang="javascript"> | |||
interface TryStatement <: Statement { | interface TryStatement <: Statement { | ||
type: "TryStatement"; | type: "TryStatement"; | ||
| 第181行: | 第697行: | ||
handler: CatchClause | handler: CatchClause | ||
fin: Statement | null | fin: Statement | null | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A while statement. | A while statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface WhileStatement <: Statement { | interface WhileStatement <: Statement { | ||
type: "WhileStatement"; | type: "WhileStatement"; | ||
| 第193行: | 第711行: | ||
test: Expression | test: Expression | ||
body: Statement | body: Statement | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A do/while statement. | A do/while statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface DoWhileStatement <: Statement { | interface DoWhileStatement <: Statement { | ||
type: "DoWhileStatement"; | type: "DoWhileStatement"; | ||
| 第205行: | 第725行: | ||
body: Statement | body: Statement | ||
test: Expression | test: Expression | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A for statement. | A for statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface ForStatement <: Statement { | interface ForStatement <: Statement { | ||
type: "ForStatement"; | type: "ForStatement"; | ||
| 第221行: | 第743行: | ||
update: Expression | null | update: Expression | null | ||
body: Statement | body: Statement | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A for/in statement, or, if each is true, a for each/in statement. | A for/in statement, or, if each is true, a for each/in statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface ForInStatement <: Statement { | interface ForInStatement <: Statement { | ||
type: "ForInStatement"; | type: "ForInStatement"; | ||
| 第237行: | 第760行: | ||
body: Statement | body: Statement | ||
isForEach: boolean | isForEach: boolean | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A for/of statement. | A for/of statement. | ||
The Mozilla Parser API does not define a builder, so one has been defined here. | The Mozilla Parser API does not define a builder, so one has been defined here. | ||
<syntaxhighlight lang="javascript"> | |||
interface ForOfStatement <: Statement { | interface ForOfStatement <: Statement { | ||
type: "ForOfStatement"; | type: "ForOfStatement"; | ||
| 第252行: | 第777行: | ||
left: VariableDeclaration | Expression | left: VariableDeclaration | Expression | ||
right: Expression | right: Expression | ||
body: Statement | body: Statement</syntaxhighlight> | ||
A let statement. | A let statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface LetStatement <: Statement { | interface LetStatement <: Statement { | ||
type: "LetStatement"; | type: "LetStatement"; | ||
| 第264行: | 第791行: | ||
head: [ Declarator ] | head: [ Declarator ] | ||
body: Statement | body: Statement | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A debugger statement. | A debugger statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface DebuggerStatement <: Statement { | interface DebuggerStatement <: Statement { | ||
type: "DebuggerStatement"; | type: "DebuggerStatement"; | ||
| 第272行: | 第801行: | ||
debuggerStatement([loc]) | debuggerStatement([loc]) | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
Declarations | |||
=== Declarations === | |||
Any declaration node. | Any declaration node. | ||
| 第281行: | 第811行: | ||
The builder intentionally differs from the Mozilla Parser API in its arguments instead of (name, args, body, isGenerator, isExpression[, loc]). | The builder intentionally differs from the Mozilla Parser API in its arguments instead of (name, args, body, isGenerator, isExpression[, loc]). | ||
<syntaxhighlight lang="javascript"> | |||
interface FunctionDeclaration <: Function, Declaration { | interface FunctionDeclaration <: Function, Declaration { | ||
type: "FunctionDeclaration"; | type: "FunctionDeclaration"; | ||
| 第300行: | 第831行: | ||
isGenerator: boolean | isGenerator: boolean | ||
isExpression: boolean | isExpression: boolean | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A variable declaration, via one of var, let, or const. | A variable declaration, via one of var, let, or const. | ||
<syntaxhighlight lang="javascript"> | |||
interface VariableDeclaration <: Declaration { | interface VariableDeclaration <: Declaration { | ||
type: "VariableDeclaration"; | type: "VariableDeclaration"; | ||
| 第312行: | 第845行: | ||
kind: "var" | "let" | "const" | kind: "var" | "let" | "const" | ||
dtors: [ Declarator ] | dtors: [ Declarator ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A variable declarator. | A variable declarator. | ||
<syntaxhighlight lang="javascript"> | |||
interface VariableDeclarator <: Node { | interface VariableDeclarator <: Node { | ||
type: "VariableDeclarator"; | type: "VariableDeclarator"; | ||
| 第324行: | 第859行: | ||
patt: Pattern | patt: Pattern | ||
init: Expression | null | init: Expression | null | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
Expressions | |||
=== Expressions === | |||
Any expression node. | Any expression node. | ||
| 第331行: | 第867行: | ||
A this expression. | A this expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface ThisExpression <: Expression { | interface ThisExpression <: Expression { | ||
type: "ThisExpression"; | type: "ThisExpression"; | ||
| 第336行: | 第873行: | ||
thisExpression([loc]) | thisExpression([loc]) | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
An array expression. | An array expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface ArrayExpression <: Expression { | interface ArrayExpression <: Expression { | ||
type: "ArrayExpression"; | type: "ArrayExpression"; | ||
| 第346行: | 第885行: | ||
arrayExpression(elts[, loc]) | arrayExpression(elts[, loc]) | ||
elts: [ Expression | null ] | elts: [ Expression | null ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
An object expression. | An object expression. | ||
| 第353行: | 第893行: | ||
Ordinary property initializers have a kind value "init"; getters and setters have the kind values "get" and "set", respectively. | Ordinary property initializers have a kind value "init"; getters and setters have the kind values "get" and "set", respectively. | ||
<syntaxhighlight lang="javascript"> | |||
interface ObjectExpression <: Expression { | interface ObjectExpression <: Expression { | ||
type: "ObjectExpression"; | type: "ObjectExpression"; | ||
| 第360行: | 第901行: | ||
objectExpression(props[, loc]) | objectExpression(props[, loc]) | ||
props: [ Property ] | props: [ Property ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A function expression. | A function expression. | ||
The builder intentionally differs from the Mozilla Parser API in its arguments instead of (name, args, body, isGenerator, isExpression[, loc]). | The builder intentionally differs from the Mozilla Parser API in its arguments instead of (name, args, body, isGenerator, isExpression[, loc]). | ||
<syntaxhighlight lang="javascript"> | |||
interface FunctionExpression <: Function, Expression { | interface FunctionExpression <: Function, Expression { | ||
type: "FunctionExpression"; | type: "FunctionExpression"; | ||
| 第384行: | 第927行: | ||
isGenerator: boolean | isGenerator: boolean | ||
isExpression: boolean | isExpression: boolean | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A fat arrow function expression, i.e., `let foo = (bar) => { /* body */ }`. | A fat arrow function expression, i.e., `let foo = (bar) => { /* body */ }`. | ||
The Mozilla Parser API does not specify a builder for the ArrowFunction node, so one has been created here. | The Mozilla Parser API does not specify a builder for the ArrowFunction node, so one has been created here. | ||
<syntaxhighlight lang="javascript"> | |||
interface ArrowExpression <: Function, Expression { | interface ArrowExpression <: Function, Expression { | ||
type: "ArrowExpression"; | type: "ArrowExpression"; | ||
| 第406行: | 第951行: | ||
isGenerator: boolean | isGenerator: boolean | ||
isExpression: boolean | isExpression: boolean | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A sequence expression, i.e., a comma-separated sequence of expressions. | A sequence expression, i.e., a comma-separated sequence of expressions. | ||
<syntaxhighlight lang="javascript"> | |||
interface SequenceExpression <: Expression { | interface SequenceExpression <: Expression { | ||
type: "SequenceExpression"; | type: "SequenceExpression"; | ||
| 第416行: | 第963行: | ||
sequenceExpression(exprs[, loc]) | sequenceExpression(exprs[, loc]) | ||
exprs: [ Expression ] | exprs: [ Expression ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A unary operator expression. | A unary operator expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface UnaryExpression <: Expression { | interface UnaryExpression <: Expression { | ||
type: "UnaryExpression"; | type: "UnaryExpression"; | ||
| 第430行: | 第979行: | ||
arg: Expression | arg: Expression | ||
isPrefix: boolean | isPrefix: boolean | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A binary operator expression. | A binary operator expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface BinaryExpression <: Expression { | interface BinaryExpression <: Expression { | ||
type: "BinaryExpression"; | type: "BinaryExpression"; | ||
| 第444行: | 第995行: | ||
left: Expression | left: Expression | ||
right: Expression | right: Expression | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
An assignment operator expression. | An assignment operator expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface AssignmentExpression <: Expression { | interface AssignmentExpression <: Expression { | ||
type: "AssignmentExpression"; | type: "AssignmentExpression"; | ||
| 第458行: | 第1,011行: | ||
left: Expression | left: Expression | ||
right: Expression | right: Expression | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
An update (increment or decrement) operator expression. | An update (increment or decrement) operator expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface UpdateExpression <: Expression { | interface UpdateExpression <: Expression { | ||
type: "UpdateExpression"; | type: "UpdateExpression"; | ||
| 第472行: | 第1,027行: | ||
arg: Expression | arg: Expression | ||
isPrefix: boolean | isPrefix: boolean | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A logical operator expression. | A logical operator expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface LogicalExpression <: Expression { | interface LogicalExpression <: Expression { | ||
type: "LogicalExpression"; | type: "LogicalExpression"; | ||
| 第486行: | 第1,043行: | ||
left: Expression | left: Expression | ||
right: Expression | right: Expression | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A conditional expression, i.e., a ternary ?/: expression. | A conditional expression, i.e., a ternary ?/: expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface ConditionalExpression <: Expression { | interface ConditionalExpression <: Expression { | ||
type: "ConditionalExpression"; | type: "ConditionalExpression"; | ||
| 第500行: | 第1,059行: | ||
cons: Expression | cons: Expression | ||
alt: Expression | alt: Expression | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A new expression. | A new expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface NewExpression <: Expression { | interface NewExpression <: Expression { | ||
type: "NewExpression"; | type: "NewExpression"; | ||
| 第512行: | 第1,073行: | ||
callee: Expression | callee: Expression | ||
args: [ Expression ] | args: [ Expression ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A function or method call expression. | A function or method call expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface CallExpression <: Expression { | interface CallExpression <: Expression { | ||
type: "CallExpression"; | type: "CallExpression"; | ||
| 第524行: | 第1,087行: | ||
callee: Expression | callee: Expression | ||
args: [ Expression ] | args: [ Expression ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A member expression. | A member expression. | ||
If computed === true, the node corresponds to a computed e1[e2] expression and property is an Expression. If computed === false, the node corresponds to a static e1.x expression and property is an Identifier. | If computed === true, the node corresponds to a computed e1[e2] expression and property is an Expression. If computed === false, the node corresponds to a static e1.x expression and property is an Identifier. | ||
<syntaxhighlight lang="javascript"> | |||
interface MemberExpression <: Expression { | interface MemberExpression <: Expression { | ||
type: "MemberExpression"; | type: "MemberExpression"; | ||
| 第540行: | 第1,105行: | ||
prop: Identifier | Expression | prop: Identifier | Expression | ||
isComputed: boolean | isComputed: boolean | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A yield expression. | A yield expression. | ||
The Mozilla Parser API does not specify a type property for YieldExpression, so one has been added here. | The Mozilla Parser API does not specify a type property for YieldExpression, so one has been added here. | ||
<syntaxhighlight lang="javascript"> | |||
interface YieldExpression <: Expression { | interface YieldExpression <: Expression { | ||
type: "YieldExpression"; | type: "YieldExpression"; | ||
| 第552行: | 第1,119行: | ||
yieldExpression(arg[, loc]) | yieldExpression(arg[, loc]) | ||
arg: Expression | arg: Expression | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
An array comprehension. | An array comprehension. | ||
| 第561行: | 第1,129行: | ||
The Mozilla Parser API does not specify a type property for ComprehensionExpression, so one has been added here. | The Mozilla Parser API does not specify a type property for ComprehensionExpression, so one has been added here. | ||
<syntaxhighlight lang="javascript"> | |||
interface ComprehensionExpression <: Expression { | interface ComprehensionExpression <: Expression { | ||
type: "ComprehensionExpression"; | type: "ComprehensionExpression"; | ||
| 第572行: | 第1,141行: | ||
blocks: [ ComprehensionBlock ] | blocks: [ ComprehensionBlock ] | ||
filter: Expression | null | filter: Expression | null | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A generator expression. | A generator expression. | ||
| 第579行: | 第1,149行: | ||
The Mozilla Parser API does not specify a type property for GeneratorExpression, so one has been added here. | The Mozilla Parser API does not specify a type property for GeneratorExpression, so one has been added here. | ||
<syntaxhighlight lang="javascript"> | |||
interface GeneratorExpression <: Expression { | interface GeneratorExpression <: Expression { | ||
type: "GeneratorExpression"; | type: "GeneratorExpression"; | ||
| 第590行: | 第1,161行: | ||
blocks: [ ComprehensionBlock ] | blocks: [ ComprehensionBlock ] | ||
filter: Expression | null | filter: Expression | null | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A let expression. | A let expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface LetExpression <: Expression { | interface LetExpression <: Expression { | ||
type: "LetExpression"; | type: "LetExpression"; | ||
| 第602行: | 第1,175行: | ||
head: [ Declarator ] | head: [ Declarator ] | ||
body: Expression | body: Expression | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
Patterns | |||
=== Patterns === | |||
interface Pattern <: Node { } | interface Pattern <: Node { } | ||
An object-destructuring pattern. | An object-destructuring pattern. | ||
| 第609行: | 第1,183行: | ||
A literal property in an object pattern can have either a string or number as its value. | A literal property in an object pattern can have either a string or number as its value. | ||
<syntaxhighlight lang="javascript"> | |||
interface ObjectPattern <: Pattern { | interface ObjectPattern <: Pattern { | ||
type: "ObjectPattern"; | type: "ObjectPattern"; | ||
| 第616行: | 第1,191行: | ||
objectPattern(props[, loc]) | objectPattern(props[, loc]) | ||
props: [ PropertyPattern ] | props: [ PropertyPattern ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
An object property pattern. | An object property pattern. | ||
The Mozilla Parser API does not specify a type property for PropertyPattern, so one has been added here. | The Mozilla Parser API does not specify a type property for PropertyPattern, so one has been added here. | ||
<syntaxhighlight lang="javascript"> | |||
interface PropertyPattern <: Node { | interface PropertyPattern <: Node { | ||
type: "PropertyPattern"; | type: "PropertyPattern"; | ||
| 第630行: | 第1,207行: | ||
key: Literal | Identifier | key: Literal | Identifier | ||
patt: Pattern | patt: Pattern | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
An array-destructuring pattern. | An array-destructuring pattern. | ||
<syntaxhighlight lang="javascript"> | |||
interface ArrayPattern <: Pattern { | interface ArrayPattern <: Pattern { | ||
type: "ArrayPattern"; | type: "ArrayPattern"; | ||
| 第640行: | 第1,219行: | ||
arrayPattern(elts[, loc]) | arrayPattern(elts[, loc]) | ||
elts: [ Pattern | null ] | elts: [ Pattern | null ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
Clauses | |||
=== Clauses === | |||
A case (if test is an Expression) or default (if test === null) clause in the body of a switch statement. | A case (if test is an Expression) or default (if test === null) clause in the body of a switch statement. | ||
<syntaxhighlight lang="javascript"> | |||
interface SwitchCase <: Node { | interface SwitchCase <: Node { | ||
type: "SwitchCase"; | type: "SwitchCase"; | ||
| 第653行: | 第1,234行: | ||
test: Expression | null | test: Expression | null | ||
cons: [ Statement ] | cons: [ Statement ] | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A catch clause following a try block. | A catch clause following a try block. | ||
The optional guard property corresponds to the optional expression guard on the bound variable. | The optional guard property corresponds to the optional expression guard on the bound variable. | ||
<syntaxhighlight lang="javascript"> | |||
interface CatchClause <: Node { | interface CatchClause <: Node { | ||
type: "CatchClause"; | type: "CatchClause"; | ||
| 第669行: | 第1,252行: | ||
guard: Expression | guard: Expression | ||
body: Statement | body: Statement | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A for or for each block in an array comprehension or generator expression. | A for or for each block in an array comprehension or generator expression. | ||
The Mozilla Parser API does not specify a type property for ComprehensionBlock, so one has been added here. | The Mozilla Parser API does not specify a type property for ComprehensionBlock, so one has been added here. | ||
<syntaxhighlight lang="javascript"> | |||
interface ComprehensionBlock <: Node { | interface ComprehensionBlock <: Node { | ||
type: "ComprehensionBlock"; | type: "ComprehensionBlock"; | ||
| 第685行: | 第1,270行: | ||
right: Expression | right: Expression | ||
isForEach: boolean | isForEach: boolean | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
Miscellaneous | |||
=== Miscellaneous === | |||
An identifier. | An identifier. | ||
Note that an identifier may be an expression or a destructuring pattern. | Note that an identifier may be an expression or a destructuring pattern. | ||
<syntaxhighlight lang="javascript"> | |||
interface Identifier <: Node, Expression, Pattern { | interface Identifier <: Node, Expression, Pattern { | ||
type: "Identifier"; | type: "Identifier"; | ||
| 第698行: | 第1,285行: | ||
identifier(name[, loc]) | identifier(name[, loc]) | ||
name: string | name: string | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A literal token. | A literal token. | ||
Note that a literal can be an expression. | Note that a literal can be an expression. | ||
<syntaxhighlight lang="javascript"> | |||
interface Literal <: Node, Expression { | interface Literal <: Node, Expression { | ||
type: "Literal"; | type: "Literal"; | ||
| 第710行: | 第1,299行: | ||
literal(val[, loc]) | literal(val[, loc]) | ||
val: string | boolean | null | number | RegExp | val: string | boolean | null | number | RegExp | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
An object property initializer. | An object property initializer. | ||
The order of the arguments in the builder intentionally differs from that specified by the Mozilla Parser API: the kind argument comes third, rather than first. | The order of the arguments in the builder intentionally differs from that specified by the Mozilla Parser API: the kind argument comes third, rather than first. | ||
<syntaxhighlight lang="javascript"> | |||
interface Property < Node { | interface Property < Node { | ||
type: "Property"; | type: "Property"; | ||
| 第726行: | 第1,317行: | ||
val: Expression | val: Expression | ||
kind: "init" | "get" | "set" | kind: "init" | "get" | "set" | ||
loc: SourceLocation | loc: SourceLocation</syntaxhighlight> | ||
A unary operator token. | A unary operator token. | ||
2022年11月25日 (五) 04:49的最新版本
estree/es5
Node objects
ESTree AST nodes are represented as Node objects, which may have any prototype inheritance but which implement the following interface:
interface Node {
type: string;
loc: SourceLocation | null;
}
The type field is a string representing the AST variant type. Each subtype of Node is documented below with the specific string of its type field. You can use this field to determine which interface a node implements.
The loc field represents the source location information of the node. If the node contains no information about the source location, the field is null; otherwise it is an object consisting of a start position (the position of the first character of the parsed source region) and an end position (the position of the first character after the parsed source region):
interface SourceLocation {
source: string | null;
start: Position;
end: Position;
}
Each Position object consists of a line number (1-indexed) and a column number (0-indexed):
interface Position {
line: number; // >= 1
column: number; // >= 0
}
Identifier
interface Identifier <: Expression, Pattern {
type: "Identifier";
name: string;
}
An identifier. Note that an identifier may be an expression or a destructuring pattern.
Literal
interface Literal <: Expression {
type: "Literal";
value: string | boolean | null | number | RegExp;
}
A literal token. Note that a literal can be an expression.
RegExpLiteral
interface RegExpLiteral <: Literal {
regex: {
pattern: string;
flags: string;
};
}
The regex property allows regexes to be represented in environments that don’t support certain flags such as y or u. In environments that don't support these flags value will be null as the regex can't be represented natively.
Programs
interface Program <: Node {
type: "Program";
body: [ Directive | Statement ];
}
A complete program source tree.
Functions
interface Function <: Node {
id: Identifier | null;
params: [ Pattern ];
body: FunctionBody;
}
A function declaration or expression.
Statements
interface Statement <: Node { }
Any statement.
ExpressionStatement
interface ExpressionStatement <: Statement {
type: "ExpressionStatement";
expression: Expression;
}
An expression statement, i.e., a statement consisting of a single expression.
Directive
interface Directive <: ExpressionStatement {
expression: Literal;
directive: string;
}
A directive from the directive prologue of a script or function. The directive property is the raw string source of the directive without quotes.
BlockStatement
interface BlockStatement <: Statement {
type: "BlockStatement";
body: [ Statement ];
}
A block statement, i.e., a sequence of statements surrounded by braces.
FunctionBody
interface FunctionBody <: BlockStatement {
body: [ Directive | Statement ];
}
The body of a function, which is a block statement that may begin with directives.
EmptyStatement
interface EmptyStatement <: Statement {
type: "EmptyStatement";
}
An empty statement, i.e., a solitary semicolon.
DebuggerStatement
interface DebuggerStatement <: Statement {
type: "DebuggerStatement";
}
A debugger statement.
WithStatement
interface WithStatement <: Statement {
type: "WithStatement";
object: Expression;
body: Statement;
}
A with statement.
Control flow ReturnStatement
interface ReturnStatement <: Statement {
type: "ReturnStatement";
argument: Expression | null;
}
A return statement.
LabeledStatement
interface LabeledStatement <: Statement {
type: "LabeledStatement";
label: Identifier;
body: Statement;
}
A labeled statement, i.e., a statement prefixed by a break/continue label.
BreakStatement
interface BreakStatement <: Statement {
type: "BreakStatement";
label: Identifier | null;
}
A break statement.
ContinueStatement
interface ContinueStatement <: Statement {
type: "ContinueStatement";
label: Identifier | null;
}
A continue statement.
Choice IfStatement
interface IfStatement <: Statement {
type: "IfStatement";
test: Expression;
consequent: Statement;
alternate: Statement | null;
}
An if statement.
SwitchStatement
interface SwitchStatement <: Statement {
type: "SwitchStatement";
discriminant: Expression;
cases: [ SwitchCase ];
}
A switch statement.
SwitchCase
interface SwitchCase <: Node {
type: "SwitchCase";
test: Expression | null;
consequent: [ Statement ];
}
A case (if test is an Expression) or default (if test === null) clause in the body of a switch statement.
Exceptions ThrowStatement
interface ThrowStatement <: Statement {
type: "ThrowStatement";
argument: Expression;
}
A throw statement.
TryStatement
interface TryStatement <: Statement {
type: "TryStatement";
block: BlockStatement;
handler: CatchClause | null;
finalizer: BlockStatement | null;
}
A try statement. If handler is null then finalizer must be a BlockStatement.
CatchClause
interface CatchClause <: Node {
type: "CatchClause";
param: Pattern;
body: BlockStatement;
}
A catch clause following a try block.
Loops WhileStatement
interface WhileStatement <: Statement {
type: "WhileStatement";
test: Expression;
body: Statement;
}
A while statement.
DoWhileStatement
interface DoWhileStatement <: Statement {
type: "DoWhileStatement";
body: Statement;
test: Expression;
}
A do/while statement.
ForStatement
interface ForStatement <: Statement {
type: "ForStatement";
init: VariableDeclaration | Expression | null;
test: Expression | null;
update: Expression | null;
body: Statement;
}
A for statement.
ForInStatement
interface ForInStatement <: Statement {
type: "ForInStatement";
left: VariableDeclaration | Pattern;
right: Expression;
body: Statement;
}
A for/in statement.
Declarations
interface Declaration <: Statement { }
Any declaration node. Note that declarations are considered statements; this is because declarations can appear in any statement context.
FunctionDeclaration
interface FunctionDeclaration <: Function, Declaration {
type: "FunctionDeclaration";
id: Identifier;
}
A function declaration. Note that unlike in the parent interface Function, the id cannot be null.
VariableDeclaration
interface VariableDeclaration <: Declaration {
type: "VariableDeclaration";
declarations: [ VariableDeclarator ];
kind: "var";
}
A variable declaration.
VariableDeclarator
interface VariableDeclarator <: Node {
type: "VariableDeclarator";
id: Pattern;
init: Expression | null;
}
A variable declarator.
Expressions
interface Expression <: Node { }
Any expression node. Since the left-hand side of an assignment may be any expression in general, an expression can also be a pattern.
ThisExpression
interface ThisExpression <: Expression {
type: "ThisExpression";
}
A this expression.
ArrayExpression
interface ArrayExpression <: Expression {
type: "ArrayExpression";
elements: [ Expression | null ];
}
An array expression. An element might be null if it represents a hole in a sparse array. E.g. [1,,2].
ObjectExpression
interface ObjectExpression <: Expression {
type: "ObjectExpression";
properties: [ Property ];
}
An object expression.
Property
interface Property <: Node {
type: "Property";
key: Literal | Identifier;
value: Expression;
kind: "init" | "get" | "set";
}
A literal property in an object expression can have either a string or number as its value. Ordinary property initializers have a kind value "init"; getters and setters have the kind values "get" and "set", respectively.
FunctionExpression
interface FunctionExpression <: Function, Expression {
type: "FunctionExpression";
}
A function expression.
Unary operations UnaryExpression
interface UnaryExpression <: Expression {
type: "UnaryExpression";
operator: UnaryOperator;
prefix: boolean;
argument: Expression;
}
A unary operator expression.
UnaryOperator
enum UnaryOperator {
"-" | "+" | "!" | "~" | "typeof" | "void" | "delete"
}
A unary operator token.
UpdateExpression
interface UpdateExpression <: Expression {
type: "UpdateExpression";
operator: UpdateOperator;
argument: Expression;
prefix: boolean;
}
An update (increment or decrement) operator expression.
UpdateOperator
enum UpdateOperator {
"++" | "--"
}
An update (increment or decrement) operator token.
Binary operations BinaryExpression
interface BinaryExpression <: Expression {
type: "BinaryExpression";
operator: BinaryOperator;
left: Expression;
right: Expression;
}
A binary operator expression.
BinaryOperator
enum BinaryOperator {
"==" | "!=" | "===" | "!=="
| "<" | "<=" | ">" | ">="
| "<<" | ">>" | ">>>"
| "+" | "-" | "*" | "/" | "%"
| "|" | "^" | "&" | "in"
| "instanceof"
}
A binary operator token.
AssignmentExpression
interface AssignmentExpression <: Expression {
type: "AssignmentExpression";
operator: AssignmentOperator;
left: Pattern | Expression;
right: Expression;
}
An assignment operator expression.
AssignmentOperator
enum AssignmentOperator {
"=" | "+=" | "-=" | "*=" | "/=" | "%="
| "<<=" | ">>=" | ">>>="
| "|=" | "^=" | "&="
}
An assignment operator token.
LogicalExpression
interface LogicalExpression <: Expression {
type: "LogicalExpression";
operator: LogicalOperator;
left: Expression;
right: Expression;
}
A logical operator expression.
LogicalOperator
enum LogicalOperator {
"||" | "&&"
}
A logical operator token.
MemberExpression
interface MemberExpression <: Expression, Pattern {
type: "MemberExpression";
object: Expression;
property: Expression;
computed: boolean;
}
A member expression. If computed is true, the node corresponds to a computed (a[b]) member expression and property is an Expression. If computed is false, the node corresponds to a static (a.b) member expression and property is an Identifier.
ConditionalExpression
interface ConditionalExpression <: Expression {
type: "ConditionalExpression";
test: Expression;
alternate: Expression;
consequent: Expression;
}
A conditional expression, i.e., a ternary ?/: expression.
CallExpression
interface CallExpression <: Expression {
type: "CallExpression";
callee: Expression;
arguments: [ Expression ];
}
A function or method call expression.
NewExpression
interface NewExpression <: Expression {
type: "NewExpression";
callee: Expression;
arguments: [ Expression ];
}
A new expression.
SequenceExpression
interface SequenceExpression <: Expression {
type: "SequenceExpression";
expressions: [ Expression ];
}
A sequence expression, i.e., a comma-separated sequence of expressions.
Patterns
Destructuring binding and assignment are not part of ES5, but all binding positions accept Pattern to allow for destructuring in ES6. Nevertheless, for ES5, the only Pattern subtype is Identifier.
interface Pattern <: Node { }
SpiderMonkey Parser API
Node objects
interface Node {
type: string;
loc: SourceLocation | null;
}
interface SourceLocation {
source: string | null;
start: Position;
end: Position;
}
interface Position {
line: uint32 >= 1;
column: uint32 >= 0;
}
Programs
A complete program source tree.
interface Program <: Node {
type: "Program";
body: [ Statement ];
}
program(body[, loc])
body: [ Statement ]
loc: SourceLocation
Functions
A function declaration or expression.
interface Function <: Node {
id: Identifier | null;
params: [ Pattern ];
defaults: [ Expression ];
rest: Identifier | null;
body: BlockStatement | Expression;
generator: boolean;
expression: boolean;
}
Statements
Any statement.
interface Statement <: Node { } An empty statement, i.e., a solitary semicolon.
interface EmptyStatement <: Statement {
type: "EmptyStatement";
}
emptyStatement([loc])
loc: SourceLocation
A block statement, i.e., a sequence of statements surrounded by braces.
The builder differs from that specified in the Mozilla Parser API: body is an Array of Statements instead of a single Statement.
interface BlockStatement <: Statement {
type: "BlockStatement";
body: [ Statement ];
}
blockStatement(body[, loc])
body: [ Statement ]
loc: SourceLocation
An expression statement, i.e., a statement consisting of a single expression.
interface ExpressionStatement <: Statement {
type: "ExpressionStatement";
expression: Expression;
}
expressionStatement(expr[, loc])
expr: Expression
loc: SourceLocation
An if statement.
interface IfStatement <: Statement {
type: "IfStatement";
test: Expression;
consequent: Statement;
alternate: Statement | null;
}
ifStatement(test, cons, alt[, loc])
test: Expression
cons: Statement
alt: Statement | null
loc: SourceLocation
A labeled statement, i.e., a statement prefixed by a break/continue label.
interface LabeledStatement <: Statement {
type: "LabeledStatement";
label: Identifier;
body: Statement;
}
labeledStatement(label, body[, loc])
label: Identifier
body: Statement
loc: SourceLocation
A break statement.
interface BreakStatement <: Statement {
type: "BreakStatement";
label: Identifier | null;
}
breakStatement(label[, loc])
label: Identifier | null
loc: SourceLocation
A continue statement.
interface ContinueStatement <: Statement {
type: "ContinueStatement";
label: Identifier | null;
}
continueStatement(label[, loc])
label: Identifier | null
loc: SourceLocation
A with statement.
interface WithStatement <: Statement {
type: "WithStatement";
object: Expression;
body: Statement;
}
withStatement(obj, body[, loc])
obj: Expression
body: Statement
loc: SourceLocation
A switch statement.
The lexical flag is metadata indicating whether the switch statement contains any unnested let declarations (and therefore introduces a new lexical scope).
interface SwitchStatement <: Statement {
type: "SwitchStatement";
discriminant: Expression;
cases: [ SwitchCase ];
lexical: boolean;
}
switchStatement(disc, cases, isLexical[, loc])
disc: Expression
cases: [ SwitchCase ]
isLexical: boolean
loc: SourceLocation
A return statement.
interface ReturnStatement <: Statement {
type: "ReturnStatement";
argument: Expression | null;
}
returnStatement(arg[, loc])
arg: Expression | null
loc: SourceLocation
A throw statement.
interface ThrowStatement <: Statement {
type: "ThrowStatement";
argument: Expression;
}
throwStatement(arg[, loc])
arg: Expression
loc: SourceLocation
A try statement.
The builder in the Mozilla Parser API accepts multiple handlers. This only accepts a single handler.
interface TryStatement <: Statement {
type: "TryStatement";
block: BlockStatement;
handler: CatchClause | null;
guardedHandlers: [ CatchClause ];
finalizer: BlockStatement | null;
}
tryStatement(body, handler, fin[, loc])
body: Statement
handler: CatchClause
fin: Statement | null
loc: SourceLocation
A while statement.
interface WhileStatement <: Statement {
type: "WhileStatement";
test: Expression;
body: Statement;
}
whileStatement(test, body[, loc])
test: Expression
body: Statement
loc: SourceLocation
A do/while statement.
interface DoWhileStatement <: Statement {
type: "DoWhileStatement";
body: Statement;
test: Expression;
}
doWhileStatement(body, test[, loc])
body: Statement
test: Expression
loc: SourceLocation
A for statement.
interface ForStatement <: Statement {
type: "ForStatement";
init: VariableDeclaration | Expression | null;
test: Expression | null;
update: Expression | null;
body: Statement;
}
forStatement(init, test, update, body[, loc])
init: VariableDeclaration | Expression | null
test: Expression | null
update: Expression | null
body: Statement
loc: SourceLocation
A for/in statement, or, if each is true, a for each/in statement.
interface ForInStatement <: Statement {
type: "ForInStatement";
left: VariableDeclaration | Expression;
right: Expression;
body: Statement;
each: boolean;
}
forInStatement(left, right, body, isForEach[, loc])
left: VariableDeclaration | Expression
right: Expression
body: Statement
isForEach: boolean
loc: SourceLocation
A for/of statement.
The Mozilla Parser API does not define a builder, so one has been defined here.
interface ForOfStatement <: Statement {
type: "ForOfStatement";
left: VariableDeclaration | Expression;
right: Expression;
body: Statement;
}
forOfStatement(left, right, body[, loc])
left: VariableDeclaration | Expression
right: Expression
body: Statement
A let statement.
interface LetStatement <: Statement {
type: "LetStatement";
head: [ { id: Pattern, init: Expression | null } ];
body: Statement;
}
letStatement(head, body[, loc])
head: [ Declarator ]
body: Statement
loc: SourceLocation
A debugger statement.
interface DebuggerStatement <: Statement {
type: "DebuggerStatement";
}
debuggerStatement([loc])
loc: SourceLocation
Declarations
Any declaration node.
interface Declaration <: Statement { } A function declaration.
The builder intentionally differs from the Mozilla Parser API in its arguments instead of (name, args, body, isGenerator, isExpression[, loc]).
interface FunctionDeclaration <: Function, Declaration {
type: "FunctionDeclaration";
id: Identifier;
params: [ Pattern ];
defaults: [ Expression ];
rest: Identifier | null;
body: BlockStatement | Expression;
generator: boolean;
expression: boolean;
}
functionDeclaration(id, params, defaults, rest, body, isGenerator, isExpression[, loc])
id: Identifier
params: [ Pattern ]
defaults: [ Expression ]
rest: Identifier | null
body: BlockStatement | Expression
isGenerator: boolean
isExpression: boolean
loc: SourceLocation
A variable declaration, via one of var, let, or const.
interface VariableDeclaration <: Declaration {
type: "VariableDeclaration";
declarations: [ VariableDeclarator ];
kind: "var" | "let" | "const";
}
variableDeclaration(kind, dtors[, loc])
kind: "var" | "let" | "const"
dtors: [ Declarator ]
loc: SourceLocation
A variable declarator.
interface VariableDeclarator <: Node {
type: "VariableDeclarator";
id: Pattern;
init: Expression | null;
}
variableDeclarator(patt, init[, loc])
patt: Pattern
init: Expression | null
loc: SourceLocation
Expressions
Any expression node.
interface Expression <: Node, Pattern { } A this expression.
interface ThisExpression <: Expression {
type: "ThisExpression";
}
thisExpression([loc])
loc: SourceLocation
An array expression.
interface ArrayExpression <: Expression {
type: "ArrayExpression";
elements: [ Expression | null ];
}
arrayExpression(elts[, loc])
elts: [ Expression | null ]
loc: SourceLocation
An object expression.
A literal property in an object expression can have either a string or number as its value.
Ordinary property initializers have a kind value "init"; getters and setters have the kind values "get" and "set", respectively.
interface ObjectExpression <: Expression {
type: "ObjectExpression";
properties: [ Property ];
}
objectExpression(props[, loc])
props: [ Property ]
loc: SourceLocation
A function expression.
The builder intentionally differs from the Mozilla Parser API in its arguments instead of (name, args, body, isGenerator, isExpression[, loc]).
interface FunctionExpression <: Function, Expression {
type: "FunctionExpression";
id: Identifier | null;
params: [ Pattern ];
defaults: [ Expression ];
rest: Identifier | null;
body: BlockStatement | Expression;
generator: boolean;
expression: boolean;
}
functionExpression(id, params, defaults, rest, body, isGenerator, isExpression[, loc])
id: Identifier | null
params: [ Pattern ]
defaults: [ Expression ]
rest: Identifier | null
body: BlockStatement | Expression
isGenerator: boolean
isExpression: boolean
loc: SourceLocation
A fat arrow function expression, i.e., `let foo = (bar) => { /* body */ }`.
The Mozilla Parser API does not specify a builder for the ArrowFunction node, so one has been created here.
interface ArrowExpression <: Function, Expression {
type: "ArrowExpression";
params: [ Pattern ];
defaults: [ Expression ];
rest: Identifier | null;
body: BlockStatement | Expression;
generator: boolean;
expression: boolean;
}
arrowExpression(params, defaults, rest, body, isGenerator, isExpression[, loc])
params: [ Pattern ]
defaults: [ Expression ]
rest: Identifier | null
body: BlockStatement | Expression
isGenerator: boolean
isExpression: boolean
loc: SourceLocation
A sequence expression, i.e., a comma-separated sequence of expressions.
interface SequenceExpression <: Expression {
type: "SequenceExpression";
expressions: [ Expression ];
}
sequenceExpression(exprs[, loc])
exprs: [ Expression ]
loc: SourceLocation
A unary operator expression.
interface UnaryExpression <: Expression {
type: "UnaryExpression";
operator: UnaryOperator;
prefix: boolean;
argument: Expression;
}
unaryExpression(op, arg, isPrefix[, loc])
op: UnaryOperator
arg: Expression
isPrefix: boolean
loc: SourceLocation
A binary operator expression.
interface BinaryExpression <: Expression {
type: "BinaryExpression";
operator: BinaryOperator;
left: Expression;
right: Expression;
}
binaryExpression(op, left, right[, loc])
op: BinaryOperator
left: Expression
right: Expression
loc: SourceLocation
An assignment operator expression.
interface AssignmentExpression <: Expression {
type: "AssignmentExpression";
operator: AssignmentOperator;
left: Expression;
right: Expression;
}
assignmentExpression(op, left, right[, loc])
op: AssignmentOperator
left: Expression
right: Expression
loc: SourceLocation
An update (increment or decrement) operator expression.
interface UpdateExpression <: Expression {
type: "UpdateExpression";
operator: UpdateOperator;
argument: Expression;
prefix: boolean;
}
updateExpression(op, arg, isPrefix[, loc])
op: UpdateOperator
arg: Expression
isPrefix: boolean
loc: SourceLocation
A logical operator expression.
interface LogicalExpression <: Expression {
type: "LogicalExpression";
operator: LogicalOperator;
left: Expression;
right: Expression;
}
logicalExpression(op, left, right[, loc])
op: LogicalOperator
left: Expression
right: Expression
loc: SourceLocation
A conditional expression, i.e., a ternary ?/: expression.
interface ConditionalExpression <: Expression {
type: "ConditionalExpression";
test: Expression;
alternate: Expression;
consequent: Expression;
}
conditionalExpression(test, cons, alt[, loc])
test: Expression
cons: Expression
alt: Expression
loc: SourceLocation
A new expression.
interface NewExpression <: Expression {
type: "NewExpression";
callee: Expression;
arguments: [ Expression | null ];
}
newExpression(callee, args[, loc])
callee: Expression
args: [ Expression ]
loc: SourceLocation
A function or method call expression.
interface CallExpression <: Expression {
type: "CallExpression";
callee: Expression;
arguments: [ Expression | null ];
}
callExpression(callee, args[, loc])
callee: Expression
args: [ Expression ]
loc: SourceLocation
A member expression.
If computed === true, the node corresponds to a computed e1[e2] expression and property is an Expression. If computed === false, the node corresponds to a static e1.x expression and property is an Identifier.
interface MemberExpression <: Expression {
type: "MemberExpression";
object: Expression;
property: Identifier | Expression;
computed: boolean;
}
memberExpression(obj, prop, isComputed[, loc])
obj: Expression
prop: Identifier | Expression
isComputed: boolean
loc: SourceLocation
A yield expression.
The Mozilla Parser API does not specify a type property for YieldExpression, so one has been added here.
interface YieldExpression <: Expression {
type: "YieldExpression";
argument: Expression | null;
}
yieldExpression(arg[, loc])
arg: Expression
loc: SourceLocation
An array comprehension.
The blocks array corresponds to the sequence of for and for each blocks.
The optional filter expression corresponds to the final if clause, if present.
The Mozilla Parser API does not specify a type property for ComprehensionExpression, so one has been added here.
interface ComprehensionExpression <: Expression {
type: "ComprehensionExpression";
body: Expression;
blocks: [ ComprehensionBlock ];
filter: Expression | null;
}
comprehensionExpression(body, blocks, filter[, loc])
body: Expression
blocks: [ ComprehensionBlock ]
filter: Expression | null
loc: SourceLocation
A generator expression.
As with array comprehensions, the blocks array corresponds to the sequence of for and for each blocks, and the optional filter expression corresponds to the final if clause, if present.
The Mozilla Parser API does not specify a type property for GeneratorExpression, so one has been added here.
interface GeneratorExpression <: Expression {
type: "GeneratorExpression";
body: Expression;
blocks: [ ComprehensionBlock ];
filter: Expression | null;
}
generatorExpression(body, blocks, filter[, loc])
body: Expression
blocks: [ ComprehensionBlock ]
filter: Expression | null
loc: SourceLocationA let expression.
interface LetExpression <: Expression {
type: "LetExpression";
head: [ { id: Pattern, init: Expression | null } ];
body: Expression;
}
letExpression(head, body[, loc])
head: [ Declarator ]
body: Expression
loc: SourceLocationPatterns
interface Pattern <: Node { } An object-destructuring pattern.
A literal property in an object pattern can have either a string or number as its value.
interface ObjectPattern <: Pattern {
type: "ObjectPattern";
properties: [ PropertyPattern ];
}
objectPattern(props[, loc])
props: [ PropertyPattern ]
loc: SourceLocationAn object property pattern.
The Mozilla Parser API does not specify a type property for PropertyPattern, so one has been added here.
interface PropertyPattern <: Node {
type: "PropertyPattern";
key: Literal | Identifier;
value: Pattern;
}
propertyPattern(key, patt[, loc])
key: Literal | Identifier
patt: Pattern
loc: SourceLocationAn array-destructuring pattern.
interface ArrayPattern <: Pattern {
type: "ArrayPattern";
elements: [ Pattern | null ];
}
arrayPattern(elts[, loc])
elts: [ Pattern | null ]
loc: SourceLocationClauses
A case (if test is an Expression) or default (if test === null) clause in the body of a switch statement.
interface SwitchCase <: Node {
type: "SwitchCase";
test: Expression | null;
consequent: [ Statement ];
}
switchCase(test, cons[, loc])
test: Expression | null
cons: [ Statement ]
loc: SourceLocationA catch clause following a try block.
The optional guard property corresponds to the optional expression guard on the bound variable.
interface CatchClause <: Node {
type: "CatchClause";
param: Pattern;
guard: Expression | null;
body: BlockStatement;
}
catchClause(arg, guard, body[, loc])
arg: Pattern
guard: Expression
body: Statement
loc: SourceLocationA for or for each block in an array comprehension or generator expression.
The Mozilla Parser API does not specify a type property for ComprehensionBlock, so one has been added here.
interface ComprehensionBlock <: Node {
type: "ComprehensionBlock";
left: Pattern;
right: Expression;
each: boolean;
}
comprehensionBlock(left, right, isForEach[, loc])
left: Pattern
right: Expression
isForEach: boolean
loc: SourceLocationMiscellaneous
An identifier.
Note that an identifier may be an expression or a destructuring pattern.
interface Identifier <: Node, Expression, Pattern {
type: "Identifier";
name: string;
}
identifier(name[, loc])
name: string
loc: SourceLocationA literal token.
Note that a literal can be an expression.
interface Literal <: Node, Expression {
type: "Literal";
value: string | boolean | null | number | RegExp;
}
literal(val[, loc])
val: string | boolean | null | number | RegExp
loc: SourceLocationAn object property initializer.
The order of the arguments in the builder intentionally differs from that specified by the Mozilla Parser API: the kind argument comes third, rather than first.
interface Property < Node {
type: "Property";
key: Literal | Identifier;
value: Expression;
kind: "init" | "get" | "set";
}
property(key, val, kind[, loc])
key: Literal | Identifier
val: Expression
kind: "init" | "get" | "set"
loc: SourceLocationA unary operator token.
enum UnaryOperator {
"-" | "+" | "!" | "~" | "typeof" | "void" | "delete"
}A binary operator token.
enum BinaryOperator {
"==" | "!=" | "===" | "!=="
| "<" | "<=" | ">" | ">="
| "<<" | ">>" | ">>>"
| "+" | "-" | "*" | "/" | "%"
| "&" | "|" | "^" | "in"
| "instanceof" | ".."
}A logical operator token.
enum LogicalOperator {
"||" | "&&"
}An assignment operator token.
enum AssignmentOperator {
"=" | "+=" | "-=" | "*=" | "/=" | "%="
| "<<=" | ">>=" | ">>>="
| "|=" | "^=" | "&="
}An update (increment or decrement) operator token.
enum UpdateOperator {
"++" | "--"
}