/
ast.d.ts
78 lines (67 loc) · 1.67 KB
/
ast.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
export interface Node {
type: string,
start: number,
end: number,
body?: any[],
}
export interface ASTNewExpression extends Node {
name: string,
callee: ASTIdentifier,
arguments: any[]
}
export interface ASTIdentifier extends Node {
name: string,
}
export interface ASTCallExpression extends Node {
callee: Node,
property: ASTIdentifier,
arguments: any[]
}
export interface ExpressionStatement extends Node {
type: "ExpressionStatement"
expression: ASTCallExpression,
arguments: any[]
}
export interface VariableDeclarator extends Node {
type: "VariableDeclarator"
id: ASTIdentifier,
init: ASTNewExpression
}
export interface VariableDeclaration extends Node {
type: "VariableDeclaration"
declarations: VariableDeclarator[],
init: ASTNewExpression
}
export interface BenchmarkSuite extends Node {
expression?: ASTCallExpression,
declarations?: VariableDeclarator[],
arguments?: any[]
}
export interface BenchmarkSuiteInstantiation {
name: string,
reference: number,
benchmarks: any,
ast: any
}
// https://esprima.readthedocs.io/en/latest/syntax-tree-format.html
export interface Identifier {
type: 'Identifier';
name: string;
}
export interface Literal {
type: 'Literal';
value: boolean | number | string | RegExp | null;
raw: string;
regex?: { pattern: string, flags: string };
}
export type Expression = Identifier | Literal;
export interface Property {
type: 'Property';
key: Expression;
computed: boolean;
value: Expression | null;
kind: string, // 'get' | 'set' | 'init';
method: boolean;
shorthand: boolean;
}
export as namespace AST;