@@ -26,7 +26,7 @@ export class ParseError extends SyntaxError {
26
26
message : string ,
27
27
offset : number ,
28
28
line : number ,
29
- column : number
29
+ column : number ,
30
30
) {
31
31
super ( message ) ;
32
32
this . index = offset ;
@@ -42,14 +42,14 @@ export class ParseError extends SyntaxError {
42
42
*/
43
43
export function throwExpectedTokenError (
44
44
name : string ,
45
- beforeToken : MaybeNodeOrToken
45
+ beforeToken : MaybeNodeOrToken ,
46
46
) : never {
47
47
const locs = getLocation ( beforeToken ) ;
48
48
const err = new ParseError (
49
49
`Expected token '${ name } '.` ,
50
50
locs . end ,
51
51
locs . loc . end . line ,
52
- locs . loc . end . column + 1
52
+ locs . loc . end . column + 1 ,
53
53
) ;
54
54
55
55
throw err ;
@@ -62,14 +62,14 @@ export function throwExpectedTokenError(
62
62
*/
63
63
export function throwUnexpectedError (
64
64
name : string ,
65
- token : MaybeNodeOrToken
65
+ token : MaybeNodeOrToken ,
66
66
) : never {
67
67
const locs = getLocation ( token ) ;
68
68
const err = new ParseError (
69
69
`Unexpected ${ name } .` ,
70
70
locs . start ,
71
71
locs . loc . start . line ,
72
- locs . loc . start . column + 1
72
+ locs . loc . start . column + 1 ,
73
73
) ;
74
74
75
75
throw err ;
@@ -82,7 +82,7 @@ export function throwUnexpectedError(
82
82
*/
83
83
export function throwUnexpectedTokenError (
84
84
name : string ,
85
- token : MaybeNodeOrToken
85
+ token : MaybeNodeOrToken ,
86
86
) : never {
87
87
return throwUnexpectedError ( `token '${ name } '` , token ) ;
88
88
}
@@ -100,14 +100,14 @@ export function throwUnexpectedCommentError(token: Comment): never {
100
100
* Throw syntax error for unexpected whitespace.
101
101
*/
102
102
export function throwUnexpectedSpaceError (
103
- beforeToken : MaybeNodeOrToken
103
+ beforeToken : MaybeNodeOrToken ,
104
104
) : never {
105
105
const locs = getLocation ( beforeToken ) ;
106
106
const err = new ParseError (
107
107
"Unexpected whitespace." ,
108
108
locs . end ,
109
109
locs . loc . end . line ,
110
- locs . loc . end . column + 1
110
+ locs . loc . end . column + 1 ,
111
111
) ;
112
112
113
113
throw err ;
@@ -118,14 +118,14 @@ export function throwUnexpectedSpaceError(
118
118
*/
119
119
export function throwInvalidNumberError (
120
120
text : string ,
121
- token : MaybeNodeOrToken
121
+ token : MaybeNodeOrToken ,
122
122
) : never {
123
123
const locs = getLocation ( token ) ;
124
124
const err = new ParseError (
125
125
`Invalid number ${ text } .` ,
126
126
locs . start ,
127
127
locs . loc . start . line ,
128
- locs . loc . start . column + 1
128
+ locs . loc . start . column + 1 ,
129
129
) ;
130
130
131
131
throw err ;
@@ -138,15 +138,15 @@ export function throwInvalidNumberError(
138
138
export function throwUnexpectedNodeError (
139
139
node : Node | JSONNode ,
140
140
tokens : TokenStore ,
141
- offset ?: number
141
+ offset ?: number ,
142
142
) : never {
143
143
if ( node . type === "Identifier" || node . type === "JSONIdentifier" ) {
144
144
const locs = getLocation ( node ) ;
145
145
const err = new ParseError (
146
146
`Unexpected identifier '${ node . name } '.` ,
147
147
locs . start ,
148
148
locs . loc . start . line ,
149
- locs . loc . start . column + 1
149
+ locs . loc . start . column + 1 ,
150
150
) ;
151
151
throw err ;
152
152
}
@@ -164,7 +164,7 @@ export function throwUnexpectedNodeError(
164
164
`Unexpected ${ type } literal.` ,
165
165
locs . start ,
166
166
locs . loc . start . line ,
167
- locs . loc . start . column + 1
167
+ locs . loc . start . column + 1 ,
168
168
) ;
169
169
throw err ;
170
170
}
@@ -174,7 +174,7 @@ export function throwUnexpectedNodeError(
174
174
"Unexpected template literal." ,
175
175
locs . start ,
176
176
locs . loc . start . line ,
177
- locs . loc . start . column + 1
177
+ locs . loc . start . column + 1 ,
178
178
) ;
179
179
throw err ;
180
180
}
@@ -188,7 +188,7 @@ export function throwUnexpectedNodeError(
188
188
`Unexpected ${ name } .` ,
189
189
locs . start ,
190
190
locs . loc . start . line ,
191
- locs . loc . start . column + 1
191
+ locs . loc . start . column + 1 ,
192
192
) ;
193
193
throw err ;
194
194
}
@@ -200,15 +200,15 @@ export function throwUnexpectedNodeError(
200
200
`Unexpected token '${ name } '.` ,
201
201
locs . start ,
202
202
locs . loc . start . line ,
203
- locs . loc . start . column + 1
203
+ locs . loc . start . column + 1 ,
204
204
) ;
205
205
206
206
throw err ;
207
207
}
208
208
209
209
/** get locations */
210
210
function getLocation (
211
- token : MaybeNodeOrToken & { start ?: number ; end ?: number }
211
+ token : MaybeNodeOrToken & { start ?: number ; end ?: number } ,
212
212
) {
213
213
const start = token . range ?. [ 0 ] ?? token . start ! ;
214
214
const end = token . range ?. [ 1 ] ?? token . end ! ;
0 commit comments