-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexpression.go
138 lines (106 loc) · 2.89 KB
/
expression.go
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package ast
import "github.com/armsnyder/typescript-ast-go/token"
// Expr is a [Node] that represents an expression. An expression produces a
// value.
type Expr interface {
Node
expr()
}
// NumericLiteral is a numeric literal expression.
type NumericLiteral struct {
Text string
}
func (n *NumericLiteral) String() string {
return n.Text
}
func (*NumericLiteral) node() {}
func (*NumericLiteral) expr() {}
// StringLiteral is a string literal expression.
type StringLiteral struct {
Text string
}
func (n *StringLiteral) String() string {
return n.Text
}
func (*StringLiteral) node() {}
func (*StringLiteral) expr() {}
// ArrayLiteralExpression is an array literal expression.
type ArrayLiteralExpression struct {
Elements []Expr
}
func (*ArrayLiteralExpression) node() {}
func (*ArrayLiteralExpression) expr() {}
// Identifier is an identifier literal expression.
type Identifier struct {
Text string
}
func (n *Identifier) String() string {
return n.Text
}
func (*Identifier) node() {}
func (*Identifier) expr() {}
// QualifiedName is a qualified name expression.
type QualifiedName struct {
Left *Identifier
Right *Identifier
}
func (*QualifiedName) node() {}
func (*QualifiedName) expr() {}
// EnumMember is an enum member expression.
type EnumMember struct {
Name *Identifier
Initializer Expr
LeadingComment string
}
func (n *EnumMember) String() string {
return n.LeadingComment
}
func (*EnumMember) node() {}
func (*EnumMember) expr() {}
// TypeParameter is a type parameter expression.
type TypeParameter struct {
Name *Identifier
}
func (*TypeParameter) node() {}
func (*TypeParameter) expr() {}
// HeritageClause is a heritage clause expression.
type HeritageClause struct {
Types []*ExpressionWithTypeArguments
}
func (*HeritageClause) node() {}
func (*HeritageClause) expr() {}
// ExpressionWithTypeArguments is an expression with type arguments.
type ExpressionWithTypeArguments struct {
Expression *Identifier
}
func (*ExpressionWithTypeArguments) node() {}
func (*ExpressionWithTypeArguments) expr() {}
// Parameter is a parameter expression.
type Parameter struct {
Name *Identifier
Type Type
}
func (*Parameter) node() {}
func (*Parameter) expr() {}
// VariableDeclarationList is an expression that declares a list of variables.
type VariableDeclarationList struct {
Declarations []*VariableDeclaration
}
func (*VariableDeclarationList) node() {}
func (*VariableDeclarationList) expr() {}
// VariableDeclaration is an expression that declares a variable.
type VariableDeclaration struct {
Name *Identifier
Type Type
Initializer Expr
}
func (*VariableDeclaration) node() {}
func (*VariableDeclaration) expr() {}
// PrefixUnaryExpression is an expression that applies a unary operator to an
// operand.
type PrefixUnaryExpression struct {
Operator token.Kind
Operand Expr
}
func (*PrefixUnaryExpression) node() {}
func (*PrefixUnaryExpression) expr() {}