simplex-lang 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,155 @@
1
+ export type Expression =
2
+ | ArrayExpression
3
+ | BinaryExpression
4
+ | CallExpression
5
+ | ConditionalExpression
6
+ | IdentifierExpression
7
+ | LogicalExpression
8
+ | LiteralExpression
9
+ | MemberExpression
10
+ | ObjectExpression
11
+ | NullishCoalescingExpression
12
+ | PipeSequence
13
+ | UnaryExpression
14
+
15
+ export type ExpressionType = Expression['type']
16
+
17
+ export type ExpressionByType = {
18
+ [P in ExpressionType]: Extract<Expression, { type: P }>
19
+ }
20
+
21
+ export interface LocationOffset {
22
+ offset: number
23
+ line: number
24
+ column: number
25
+ }
26
+
27
+ export interface Location {
28
+ start: LocationOffset
29
+ end: LocationOffset
30
+ }
31
+
32
+ export interface ExpressionStatement {
33
+ type: 'ExpressionStatement'
34
+ expression: Expression
35
+ location: Location
36
+ }
37
+
38
+ export interface LiteralExpression {
39
+ type: 'Literal'
40
+ value: string | number | null | boolean
41
+ location: Location
42
+ }
43
+
44
+ export interface IdentifierExpression {
45
+ type: 'Identifier'
46
+ name: string
47
+ location: Location
48
+ }
49
+
50
+ export interface PropertyAssignment {
51
+ type: 'Property'
52
+ key: Expression
53
+ value: Expression
54
+ kind: 'init'
55
+ location: Location
56
+ }
57
+
58
+ export interface ObjectExpression {
59
+ type: 'ObjectExpression'
60
+ properties: PropertyAssignment[]
61
+ location: Location
62
+ }
63
+
64
+ export interface ArrayExpression {
65
+ type: 'ArrayExpression'
66
+ elements: (Expression | null)[]
67
+ location: Location
68
+ }
69
+
70
+ export type MemberExpression =
71
+ | {
72
+ type: 'MemberExpression'
73
+ computed: false
74
+ object: IdentifierExpression | ObjectExpression | ArrayExpression
75
+ property: IdentifierExpression
76
+ location: Location
77
+ }
78
+ | {
79
+ type: 'MemberExpression'
80
+ computed: true
81
+ object: IdentifierExpression | ObjectExpression | ArrayExpression
82
+ property: Expression
83
+ location: Location
84
+ }
85
+
86
+ export interface CallExpression {
87
+ type: 'CallExpression'
88
+ callee: Expression
89
+ arguments: Expression[]
90
+ location: Location
91
+ }
92
+
93
+ export interface UnaryExpression {
94
+ type: 'UnaryExpression'
95
+ operator: '-' | '+' | 'not' | 'typeof'
96
+ argument: Expression
97
+ prefix: true
98
+ location: Location
99
+ }
100
+
101
+ export interface BinaryExpression {
102
+ type: 'BinaryExpression'
103
+ operator:
104
+ | '+'
105
+ | '-'
106
+ | '*'
107
+ | '/'
108
+ | 'mod'
109
+ | '=='
110
+ | '!='
111
+ | '>'
112
+ | '>='
113
+ | '<'
114
+ | '<='
115
+ | 'in'
116
+ | '^'
117
+ | '&'
118
+ left: Expression
119
+ right: Expression
120
+ location: Location
121
+ }
122
+
123
+ export interface LogicalExpression {
124
+ type: 'LogicalExpression'
125
+ operator: 'and' | 'or'
126
+ left: Expression
127
+ right: Expression
128
+ location: Location
129
+ }
130
+
131
+ export interface ConditionalExpression {
132
+ type: 'ConditionalExpression'
133
+ test: Expression
134
+ consequent: Expression
135
+ alternate: Expression | null
136
+ location: Location
137
+ }
138
+
139
+ export interface NullishCoalescingExpression {
140
+ type: 'NullishCoalescingExpression'
141
+ operator: '??'
142
+ left: Expression
143
+ right: Expression
144
+ location: Location
145
+ }
146
+
147
+ export interface PipeSequence {
148
+ type: 'PipeSequence'
149
+ head: Expression
150
+ tail: {
151
+ operator: '|?' | '|'
152
+ expression: Expression
153
+ }[]
154
+ location: Location
155
+ }