@@ -32,13 +32,13 @@ export type MultiLineComment = {
3232export type Trivia = Whitespace | SingleLineComment | MultiLineComment
3333
3434export type Token <Kind = string > = {
35- read leadingTrivia : { Trivia },
36- read position : Position ,
37- read text : Kind ,
38- read trailingTrivia : { Trivia },
35+ leadingTrivia : { Trivia },
36+ position : Position ,
37+ text : Kind ,
38+ trailingTrivia : { Trivia },
3939}
4040
41- export type Eof = Token <nil > & { tag : "eof" }
41+ export type Eof = Token <"" > & { tag : "eof" }
4242
4343export type Pair <T , Separator > = { node : T , separator : Token <Separator >? }
4444export type Punctuated <T , Separator = "," > = { Pair <T , Separator > }
@@ -47,6 +47,7 @@ export type AstLocal = {
4747 name : Token <string >,
4848 colon : Token <":" >? ,
4949 annotation : AstType ? ,
50+ shadows : AstLocal ? ,
5051}
5152
5253export type AstExprGroup = {
@@ -84,24 +85,25 @@ export type AstExprVarargs = Token<"..."> & { tag: "vararg" }
8485
8586export type AstExprCall = {
8687 tag : "call" ,
87- func : AstExpr , -- TODO: stricter?
88+ func : AstExpr ,
8889 openParens : Token <"(" >? ,
8990 arguments : Punctuated <AstExpr >,
9091 closeParens : Token <")" >? ,
9192 self : boolean ,
93+ argLocation : Location ,
9294}
9395
9496export type AstExprIndexName = {
9597 tag : "indexname" ,
96- expr : AstExpr ,
98+ expression : AstExpr ,
9799 accessor : Token <"." | ":" >,
98100 index : Token <string >,
99101 indexLocation : Location ,
100102}
101103
102104export type AstExprIndexExpr = {
103105 tag : "index" ,
104- expr : AstExpr ,
106+ expression : AstExpr ,
105107 openBrackets : Token <"[" >,
106108 index : AstExpr ,
107109 closeBrackets : Token <"]" >,
@@ -112,6 +114,7 @@ export type AstFunctionBody = {
112114 generics : Punctuated <AstGenericType >? ,
113115 genericPacks : Punctuated <AstGenericTypePack >? ,
114116 closeGenerics : Token <">" >? ,
117+ self : AstLocal ? ,
115118 openParens : Token <"(" >,
116119 parameters : Punctuated <AstLocal >,
117120 vararg : Token <"..." >? ,
@@ -121,13 +124,13 @@ export type AstFunctionBody = {
121124 returnSpecifier : Token <":" >? ,
122125 returnAnnotation : AstTypePack ? ,
123126 body : AstStatBlock ,
124- [ "end" ] : Token <"end" >,
127+ endKeyword : Token <"end" >,
125128}
126129
127130export type AstExprAnonymousFunction = {
128131 tag : "function" ,
129132 attributes : { AstAttribute },
130- [ "function" ] : Token <"function" >,
133+ functionKeyword : Token <"function" >,
131134 body : AstFunctionBody ,
132135}
133136
@@ -181,20 +184,20 @@ export type AstExprTypeAssertion = {
181184}
182185
183186export type AstExprIfElseIfs = {
184- [ "elseif" ] : Token <"elseif" >,
187+ elseifKeyword : Token <"elseif" >,
185188 condition : AstExpr ,
186- [ "then" ] : Token <"then" >,
189+ thenKeyword : Token <"then" >,
187190 consequent : AstExpr ,
188191}
189192
190193export type AstExprIfElse = {
191194 tag : "conditional" ,
192- [ "if" ] : Token <"if" >,
195+ ifKeyword : Token <"if" >,
193196 condition : AstExpr ,
194- [ "then" ] : Token <"then" >,
197+ thenKeyword : Token <"then" >,
195198 consequent : AstExpr ,
196199 elseifs : { AstExprIfElseIfs },
197- [ "else" ] : Token <"else" >,
200+ elseKeyword : Token <"else" >,
198201 antecedent : AstExpr ,
199202}
200203
@@ -224,38 +227,38 @@ export type AstStatBlock = {
224227}
225228
226229export type AstStatElseIf = {
227- [ "elseif" ] : Token <"elseif" >,
230+ elseifKeyword : Token <"elseif" >,
228231 condition : AstExpr ,
229- [ "then" ] : Token <"then" >,
232+ thenKeyword : Token <"then" >,
230233 consequent : AstStatBlock ,
231234}
232235
233236export type AstStatIf = {
234237 tag : "conditional" ,
235- [ "if" ] : Token <"if" >,
238+ ifKeyword : Token <"if" >,
236239 condition : AstExpr ,
237- [ "then" ] : Token <"then" >,
240+ thenKeyword : Token <"then" >,
238241 consequent : AstStatBlock ,
239242 elseifs : { AstStatElseIf },
240- [ "else" ] : Token <"else" >, -- TODO: this could be elseif!
241- antecedent : AstStatBlock ,
242- [ "end" ] : Token <"end" >,
243+ elseKeyword : Token <"else" >? , -- TODO: this could be elseif!
244+ antecedent : AstStatBlock ? ,
245+ endKeyword : Token <"end" >,
243246}
244247
245248export type AstStatWhile = {
246249 tag : "while" ,
247- [ "while" ] : Token <"while" >,
250+ whileKeyword : Token <"while" >,
248251 condition : AstExpr ,
249- [ "do" ] : Token <"do" >,
252+ doKeyword : Token <"do" >,
250253 body : AstStatBlock ,
251- [ "end" ] : Token <"end" >,
254+ endKeyword : Token <"end" >,
252255}
253256
254257export type AstStatRepeat = {
255258 tag : "repeat" ,
256- [ "repeat" ] : Token <"repeat" >,
259+ repeatKeyword : Token <"repeat" >,
257260 body : AstStatBlock ,
258- [ "until" ] : Token <"until" >,
261+ untilKeyword : Token <"until" >,
259262 condition : AstExpr ,
260263}
261264
@@ -265,7 +268,7 @@ export type AstStatContinue = Token<"continue"> & { tag: "continue" }
265268
266269export type AstStatReturn = {
267270 tag : "return" ,
268- [ "return" ] : Token <"return" >,
271+ returnKeyword : Token <"return" >,
269272 expressions : Punctuated <AstExpr >,
270273}
271274
@@ -276,36 +279,36 @@ export type AstStatExpr = {
276279
277280export type AstStatLocal = {
278281 tag : "local" ,
279- [ "local" ] : Token <"local" >,
282+ localKeyword : Token <"local" >,
280283 variables : Punctuated <AstLocal >,
281284 equals : Token <"=" >? ,
282285 values : Punctuated <AstExpr >,
283286}
284287
285288export type AstStatFor = {
286289 tag : "for" ,
287- [ "for" ] : Token <"for" >,
290+ forKeyword : Token <"for" >,
288291 variable : AstLocal ,
289292 equals : Token <"=" >,
290293 from : AstExpr ,
291294 toComma : Token <"," >,
292295 to : AstExpr ,
293296 stepComma : Token <"," >? ,
294297 step : AstExpr ? ,
295- [ "do" ] : Token <"do" >,
298+ doKeyword : Token <"do" >,
296299 body : AstStatBlock ,
297- [ "end" ] : Token <"end" >,
300+ endKeyword : Token <"end" >,
298301}
299302
300303export type AstStatForIn = {
301304 tag : "forin" ,
302- [ "for" ] : Token <"for" >,
305+ forKeyword : Token <"for" >,
303306 variables : Punctuated <Token <string >>,
304- [ "in" ] : Token <"in" >,
307+ inKeyword : Token <"in" >,
305308 values : Punctuated <AstExpr >,
306- [ "do" ] : Token <"do" >,
309+ doKeyword : Token <"do" >,
307310 body : AstStatBlock ,
308- [ "end" ] : Token <"end" >,
311+ endKeyword : Token <"end" >,
309312}
310313
311314export type AstStatAssign = {
@@ -327,23 +330,23 @@ export type AstAttribute = Token<"@checked" | "@native" | "@deprecated"> & { tag
327330export type AstStatFunction = {
328331 tag : "function" ,
329332 attributes : { AstAttribute },
330- [ "function" ] : Token <"function" >,
333+ functionKeyword : Token <"function" >,
331334 name : AstExpr ,
332335 body : AstFunctionBody ,
333336}
334337
335338export type AstStatLocalFunction = {
336339 tag : "localfunction" ,
337340 attributes : { AstAttribute },
338- [ "local" ] : Token <"local" >,
339- [ "function" ] : Token <"function" >,
341+ localKeyword : Token <"local" >,
342+ functionKeyword : Token <"function" >,
340343 name : AstLocal ,
341344 body : AstFunctionBody ,
342345}
343346
344347export type AstStatTypeAlias = {
345348 tag : "typealias" ,
346- [ " export" ] : Token <"export" >? ,
349+ export : Token <"export" >? ,
347350 typeToken : Token <"type" >,
348351 name : Token ,
349352 openGenerics : Token <"<" >? ,
@@ -356,9 +359,9 @@ export type AstStatTypeAlias = {
356359
357360export type AstStatTypeFunction = {
358361 tag : "typefunction" ,
359- [ " export" ] : Token <"export" >? ,
362+ export : Token <"export" >? ,
360363 type : Token <"type" >,
361- [ "function" ] : Token <"function" >,
364+ functionKeyword : Token <"function" >,
362365 name : Token ,
363366 body : AstFunctionBody ,
364367}
@@ -421,7 +424,7 @@ export type AstTypeTypeof = {
421424 tag : "typeof" ,
422425 typeof : Token <"typeof" >,
423426 openParens : Token <"(" >,
424- expr : AstExpr ,
427+ expression : AstExpr ,
425428 closeParens : Token <")" >,
426429}
427430
0 commit comments