@magnusopera/fscript 0.77.1 → 0.78.1
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.
- package/dist/FScript.Language/Ast.js +2 -2
- package/dist/FScript.Language/BuiltinFunctions.js +68 -67
- package/dist/FScript.Language/BuiltinSignatures.js +7 -7
- package/dist/FScript.Language/BuiltinTypes.js +3 -3
- package/dist/FScript.Language/Error.js +2 -2
- package/dist/FScript.Language/Eval.js +305 -213
- package/dist/FScript.Language/IncludeResolver.js +97 -79
- package/dist/FScript.Language/Interactive.js +149 -0
- package/dist/FScript.Language/Lexer.js +77 -77
- package/dist/FScript.Language/Parser.js +274 -272
- package/dist/FScript.Language/Pretty.js +4 -4
- package/dist/FScript.Language/Span.js +2 -2
- package/dist/FScript.Language/Token.js +59 -2
- package/dist/FScript.Language/TypeInfer.js +452 -348
- package/dist/FScript.Language/Types.js +22 -10
- package/dist/FScript.Language/Value.js +3 -2
- package/dist/Library.js +91 -79
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Array.js +36 -35
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Async.js +52 -23
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/AsyncBuilder.js +23 -2
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/BigInt.js +33 -32
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/BitConverter.js +2 -2
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/CHANGELOG.md +80 -1
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Date.js +8 -15
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/DateOffset.js +8 -17
- package/dist/fable_modules/fable-library-js.5.13.0/Directory.js +11 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Double.js +8 -2
- package/dist/fable_modules/fable-library-js.5.13.0/Environment.js +3 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Event.js +10 -1
- package/dist/fable_modules/fable-library-js.5.13.0/File.js +27 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/List.js +35 -21
- package/dist/fable_modules/fable-library-js.5.13.0/Long.js +38 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MailboxProcessor.js +11 -5
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Map.js +8 -4
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MutableMap.js +2 -2
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MutableSet.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Observable.js +5 -3
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Option.js +1 -18
- package/dist/fable_modules/fable-library-js.5.13.0/Path.js +31 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Reflection.js +13 -3
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/RegExp.js +53 -24
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Seq.js +109 -22
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Set.js +16 -3
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/String.js +28 -1
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/System.js +15 -9
- package/dist/fable_modules/fable-library-js.5.13.0/Task.js +27 -0
- package/dist/fable_modules/fable-library-js.5.13.0/TaskBuilder.js +72 -0
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Types.js +12 -12
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Util.js +15 -3
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/package.json +1 -1
- package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/quotation.js +25 -8
- package/dist/fable_modules/project_cracked.json +1 -1
- package/package.json +1 -1
- package/dist/fable_modules/fable-library-js.5.2.0/Long.js +0 -47
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Boolean.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Char.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Choice.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/CollectionUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/ConditionalWeakTable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/DateOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Decimal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Encoding.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/FSharp.Collections.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/FSharp.Core.CompilerServices.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/FSharp.Core.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Global.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Guid.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Int32.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/MapUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Native.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Numeric.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/README.md +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Random.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Range.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Result.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Seq2.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/System.Collections.Generic.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/System.Text.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/TimeOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/TimeSpan.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Timer.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Unicode.13.0.0.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/Uri.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/big.d.ts +0 -0
- /package/dist/fable_modules/{fable-library-js.5.2.0 → fable-library-js.5.13.0}/lib/big.js +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
|
|
2
|
-
import { class_type } from "../fable_modules/fable-library-js.5.
|
|
3
|
-
import { singleton, tail as tail_1, head as head_1, isEmpty, foldBack, empty, length, item } from "../fable_modules/fable-library-js.5.
|
|
4
|
-
import { equals } from "../fable_modules/fable-library-js.5.
|
|
2
|
+
import { class_type } from "../fable_modules/fable-library-js.5.13.0/Reflection.js";
|
|
3
|
+
import { singleton, tail as tail_1, head as head_1, isEmpty, foldBack, empty, length, item } from "../fable_modules/fable-library-js.5.13.0/List.js";
|
|
4
|
+
import { equals } from "../fable_modules/fable-library-js.5.13.0/Util.js";
|
|
5
5
|
import { ParseException, ParseError } from "./Error.js";
|
|
6
6
|
import { TokenKind } from "./Token.js";
|
|
7
7
|
import { Span, SpanModule_merge } from "./Span.js";
|
|
8
|
-
import { isNullOrWhiteSpace, substring, concat, join, isNullOrEmpty } from "../fable_modules/fable-library-js.5.
|
|
9
|
-
import { isUpper } from "../fable_modules/fable-library-js.5.
|
|
8
|
+
import { isNullOrWhiteSpace, substring, concat, join, isNullOrEmpty } from "../fable_modules/fable-library-js.5.13.0/String.js";
|
|
9
|
+
import { isUpper } from "../fable_modules/fable-library-js.5.13.0/Char.js";
|
|
10
10
|
import { MapEntry, Ast_spanOfExpr, InterpolatedPart, Expr, Ast_spanOfPattern, Pattern, Stmt, TypeDef, Param, TypeRef, Literal } from "./Ast.js";
|
|
11
11
|
import { tokenizeWithSourceName } from "./Lexer.js";
|
|
12
|
-
import { addToSet } from "../fable_modules/fable-library-js.5.
|
|
13
|
-
import { foldBack as foldBack_1, toList } from "../fable_modules/fable-library-js.5.
|
|
14
|
-
import { StringBuilder__Append_244C7CD6, StringBuilder__Clear, StringBuilder__get_Length, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.
|
|
15
|
-
import { toString } from "../fable_modules/fable-library-js.5.
|
|
16
|
-
import { item as item_1 } from "../fable_modules/fable-library-js.5.
|
|
12
|
+
import { addToSet } from "../fable_modules/fable-library-js.5.13.0/MapUtil.js";
|
|
13
|
+
import { foldBack as foldBack_1, toList } from "../fable_modules/fable-library-js.5.13.0/Seq.js";
|
|
14
|
+
import { StringBuilder__Append_244C7CD6, StringBuilder__Clear, StringBuilder__get_Length, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.13.0/System.Text.js";
|
|
15
|
+
import { toString } from "../fable_modules/fable-library-js.5.13.0/Types.js";
|
|
16
|
+
import { item as item_1 } from "../fable_modules/fable-library-js.5.13.0/Array.js";
|
|
17
17
|
|
|
18
18
|
class TokenStream {
|
|
19
19
|
constructor(tokens) {
|
|
@@ -93,11 +93,11 @@ function TokenStream__ExpectIdent_Z721C83C5(_, message) {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
function TokenStream__get_AtEnd(_) {
|
|
96
|
-
return equals(item(_.index, _.tokens).Kind,
|
|
96
|
+
return equals(item(_.index, _.tokens).Kind, TokenKind.EOF);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
function TokenStream__SkipNewlines(_) {
|
|
100
|
-
while (equals(item(_.index, _.tokens).Kind,
|
|
100
|
+
while (equals(item(_.index, _.tokens).Kind, TokenKind.Newline)) {
|
|
101
101
|
_.index = ((_.index + 1) | 0);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -160,13 +160,13 @@ function parseLiteral(t) {
|
|
|
160
160
|
const matchValue = t.Kind;
|
|
161
161
|
switch (matchValue.tag) {
|
|
162
162
|
case 5:
|
|
163
|
-
return new Literal(0, [matchValue.fields[0]]);
|
|
163
|
+
return new Literal(/* LInt */ 0, [matchValue.fields[0]]);
|
|
164
164
|
case 6:
|
|
165
|
-
return new Literal(1, [matchValue.fields[0]]);
|
|
165
|
+
return new Literal(/* LFloat */ 1, [matchValue.fields[0]]);
|
|
166
166
|
case 7:
|
|
167
|
-
return new Literal(3, [matchValue.fields[0]]);
|
|
167
|
+
return new Literal(/* LString */ 3, [matchValue.fields[0]]);
|
|
168
168
|
case 9:
|
|
169
|
-
return new Literal(2, [matchValue.fields[0]]);
|
|
169
|
+
return new Literal(/* LBool */ 2, [matchValue.fields[0]]);
|
|
170
170
|
default:
|
|
171
171
|
throw new ParseException(new ParseError("Expected literal", t.Span));
|
|
172
172
|
}
|
|
@@ -180,15 +180,15 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
180
180
|
let progress = true;
|
|
181
181
|
while (progress) {
|
|
182
182
|
progress = false;
|
|
183
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
183
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
184
184
|
consumed = true;
|
|
185
185
|
progress = true;
|
|
186
186
|
}
|
|
187
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
187
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Indent)) {
|
|
188
188
|
consumed = true;
|
|
189
189
|
progress = true;
|
|
190
190
|
}
|
|
191
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
191
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
|
|
192
192
|
consumed = true;
|
|
193
193
|
progress = true;
|
|
194
194
|
}
|
|
@@ -250,8 +250,8 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
250
250
|
const matchValue_5 = TokenStream__Peek(stream).Kind;
|
|
251
251
|
switch (matchValue_5.tag) {
|
|
252
252
|
case 4:
|
|
253
|
-
return new TypeRef(0, [(firstName = ((matchValue_3 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected type name").Kind, (matchValue_3.tag === 4) ? matchValue_3.fields[0] : "")), (parts_1 = [], (void (parts_1.push(firstName)), (keepGoing = true, ((() => {
|
|
254
|
-
while (keepGoing && TokenStream__Match_5CEB78CD(stream,
|
|
253
|
+
return new TypeRef(/* TRName */ 0, [(firstName = ((matchValue_3 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected type name").Kind, (matchValue_3.tag === 4) ? matchValue_3.fields[0] : "")), (parts_1 = [], (void (parts_1.push(firstName)), (keepGoing = true, ((() => {
|
|
254
|
+
while (keepGoing && TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
|
|
255
255
|
const matchValue_4 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'.\' in qualified type name").Kind;
|
|
256
256
|
if (matchValue_4.tag === 4) {
|
|
257
257
|
void (parts_1.push(matchValue_4.fields[0]));
|
|
@@ -261,7 +261,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
261
261
|
})(), join(".", parts_1))))))]);
|
|
262
262
|
case 43: {
|
|
263
263
|
TokenStream__Next(stream);
|
|
264
|
-
const isStructural = TokenStream__Match_5CEB78CD(stream,
|
|
264
|
+
const isStructural = TokenStream__Match_5CEB78CD(stream, TokenKind.Bar);
|
|
265
265
|
const fields = [];
|
|
266
266
|
const seen = new Set([]);
|
|
267
267
|
const parseField = () => {
|
|
@@ -272,45 +272,45 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
272
272
|
if (!addToSet(fieldName, seen)) {
|
|
273
273
|
throw new ParseException(new ParseError(concat("Duplicate field \'", fieldName, "\' in inline record type"), nameTok.Span));
|
|
274
274
|
}
|
|
275
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
275
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' after inline record type field name");
|
|
276
276
|
const fieldType = parseTypeRef();
|
|
277
277
|
void (fields.push([fieldName, fieldType]));
|
|
278
278
|
};
|
|
279
|
-
if ((isStructural && equals(TokenStream__Peek(stream).Kind,
|
|
279
|
+
if ((isStructural && equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) ? true : (!isStructural && equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace))) {
|
|
280
280
|
throw new ParseException(new ParseError("Inline record type must define at least one field", TokenStream__Peek(stream).Span));
|
|
281
281
|
}
|
|
282
282
|
parseField();
|
|
283
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
284
|
-
if ((isStructural && !equals(TokenStream__Peek(stream).Kind,
|
|
283
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon)) {
|
|
284
|
+
if ((isStructural && !equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) ? true : (!isStructural && !equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace))) {
|
|
285
285
|
parseField();
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
if (isStructural) {
|
|
289
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
289
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Bar, "Expected \'|\' in structural record type");
|
|
290
290
|
}
|
|
291
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
291
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in inline record type");
|
|
292
292
|
if (isStructural) {
|
|
293
|
-
return new TypeRef(5, [toList(fields)]);
|
|
293
|
+
return new TypeRef(/* TRStructuralRecord */ 5, [toList(fields)]);
|
|
294
294
|
}
|
|
295
295
|
else {
|
|
296
|
-
return new TypeRef(4, [toList(fields)]);
|
|
296
|
+
return new TypeRef(/* TRRecord */ 4, [toList(fields)]);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
case 27: {
|
|
300
300
|
TokenStream__Next(stream);
|
|
301
301
|
const first_1 = parseTypeRef();
|
|
302
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
302
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Star)) {
|
|
303
303
|
const items = [];
|
|
304
304
|
void (items.push(first_1));
|
|
305
305
|
void (items.push(parseTypeRef()));
|
|
306
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
306
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Star)) {
|
|
307
307
|
void (items.push(parseTypeRef()));
|
|
308
308
|
}
|
|
309
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
310
|
-
return new TypeRef(1, [toList(items)]);
|
|
309
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' in tuple type");
|
|
310
|
+
return new TypeRef(/* TRTuple */ 1, [toList(items)]);
|
|
311
311
|
}
|
|
312
312
|
else {
|
|
313
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
313
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' in type expression");
|
|
314
314
|
return first_1;
|
|
315
315
|
}
|
|
316
316
|
}
|
|
@@ -352,22 +352,22 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
352
352
|
switch (matchResult) {
|
|
353
353
|
case 0: {
|
|
354
354
|
TokenStream__Next(stream);
|
|
355
|
-
t = (new TypeRef(3, [t, "list"]));
|
|
355
|
+
t = (new TypeRef(/* TRPostfix */ 3, [t, "list"]));
|
|
356
356
|
break;
|
|
357
357
|
}
|
|
358
358
|
case 1: {
|
|
359
359
|
TokenStream__Next(stream);
|
|
360
|
-
t = (new TypeRef(3, [t, "option"]));
|
|
360
|
+
t = (new TypeRef(/* TRPostfix */ 3, [t, "option"]));
|
|
361
361
|
break;
|
|
362
362
|
}
|
|
363
363
|
case 2: {
|
|
364
364
|
TokenStream__Next(stream);
|
|
365
|
-
t = (new TypeRef(3, [t, "map"]));
|
|
365
|
+
t = (new TypeRef(/* TRPostfix */ 3, [t, "map"]));
|
|
366
366
|
break;
|
|
367
367
|
}
|
|
368
368
|
case 3: {
|
|
369
369
|
TokenStream__Next(stream);
|
|
370
|
-
t = (new TypeRef(3, [t, "task"]));
|
|
370
|
+
t = (new TypeRef(/* TRPostfix */ 3, [t, "task"]));
|
|
371
371
|
break;
|
|
372
372
|
}
|
|
373
373
|
case 4: {
|
|
@@ -380,8 +380,8 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
380
380
|
};
|
|
381
381
|
const parseTypeRef = () => {
|
|
382
382
|
const left = parseTypeRefPostfix();
|
|
383
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
384
|
-
return new TypeRef(2, [left, parseTypeRef()]);
|
|
383
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Arrow)) {
|
|
384
|
+
return new TypeRef(/* TRFun */ 2, [left, parseTypeRef()]);
|
|
385
385
|
}
|
|
386
386
|
else {
|
|
387
387
|
return left;
|
|
@@ -396,16 +396,16 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
396
396
|
case 27: {
|
|
397
397
|
const lp = TokenStream__Next(stream);
|
|
398
398
|
TokenStream__SkipNewlines(stream);
|
|
399
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
400
|
-
return new Param("()", new TypeRef(0, ["unit"]), mkSpanFrom(lp.Span, TokenStream__TokenAt_Z524259A4(stream, TokenStream__get_Index(stream) - 1).Span));
|
|
399
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.RParen)) {
|
|
400
|
+
return new Param("()", new TypeRef(/* TRName */ 0, ["unit"]), mkSpanFrom(lp.Span, TokenStream__TokenAt_Z524259A4(stream, TokenStream__get_Index(stream) - 1).Span));
|
|
401
401
|
}
|
|
402
402
|
else {
|
|
403
403
|
let name;
|
|
404
404
|
const matchValue_9 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected parameter name in annotated parameter").Kind;
|
|
405
405
|
name = ((matchValue_9.tag === 4) ? matchValue_9.fields[0] : "");
|
|
406
406
|
TokenStream__SkipNewlines(stream);
|
|
407
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
408
|
-
return new Param(name, parseTypeRef(), mkSpanFrom(lp.Span, TokenStream__Expect_77B9EE56(stream,
|
|
407
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' in annotated parameter");
|
|
408
|
+
return new Param(name, parseTypeRef(), mkSpanFrom(lp.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after annotated parameter").Span));
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
default:
|
|
@@ -418,12 +418,12 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
418
418
|
let firstParamColumn = undefined;
|
|
419
419
|
while (!argsDone) {
|
|
420
420
|
let sawNewline = false;
|
|
421
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
421
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
422
422
|
sawNewline = true;
|
|
423
423
|
}
|
|
424
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
424
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Indent)) {
|
|
425
425
|
}
|
|
426
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
426
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
|
|
427
427
|
}
|
|
428
428
|
const matchValue_10 = TokenStream__Peek(stream).Kind;
|
|
429
429
|
switch (matchValue_10.tag) {
|
|
@@ -449,18 +449,18 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
449
449
|
return args;
|
|
450
450
|
};
|
|
451
451
|
const parseTypeDecl = () => {
|
|
452
|
-
const typeTok = TokenStream__Expect_77B9EE56(stream,
|
|
453
|
-
const isRec = TokenStream__Match_5CEB78CD(stream,
|
|
452
|
+
const typeTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Type, "Expected \'type\'");
|
|
453
|
+
const isRec = TokenStream__Match_5CEB78CD(stream, TokenKind.Rec);
|
|
454
454
|
let name_1;
|
|
455
455
|
const matchValue_11 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'type\'").Kind;
|
|
456
456
|
name_1 = ((matchValue_11.tag === 4) ? matchValue_11.fields[0] : "");
|
|
457
457
|
TokenStream__SkipNewlines(stream);
|
|
458
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
458
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in type declaration");
|
|
459
459
|
let hasOuterIndent = false;
|
|
460
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
461
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
460
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
461
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
462
462
|
}
|
|
463
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
463
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Indent)) {
|
|
464
464
|
hasOuterIndent = true;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
@@ -469,7 +469,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
469
469
|
switch (matchValue_15.tag) {
|
|
470
470
|
case 43: {
|
|
471
471
|
const lbIndex = TokenStream__get_Index(stream) | 0;
|
|
472
|
-
const lb = TokenStream__Expect_77B9EE56(stream,
|
|
472
|
+
const lb = TokenStream__Expect_77B9EE56(stream, TokenKind.LBrace, "Expected \'{\' in record type declaration");
|
|
473
473
|
if (!hasNonLayoutTokenAfterOnSameLine(lbIndex, lb.Span.Start.Line)) {
|
|
474
474
|
throw new ParseException(new ParseError("Opening \'{\' cannot be on its own line; keep it with the first field", lb.Span));
|
|
475
475
|
}
|
|
@@ -481,7 +481,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
481
481
|
const matchValue_12 = fieldTok.Kind;
|
|
482
482
|
fieldName_1 = ((matchValue_12.tag === 4) ? matchValue_12.fields[0] : "");
|
|
483
483
|
TokenStream__SkipNewlines(stream);
|
|
484
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
484
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' after field name");
|
|
485
485
|
const fieldType_1 = parseTypeRef();
|
|
486
486
|
void (fields_1.push([fieldName_1, fieldType_1]));
|
|
487
487
|
return fieldTok.Span.Start.Column | 0;
|
|
@@ -489,8 +489,8 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
489
489
|
const firstFieldColumn = parseField_1() | 0;
|
|
490
490
|
let doneFields = false;
|
|
491
491
|
while (!doneFields) {
|
|
492
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
493
|
-
if (!equals(TokenStream__Peek(stream).Kind,
|
|
492
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon)) {
|
|
493
|
+
if (!equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace)) {
|
|
494
494
|
parseField_1();
|
|
495
495
|
}
|
|
496
496
|
else {
|
|
@@ -499,12 +499,12 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
499
499
|
}
|
|
500
500
|
else {
|
|
501
501
|
let sawNewline_1 = false;
|
|
502
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
502
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
503
503
|
sawNewline_1 = true;
|
|
504
504
|
}
|
|
505
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
505
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Indent)) {
|
|
506
506
|
}
|
|
507
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
507
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
|
|
508
508
|
}
|
|
509
509
|
if (sawNewline_1) {
|
|
510
510
|
const matchValue_13 = TokenStream__Peek(stream).Kind;
|
|
@@ -529,7 +529,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
529
529
|
}
|
|
530
530
|
}
|
|
531
531
|
const rbIndex = TokenStream__get_Index(stream) | 0;
|
|
532
|
-
const rb = TokenStream__Expect_77B9EE56(stream,
|
|
532
|
+
const rb = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in record type declaration");
|
|
533
533
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex, rb.Span.Start.Line)) {
|
|
534
534
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last field", rb.Span));
|
|
535
535
|
}
|
|
@@ -541,7 +541,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
541
541
|
const cases = [];
|
|
542
542
|
const parseCase = () => {
|
|
543
543
|
TokenStream__SkipNewlines(stream);
|
|
544
|
-
TokenStream__Match_5CEB78CD(stream,
|
|
544
|
+
TokenStream__Match_5CEB78CD(stream, TokenKind.Bar);
|
|
545
545
|
const caseTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected union case name");
|
|
546
546
|
let caseName;
|
|
547
547
|
const matchValue_14 = caseTok.Kind;
|
|
@@ -550,7 +550,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
550
550
|
throw new ParseException(new ParseError("Union case name must start with uppercase letter", caseTok.Span));
|
|
551
551
|
}
|
|
552
552
|
TokenStream__SkipNewlines(stream);
|
|
553
|
-
const payload = TokenStream__Match_5CEB78CD(stream,
|
|
553
|
+
const payload = TokenStream__Match_5CEB78CD(stream, TokenKind.Of) ? parseTypeRef() : undefined;
|
|
554
554
|
void (cases.push([caseName, payload]));
|
|
555
555
|
return caseTok.Span;
|
|
556
556
|
};
|
|
@@ -558,12 +558,12 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
558
558
|
let doneCases = false;
|
|
559
559
|
while (!doneCases) {
|
|
560
560
|
let sawNewline_2 = false;
|
|
561
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
561
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
562
562
|
sawNewline_2 = true;
|
|
563
563
|
}
|
|
564
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
564
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Indent)) {
|
|
565
565
|
}
|
|
566
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
566
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) {
|
|
567
567
|
const s_1 = parseCase();
|
|
568
568
|
lastSpan = s_1.End;
|
|
569
569
|
}
|
|
@@ -582,13 +582,13 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
582
582
|
}
|
|
583
583
|
if (hasOuterIndent) {
|
|
584
584
|
TokenStream__SkipNewlines(stream);
|
|
585
|
-
if (!TokenStream__Match_5CEB78CD(stream,
|
|
585
|
+
if (!TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
|
|
586
586
|
throw new ParseException(new ParseError("Expected dedent after type declaration", TokenStream__Peek(stream).Span));
|
|
587
587
|
}
|
|
588
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
588
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
|
|
589
589
|
}
|
|
590
590
|
}
|
|
591
|
-
return new Stmt(0, [new TypeDef(name_1, isRec, patternInput_1[0], patternInput_1[1], mkSpanFrom(typeTok.Span, patternInput_1[2]))]);
|
|
591
|
+
return new Stmt(/* SType */ 0, [new TypeDef(name_1, isRec, patternInput_1[0], patternInput_1[1], mkSpanFrom(typeTok.Span, patternInput_1[2]))]);
|
|
592
592
|
};
|
|
593
593
|
const parsePattern = () => {
|
|
594
594
|
TokenStream__SkipNewlines(stream);
|
|
@@ -631,10 +631,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
631
631
|
}
|
|
632
632
|
switch (matchResult_1) {
|
|
633
633
|
case 0:
|
|
634
|
-
return new Pattern(0, [TokenStream__Next(stream).Span]);
|
|
634
|
+
return new Pattern(/* PWildcard */ 0, [TokenStream__Next(stream).Span]);
|
|
635
635
|
case 1: {
|
|
636
636
|
const t_3 = TokenStream__Next(stream);
|
|
637
|
-
if (isUpperIdent(name_4) && TokenStream__Match_5CEB78CD(stream,
|
|
637
|
+
if (isUpperIdent(name_4) && TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
|
|
638
638
|
const caseTok_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected union case name after \'.\'");
|
|
639
639
|
let caseName_1;
|
|
640
640
|
const matchValue_17 = caseTok_1.Kind;
|
|
@@ -644,39 +644,39 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
644
644
|
}
|
|
645
645
|
if (isStartPatternAtom(TokenStream__Peek(stream).Kind)) {
|
|
646
646
|
const p = parsePattern();
|
|
647
|
-
return new Pattern(10, [name_4, caseName_1, p, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p))]);
|
|
647
|
+
return new Pattern(/* PUnionCase */ 10, [name_4, caseName_1, p, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p))]);
|
|
648
648
|
}
|
|
649
649
|
else {
|
|
650
|
-
return new Pattern(10, [name_4, caseName_1, undefined, mkSpanFrom(t_3.Span, caseTok_1.Span)]);
|
|
650
|
+
return new Pattern(/* PUnionCase */ 10, [name_4, caseName_1, undefined, mkSpanFrom(t_3.Span, caseTok_1.Span)]);
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
else {
|
|
654
654
|
switch (name_4) {
|
|
655
655
|
case "None":
|
|
656
|
-
return new Pattern(9, [t_3.Span]);
|
|
656
|
+
return new Pattern(/* PNone */ 9, [t_3.Span]);
|
|
657
657
|
case "Some": {
|
|
658
658
|
const p_1 = parsePattern();
|
|
659
|
-
return new Pattern(8, [p_1, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p_1))]);
|
|
659
|
+
return new Pattern(/* PSome */ 8, [p_1, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p_1))]);
|
|
660
660
|
}
|
|
661
661
|
default:
|
|
662
662
|
if (isUpperIdent(name_4)) {
|
|
663
663
|
if (isStartPatternAtom(TokenStream__Peek(stream).Kind)) {
|
|
664
664
|
const p_2 = parsePattern();
|
|
665
|
-
return new Pattern(10, [undefined, name_4, p_2, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p_2))]);
|
|
665
|
+
return new Pattern(/* PUnionCase */ 10, [undefined, name_4, p_2, mkSpanFrom(t_3.Span, Ast_spanOfPattern(p_2))]);
|
|
666
666
|
}
|
|
667
667
|
else {
|
|
668
|
-
return new Pattern(10, [undefined, name_4, undefined, t_3.Span]);
|
|
668
|
+
return new Pattern(/* PUnionCase */ 10, [undefined, name_4, undefined, t_3.Span]);
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
671
|
else {
|
|
672
|
-
return new Pattern(1, [name_4, t_3.Span]);
|
|
672
|
+
return new Pattern(/* PVar */ 1, [name_4, t_3.Span]);
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
677
|
case 2: {
|
|
678
678
|
const t_4 = TokenStream__Next(stream);
|
|
679
|
-
return new Pattern(2, [parseLiteral(t_4), t_4.Span]);
|
|
679
|
+
return new Pattern(/* PLiteral */ 2, [parseLiteral(t_4), t_4.Span]);
|
|
680
680
|
}
|
|
681
681
|
case 3: {
|
|
682
682
|
const lbIndex_1 = TokenStream__get_Index(stream) | 0;
|
|
@@ -684,41 +684,41 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
684
684
|
if (!hasNonLayoutTokenAfterOnSameLine(lbIndex_1, lb_1.Span.Start.Line)) {
|
|
685
685
|
throw new ParseException(new ParseError("Opening \'[\' cannot be on its own line; keep it with the first element", lb_1.Span));
|
|
686
686
|
}
|
|
687
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
688
|
-
return new Pattern(3, [mkSpanFrom(lb_1.Span, lb_1.Span)]);
|
|
687
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.RBracket)) {
|
|
688
|
+
return new Pattern(/* PNil */ 3, [mkSpanFrom(lb_1.Span, lb_1.Span)]);
|
|
689
689
|
}
|
|
690
690
|
else {
|
|
691
691
|
const first_2 = parsePatternCons();
|
|
692
692
|
const elements = [];
|
|
693
693
|
void (elements.push(first_2));
|
|
694
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
695
|
-
if (!equals(TokenStream__Peek(stream).Kind,
|
|
694
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon)) {
|
|
695
|
+
if (!equals(TokenStream__Peek(stream).Kind, TokenKind.RBracket)) {
|
|
696
696
|
void (elements.push(parsePatternCons()));
|
|
697
697
|
}
|
|
698
698
|
}
|
|
699
699
|
const rbIndex_1 = TokenStream__get_Index(stream) | 0;
|
|
700
|
-
const rb_1 = TokenStream__Expect_77B9EE56(stream,
|
|
700
|
+
const rb_1 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' in list pattern");
|
|
701
701
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_1, rb_1.Span.Start.Line)) {
|
|
702
702
|
throw new ParseException(new ParseError("Closing \']\' cannot be on its own line; keep it with the last element", rb_1.Span));
|
|
703
703
|
}
|
|
704
|
-
return foldBack((head, tail) => (new Pattern(4, [head, tail, mkSpanFrom(Ast_spanOfPattern(head), Ast_spanOfPattern(tail))])), toList(elements), new Pattern(3, [mkSpanFrom(rb_1.Span, rb_1.Span)]));
|
|
704
|
+
return foldBack((head, tail) => (new Pattern(/* PCons */ 4, [head, tail, mkSpanFrom(Ast_spanOfPattern(head), Ast_spanOfPattern(tail))])), toList(elements), new Pattern(/* PNil */ 3, [mkSpanFrom(rb_1.Span, rb_1.Span)]));
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
707
|
case 4: {
|
|
708
708
|
const lp_1 = TokenStream__Next(stream);
|
|
709
709
|
const first_3 = parsePatternCons();
|
|
710
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
710
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Comma)) {
|
|
711
711
|
const elements_1 = [];
|
|
712
712
|
void (elements_1.push(first_3));
|
|
713
713
|
void (elements_1.push(parsePatternCons()));
|
|
714
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
714
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Comma)) {
|
|
715
715
|
void (elements_1.push(parsePatternCons()));
|
|
716
716
|
}
|
|
717
|
-
const rp_2 = TokenStream__Expect_77B9EE56(stream,
|
|
718
|
-
return new Pattern(5, [toList(elements_1), mkSpanFrom(lp_1.Span, rp_2.Span)]);
|
|
717
|
+
const rp_2 = TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after tuple pattern");
|
|
718
|
+
return new Pattern(/* PTuple */ 5, [toList(elements_1), mkSpanFrom(lp_1.Span, rp_2.Span)]);
|
|
719
719
|
}
|
|
720
720
|
else {
|
|
721
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
721
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after parenthesized pattern");
|
|
722
722
|
return first_3;
|
|
723
723
|
}
|
|
724
724
|
}
|
|
@@ -729,10 +729,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
729
729
|
throw new ParseException(new ParseError("Opening \'{\' cannot be on its own line; keep it with the first entry", lb_2.Span));
|
|
730
730
|
}
|
|
731
731
|
TokenStream__SkipNewlines(stream);
|
|
732
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
733
|
-
return new Pattern(7, [empty(), undefined, mkSpanFrom(lb_2.Span, lb_2.Span)]);
|
|
732
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.RBrace)) {
|
|
733
|
+
return new Pattern(/* PMap */ 7, [empty(), undefined, mkSpanFrom(lb_2.Span, lb_2.Span)]);
|
|
734
734
|
}
|
|
735
|
-
else if (equals(TokenStream__Peek(stream).Kind,
|
|
735
|
+
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) {
|
|
736
736
|
TokenStream__Next(stream);
|
|
737
737
|
const fields_3 = [];
|
|
738
738
|
const seen_1 = new Set([]);
|
|
@@ -744,32 +744,32 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
744
744
|
if (!addToSet(fieldName_2, seen_1)) {
|
|
745
745
|
throw new ParseException(new ParseError(concat("Duplicate field \'", fieldName_2, "\' in structural record type pattern"), nameTok_3.Span));
|
|
746
746
|
}
|
|
747
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
747
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' in structural record type pattern");
|
|
748
748
|
const fieldType_2 = parseTypeRef();
|
|
749
749
|
void (fields_3.push([fieldName_2, fieldType_2]));
|
|
750
750
|
};
|
|
751
751
|
parseTypeField();
|
|
752
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
753
|
-
if (!equals(TokenStream__Peek(stream).Kind,
|
|
752
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon)) {
|
|
753
|
+
if (!equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) {
|
|
754
754
|
parseTypeField();
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
757
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Bar, "Expected \'|\' in structural record type pattern");
|
|
758
758
|
const rbIndex_2 = TokenStream__get_Index(stream) | 0;
|
|
759
|
-
const rb_2 = TokenStream__Expect_77B9EE56(stream,
|
|
759
|
+
const rb_2 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in structural record type pattern");
|
|
760
760
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_2, rb_2.Span.Start.Line)) {
|
|
761
761
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_2.Span));
|
|
762
762
|
}
|
|
763
|
-
return new Pattern(11, [new TypeRef(5, [toList(fields_3)]), mkSpanFrom(lb_2.Span, rb_2.Span)]);
|
|
763
|
+
return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRStructuralRecord */ 5, [toList(fields_3)]), mkSpanFrom(lb_2.Span, rb_2.Span)]);
|
|
764
764
|
}
|
|
765
|
-
else if (equals(TokenStream__Peek(stream).Kind,
|
|
765
|
+
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket)) {
|
|
766
766
|
const clauses = [];
|
|
767
767
|
const parseClause = () => {
|
|
768
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
768
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.LBracket, "Expected \'[\' in map pattern key");
|
|
769
769
|
const keyPattern = parsePatternCons();
|
|
770
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
770
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' in map pattern key");
|
|
771
771
|
TokenStream__SkipNewlines(stream);
|
|
772
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
772
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' after map key pattern");
|
|
773
773
|
const valuePattern = parsePatternCons();
|
|
774
774
|
void (clauses.push([keyPattern, valuePattern]));
|
|
775
775
|
};
|
|
@@ -778,32 +778,32 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
778
778
|
let tailPattern = undefined;
|
|
779
779
|
let donePattern = false;
|
|
780
780
|
while (!donePattern) {
|
|
781
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
781
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon)) {
|
|
782
782
|
TokenStream__SkipNewlines(stream);
|
|
783
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
783
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.RangeDots)) {
|
|
784
784
|
TokenStream__Next(stream);
|
|
785
785
|
tailPattern = parsePatternCons();
|
|
786
786
|
TokenStream__SkipNewlines(stream);
|
|
787
787
|
donePattern = true;
|
|
788
788
|
}
|
|
789
|
-
else if (equals(TokenStream__Peek(stream).Kind,
|
|
789
|
+
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket)) {
|
|
790
790
|
parseClause();
|
|
791
791
|
TokenStream__SkipNewlines(stream);
|
|
792
792
|
}
|
|
793
|
-
else if (equals(TokenStream__Peek(stream).Kind,
|
|
793
|
+
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace)) {
|
|
794
794
|
donePattern = true;
|
|
795
795
|
}
|
|
796
796
|
else {
|
|
797
797
|
throw new ParseException(new ParseError("Expected map pattern clause or \'..tail\'", TokenStream__Peek(stream).Span));
|
|
798
798
|
}
|
|
799
799
|
}
|
|
800
|
-
else if (equals(TokenStream__Peek(stream).Kind,
|
|
800
|
+
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.RangeDots)) {
|
|
801
801
|
TokenStream__Next(stream);
|
|
802
802
|
tailPattern = parsePatternCons();
|
|
803
803
|
TokenStream__SkipNewlines(stream);
|
|
804
804
|
donePattern = true;
|
|
805
805
|
}
|
|
806
|
-
else if (equals(TokenStream__Peek(stream).Kind,
|
|
806
|
+
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket)) {
|
|
807
807
|
parseClause();
|
|
808
808
|
TokenStream__SkipNewlines(stream);
|
|
809
809
|
}
|
|
@@ -812,11 +812,11 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
814
|
const rbIndex_3 = TokenStream__get_Index(stream) | 0;
|
|
815
|
-
const rb_3 = TokenStream__Expect_77B9EE56(stream,
|
|
815
|
+
const rb_3 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in map pattern");
|
|
816
816
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_3, rb_3.Span.Start.Line)) {
|
|
817
817
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_3.Span));
|
|
818
818
|
}
|
|
819
|
-
return new Pattern(7, [toList(clauses), tailPattern, mkSpanFrom(lb_2.Span, rb_3.Span)]);
|
|
819
|
+
return new Pattern(/* PMap */ 7, [toList(clauses), tailPattern, mkSpanFrom(lb_2.Span, rb_3.Span)]);
|
|
820
820
|
}
|
|
821
821
|
else {
|
|
822
822
|
const mark = TokenStream__Mark(stream) | 0;
|
|
@@ -824,7 +824,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
824
824
|
try {
|
|
825
825
|
TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record type pattern");
|
|
826
826
|
TokenStream__SkipNewlines(stream);
|
|
827
|
-
isTypeRefPattern = TokenStream__Match_5CEB78CD(stream,
|
|
827
|
+
isTypeRefPattern = TokenStream__Match_5CEB78CD(stream, TokenKind.Colon);
|
|
828
828
|
}
|
|
829
829
|
catch (matchValue_19) {
|
|
830
830
|
isTypeRefPattern = false;
|
|
@@ -843,22 +843,22 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
843
843
|
throw new ParseException(new ParseError(concat("Duplicate field \'", name_5, "\' in record type pattern"), nameTok_4.Span));
|
|
844
844
|
}
|
|
845
845
|
TokenStream__SkipNewlines(stream);
|
|
846
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
846
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Colon, "Expected \':\' in record type pattern field");
|
|
847
847
|
const t_5 = parseTypeRef();
|
|
848
848
|
void (fields_4.push([name_5, t_5]));
|
|
849
849
|
};
|
|
850
850
|
parseTypeField_1();
|
|
851
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
852
|
-
if (!equals(TokenStream__Peek(stream).Kind,
|
|
851
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon)) {
|
|
852
|
+
if (!equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace)) {
|
|
853
853
|
parseTypeField_1();
|
|
854
854
|
}
|
|
855
855
|
}
|
|
856
856
|
const rbIndex_4 = TokenStream__get_Index(stream) | 0;
|
|
857
|
-
const rb_4 = TokenStream__Expect_77B9EE56(stream,
|
|
857
|
+
const rb_4 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in record type pattern");
|
|
858
858
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_4, rb_4.Span.Start.Line)) {
|
|
859
859
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last field", rb_4.Span));
|
|
860
860
|
}
|
|
861
|
-
return new Pattern(11, [new TypeRef(4, [toList(fields_4)]), mkSpanFrom(lb_2.Span, rb_4.Span)]);
|
|
861
|
+
return new Pattern(/* PTypeRef */ 11, [new TypeRef(/* TRRecord */ 4, [toList(fields_4)]), mkSpanFrom(lb_2.Span, rb_4.Span)]);
|
|
862
862
|
}
|
|
863
863
|
else {
|
|
864
864
|
const fields_5 = [];
|
|
@@ -873,22 +873,22 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
873
873
|
throw new ParseException(new ParseError(concat("Duplicate field \'", name_6, "\' in record pattern"), nameTok_5.Span));
|
|
874
874
|
}
|
|
875
875
|
TokenStream__SkipNewlines(stream);
|
|
876
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
876
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record pattern field");
|
|
877
877
|
const p_3 = parsePatternCons();
|
|
878
878
|
void (fields_5.push([name_6, p_3]));
|
|
879
879
|
};
|
|
880
880
|
parseField_2();
|
|
881
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
882
|
-
if (!equals(TokenStream__Peek(stream).Kind,
|
|
881
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon)) {
|
|
882
|
+
if (!equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace)) {
|
|
883
883
|
parseField_2();
|
|
884
884
|
}
|
|
885
885
|
}
|
|
886
886
|
const rbIndex_5 = TokenStream__get_Index(stream) | 0;
|
|
887
|
-
const rb_5 = TokenStream__Expect_77B9EE56(stream,
|
|
887
|
+
const rb_5 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in record pattern");
|
|
888
888
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_5, rb_5.Span.Start.Line)) {
|
|
889
889
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last field", rb_5.Span));
|
|
890
890
|
}
|
|
891
|
-
return new Pattern(6, [toList(fields_5), mkSpanFrom(lb_2.Span, rb_5.Span)]);
|
|
891
|
+
return new Pattern(/* PRecord */ 6, [toList(fields_5), mkSpanFrom(lb_2.Span, rb_5.Span)]);
|
|
892
892
|
}
|
|
893
893
|
}
|
|
894
894
|
}
|
|
@@ -898,9 +898,9 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
898
898
|
};
|
|
899
899
|
const parsePatternCons = () => {
|
|
900
900
|
const left_1 = parsePattern();
|
|
901
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
901
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Cons)) {
|
|
902
902
|
const right_1 = parsePatternCons();
|
|
903
|
-
return new Pattern(4, [left_1, right_1, mkSpanFrom(Ast_spanOfPattern(left_1), Ast_spanOfPattern(right_1))]);
|
|
903
|
+
return new Pattern(/* PCons */ 4, [left_1, right_1, mkSpanFrom(Ast_spanOfPattern(left_1), Ast_spanOfPattern(right_1))]);
|
|
904
904
|
}
|
|
905
905
|
else {
|
|
906
906
|
return left_1;
|
|
@@ -915,10 +915,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
915
915
|
let progress_1 = true;
|
|
916
916
|
while (progress_1) {
|
|
917
917
|
progress_1 = false;
|
|
918
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
918
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
919
919
|
progress_1 = true;
|
|
920
920
|
}
|
|
921
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
921
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Indent)) {
|
|
922
922
|
progress_1 = true;
|
|
923
923
|
}
|
|
924
924
|
}
|
|
@@ -940,7 +940,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
940
940
|
case 7:
|
|
941
941
|
case 9: {
|
|
942
942
|
const t_7 = TokenStream__Next(stream);
|
|
943
|
-
return new Expr(1, [parseLiteral(t_7), t_7.Span]);
|
|
943
|
+
return new Expr(/* ELiteral */ 1, [parseLiteral(t_7), t_7.Span]);
|
|
944
944
|
}
|
|
945
945
|
case 8: {
|
|
946
946
|
const raw = matchValue_22.fields[0];
|
|
@@ -949,7 +949,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
949
949
|
const text = StringBuilder_$ctor();
|
|
950
950
|
const flushText = () => {
|
|
951
951
|
if (StringBuilder__get_Length(text) > 0) {
|
|
952
|
-
void (parts.push(new InterpolatedPart(0, [toString(text)])));
|
|
952
|
+
void (parts.push(new InterpolatedPart(/* IPText */ 0, [toString(text)])));
|
|
953
953
|
StringBuilder__Clear(text);
|
|
954
954
|
}
|
|
955
955
|
};
|
|
@@ -1072,7 +1072,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1072
1072
|
})()) : (() => {
|
|
1073
1073
|
throw new ParseException(new ParseError("Interpolation placeholders must contain a single expression", TokenStream__Peek(stream).Span));
|
|
1074
1074
|
})()), i];
|
|
1075
|
-
void (parts.push(new InterpolatedPart(1, [patternInput[0]])));
|
|
1075
|
+
void (parts.push(new InterpolatedPart(/* IPExpr */ 1, [patternInput[0]])));
|
|
1076
1076
|
i_1 = (patternInput[1] | 0);
|
|
1077
1077
|
break;
|
|
1078
1078
|
}
|
|
@@ -1113,41 +1113,41 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
1115
|
flushText();
|
|
1116
|
-
return new Expr(30, [(parts.length === 0) ? singleton(new InterpolatedPart(0, [""])) : toList(parts), span]);
|
|
1116
|
+
return new Expr(/* EInterpolatedString */ 30, [(parts.length === 0) ? singleton(new InterpolatedPart(/* IPText */ 0, [""])) : toList(parts), span]);
|
|
1117
1117
|
}
|
|
1118
1118
|
case 4: {
|
|
1119
1119
|
const name_7 = matchValue_22.fields[0];
|
|
1120
1120
|
const t_9 = TokenStream__Next(stream);
|
|
1121
1121
|
switch (name_7) {
|
|
1122
1122
|
case "None":
|
|
1123
|
-
return new Expr(27, [t_9.Span]);
|
|
1123
|
+
return new Expr(/* ENone */ 27, [t_9.Span]);
|
|
1124
1124
|
case "Some": {
|
|
1125
1125
|
const arg = parsePrimary();
|
|
1126
|
-
return new Expr(26, [arg, mkSpanFrom(t_9.Span, Ast_spanOfExpr(arg))]);
|
|
1126
|
+
return new Expr(/* ESome */ 26, [arg, mkSpanFrom(t_9.Span, Ast_spanOfExpr(arg))]);
|
|
1127
1127
|
}
|
|
1128
1128
|
default:
|
|
1129
|
-
return new Expr(2, [name_7, t_9.Span]);
|
|
1129
|
+
return new Expr(/* EVar */ 2, [name_7, t_9.Span]);
|
|
1130
1130
|
}
|
|
1131
1131
|
}
|
|
1132
1132
|
case 27: {
|
|
1133
1133
|
const lp_2 = TokenStream__Next(stream);
|
|
1134
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
1135
|
-
return new Expr(0, [mkSpanFrom(lp_2.Span, TokenStream__Next(stream).Span)]);
|
|
1134
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.RParen)) {
|
|
1135
|
+
return new Expr(/* EUnit */ 0, [mkSpanFrom(lp_2.Span, TokenStream__Next(stream).Span)]);
|
|
1136
1136
|
}
|
|
1137
1137
|
else {
|
|
1138
1138
|
const first_4 = parseExpr();
|
|
1139
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1139
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Comma)) {
|
|
1140
1140
|
const elements_2 = [];
|
|
1141
1141
|
void (elements_2.push(first_4));
|
|
1142
1142
|
void (elements_2.push(parseExpr()));
|
|
1143
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
1143
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Comma)) {
|
|
1144
1144
|
void (elements_2.push(parseExpr()));
|
|
1145
1145
|
}
|
|
1146
|
-
const rp_4 = TokenStream__Expect_77B9EE56(stream,
|
|
1147
|
-
return new Expr(15, [toList(elements_2), mkSpanFrom(lp_2.Span, rp_4.Span)]);
|
|
1146
|
+
const rp_4 = TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after tuple expression");
|
|
1147
|
+
return new Expr(/* ETuple */ 15, [toList(elements_2), mkSpanFrom(lp_2.Span, rp_4.Span)]);
|
|
1148
1148
|
}
|
|
1149
1149
|
else {
|
|
1150
|
-
return new Expr(3, [first_4, mkSpanFrom(lp_2.Span, TokenStream__Expect_77B9EE56(stream,
|
|
1150
|
+
return new Expr(/* EParen */ 3, [first_4, mkSpanFrom(lp_2.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RParen, "Expected \')\' after expression").Span)]);
|
|
1151
1151
|
}
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
@@ -1158,24 +1158,24 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1158
1158
|
throw new ParseException(new ParseError("Opening \'[\' cannot be on its own line; keep it with the first element", lb_3.Span));
|
|
1159
1159
|
}
|
|
1160
1160
|
consumeLayoutSeparators();
|
|
1161
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1162
|
-
return new Expr(13, [empty(), mkSpanFrom(lb_3.Span, lb_3.Span)]);
|
|
1161
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.RBracket)) {
|
|
1162
|
+
return new Expr(/* EList */ 13, [empty(), mkSpanFrom(lb_3.Span, lb_3.Span)]);
|
|
1163
1163
|
}
|
|
1164
1164
|
else {
|
|
1165
1165
|
const first_5 = parseEntryExpr();
|
|
1166
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1166
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.RangeDots)) {
|
|
1167
1167
|
const second = parseEntryExpr();
|
|
1168
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1168
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon) ? true : TokenStream__Match_5CEB78CD(stream, TokenKind.RangeDots)) {
|
|
1169
1169
|
throw new ParseException(new ParseError("Invalid range syntax", TokenStream__Peek(stream).Span));
|
|
1170
1170
|
}
|
|
1171
|
-
return new Expr(14, [first_5, second, mkSpanFrom(lb_3.Span, TokenStream__Expect_77B9EE56(stream,
|
|
1171
|
+
return new Expr(/* ERange */ 14, [first_5, second, mkSpanFrom(lb_3.Span, TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' in range expression").Span)]);
|
|
1172
1172
|
}
|
|
1173
1173
|
else {
|
|
1174
1174
|
const elements_3 = [];
|
|
1175
1175
|
void (elements_3.push(first_5));
|
|
1176
1176
|
let keepParsing = true;
|
|
1177
1177
|
while (keepParsing) {
|
|
1178
|
-
if ((TokenStream__Match_5CEB78CD(stream,
|
|
1178
|
+
if ((TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon) ? ((void consumeLayoutSeparators(), true)) : consumeLayoutSeparators()) && !equals(TokenStream__Peek(stream).Kind, TokenKind.RBracket)) {
|
|
1179
1179
|
void (elements_3.push(parseEntryExpr()));
|
|
1180
1180
|
}
|
|
1181
1181
|
else {
|
|
@@ -1183,11 +1183,11 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1183
1183
|
}
|
|
1184
1184
|
}
|
|
1185
1185
|
const rbIndex_6 = TokenStream__get_Index(stream) | 0;
|
|
1186
|
-
const rb_7 = TokenStream__Expect_77B9EE56(stream,
|
|
1186
|
+
const rb_7 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' in list literal");
|
|
1187
1187
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_6, rb_7.Span.Start.Line)) {
|
|
1188
1188
|
throw new ParseException(new ParseError("Closing \']\' cannot be on its own line; keep it with the last element", rb_7.Span));
|
|
1189
1189
|
}
|
|
1190
|
-
return new Expr(13, [toList(elements_3), mkSpanFrom(lb_3.Span, rb_7.Span)]);
|
|
1190
|
+
return new Expr(/* EList */ 13, [toList(elements_3), mkSpanFrom(lb_3.Span, rb_7.Span)]);
|
|
1191
1191
|
}
|
|
1192
1192
|
}
|
|
1193
1193
|
}
|
|
@@ -1198,18 +1198,18 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1198
1198
|
throw new ParseException(new ParseError("Opening \'{\' cannot be on its own line; keep it with the first entry", lb_4.Span));
|
|
1199
1199
|
}
|
|
1200
1200
|
consumeLayoutSeparators();
|
|
1201
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1202
|
-
return new Expr(18, [empty(), mkSpanFrom(lb_4.Span, lb_4.Span)]);
|
|
1201
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.RBrace)) {
|
|
1202
|
+
return new Expr(/* EMap */ 18, [empty(), mkSpanFrom(lb_4.Span, lb_4.Span)]);
|
|
1203
1203
|
}
|
|
1204
|
-
else if (TokenStream__Match_5CEB78CD(stream,
|
|
1205
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
1204
|
+
else if (TokenStream__Match_5CEB78CD(stream, TokenKind.Bar)) {
|
|
1205
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) {
|
|
1206
1206
|
throw new ParseException(new ParseError("Structural record literal must define at least one field", TokenStream__Peek(stream).Span));
|
|
1207
1207
|
}
|
|
1208
1208
|
const mark_1 = TokenStream__Mark(stream) | 0;
|
|
1209
1209
|
let matchValue_24;
|
|
1210
1210
|
const baseExpr = parseExpr();
|
|
1211
1211
|
TokenStream__SkipNewlines(stream);
|
|
1212
|
-
if (!TokenStream__Match_5CEB78CD(stream,
|
|
1212
|
+
if (!TokenStream__Match_5CEB78CD(stream, TokenKind.With)) {
|
|
1213
1213
|
TokenStream__Restore_Z524259A4(stream, mark_1);
|
|
1214
1214
|
matchValue_24 = undefined;
|
|
1215
1215
|
}
|
|
@@ -1220,27 +1220,27 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1220
1220
|
const matchValue_23 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record update").Kind;
|
|
1221
1221
|
name_8 = ((matchValue_23.tag === 4) ? matchValue_23.fields[0] : "");
|
|
1222
1222
|
TokenStream__SkipNewlines(stream);
|
|
1223
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1223
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in structural record update field");
|
|
1224
1224
|
const value_40 = parseEntryExpr();
|
|
1225
1225
|
void (updates.push([name_8, value_40]));
|
|
1226
1226
|
};
|
|
1227
1227
|
parseUpdateField();
|
|
1228
1228
|
let keepParsing_1 = true;
|
|
1229
1229
|
while (keepParsing_1) {
|
|
1230
|
-
if ((TokenStream__Match_5CEB78CD(stream,
|
|
1230
|
+
if ((TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon) ? ((void consumeLayoutSeparators(), true)) : consumeLayoutSeparators()) && !equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) {
|
|
1231
1231
|
parseUpdateField();
|
|
1232
1232
|
}
|
|
1233
1233
|
else {
|
|
1234
1234
|
keepParsing_1 = false;
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1237
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Bar, "Expected \'|\' in structural record update");
|
|
1238
1238
|
const rbIndex_7 = TokenStream__get_Index(stream) | 0;
|
|
1239
|
-
const rb_8 = TokenStream__Expect_77B9EE56(stream,
|
|
1239
|
+
const rb_8 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in structural record update");
|
|
1240
1240
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_7, rb_8.Span.Start.Line)) {
|
|
1241
1241
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_8.Span));
|
|
1242
1242
|
}
|
|
1243
|
-
matchValue_24 = (new Expr(20, [baseExpr, toList(updates), mkSpanFrom(lb_4.Span, rb_8.Span)]));
|
|
1243
|
+
matchValue_24 = (new Expr(/* EStructuralRecordUpdate */ 20, [baseExpr, toList(updates), mkSpanFrom(lb_4.Span, rb_8.Span)]));
|
|
1244
1244
|
}
|
|
1245
1245
|
if (matchValue_24 == null) {
|
|
1246
1246
|
const fields_6 = [];
|
|
@@ -1249,59 +1249,59 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1249
1249
|
const matchValue_25 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in structural record literal").Kind;
|
|
1250
1250
|
name_9 = ((matchValue_25.tag === 4) ? matchValue_25.fields[0] : "");
|
|
1251
1251
|
TokenStream__SkipNewlines(stream);
|
|
1252
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1252
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in structural record field");
|
|
1253
1253
|
const value_44 = parseEntryExpr();
|
|
1254
1254
|
void (fields_6.push([name_9, value_44]));
|
|
1255
1255
|
};
|
|
1256
1256
|
parseField_3();
|
|
1257
1257
|
let keepParsing_2 = true;
|
|
1258
1258
|
while (keepParsing_2) {
|
|
1259
|
-
if ((TokenStream__Match_5CEB78CD(stream,
|
|
1259
|
+
if ((TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon) ? ((void consumeLayoutSeparators(), true)) : consumeLayoutSeparators()) && !equals(TokenStream__Peek(stream).Kind, TokenKind.Bar)) {
|
|
1260
1260
|
parseField_3();
|
|
1261
1261
|
}
|
|
1262
1262
|
else {
|
|
1263
1263
|
keepParsing_2 = false;
|
|
1264
1264
|
}
|
|
1265
1265
|
}
|
|
1266
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1266
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Bar, "Expected \'|\' in structural record literal");
|
|
1267
1267
|
const rbIndex_8 = TokenStream__get_Index(stream) | 0;
|
|
1268
|
-
const rb_9 = TokenStream__Expect_77B9EE56(stream,
|
|
1268
|
+
const rb_9 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in structural record literal");
|
|
1269
1269
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_8, rb_9.Span.Start.Line)) {
|
|
1270
1270
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_9.Span));
|
|
1271
1271
|
}
|
|
1272
|
-
return new Expr(17, [toList(fields_6), mkSpanFrom(lb_4.Span, rb_9.Span)]);
|
|
1272
|
+
return new Expr(/* EStructuralRecord */ 17, [toList(fields_6), mkSpanFrom(lb_4.Span, rb_9.Span)]);
|
|
1273
1273
|
}
|
|
1274
1274
|
else {
|
|
1275
1275
|
return matchValue_24;
|
|
1276
1276
|
}
|
|
1277
1277
|
}
|
|
1278
|
-
else if (equals(TokenStream__Peek(stream).Kind,
|
|
1278
|
+
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket) ? true : equals(TokenStream__Peek(stream).Kind, TokenKind.RangeDots)) {
|
|
1279
1279
|
const parseMapEntry = () => {
|
|
1280
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1281
|
-
return new MapEntry(1, [parseEntryExpr()]);
|
|
1280
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.RangeDots)) {
|
|
1281
|
+
return new MapEntry(/* MESpread */ 1, [parseEntryExpr()]);
|
|
1282
1282
|
}
|
|
1283
1283
|
else {
|
|
1284
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1284
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.LBracket, "Expected \'[\' in map entry key");
|
|
1285
1285
|
const keyExpr = parseExpr();
|
|
1286
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1286
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' after map entry key");
|
|
1287
1287
|
TokenStream__SkipNewlines(stream);
|
|
1288
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1289
|
-
return new MapEntry(0, [keyExpr, parseEntryExpr()]);
|
|
1288
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in map entry");
|
|
1289
|
+
return new MapEntry(/* MEKeyValue */ 0, [keyExpr, parseEntryExpr()]);
|
|
1290
1290
|
}
|
|
1291
1291
|
};
|
|
1292
1292
|
const entries = [];
|
|
1293
1293
|
void (entries.push(parseMapEntry()));
|
|
1294
1294
|
let keepParsing_3 = true;
|
|
1295
1295
|
while (keepParsing_3) {
|
|
1296
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1297
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
1296
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon) ? ((void consumeLayoutSeparators(), true)) : consumeLayoutSeparators()) {
|
|
1297
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace)) {
|
|
1298
1298
|
keepParsing_3 = false;
|
|
1299
1299
|
}
|
|
1300
1300
|
else {
|
|
1301
1301
|
void (entries.push(parseMapEntry()));
|
|
1302
1302
|
}
|
|
1303
1303
|
}
|
|
1304
|
-
else if (equals(TokenStream__Peek(stream).Kind,
|
|
1304
|
+
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace)) {
|
|
1305
1305
|
keepParsing_3 = false;
|
|
1306
1306
|
}
|
|
1307
1307
|
else {
|
|
@@ -1309,18 +1309,18 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
1311
|
const rbIndex_9 = TokenStream__get_Index(stream) | 0;
|
|
1312
|
-
const rb_10 = TokenStream__Expect_77B9EE56(stream,
|
|
1312
|
+
const rb_10 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in map literal");
|
|
1313
1313
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_9, rb_10.Span.Start.Line)) {
|
|
1314
1314
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_10.Span));
|
|
1315
1315
|
}
|
|
1316
|
-
return new Expr(18, [toList(entries), mkSpanFrom(lb_4.Span, rb_10.Span)]);
|
|
1316
|
+
return new Expr(/* EMap */ 18, [toList(entries), mkSpanFrom(lb_4.Span, rb_10.Span)]);
|
|
1317
1317
|
}
|
|
1318
1318
|
else {
|
|
1319
1319
|
const mark_2 = TokenStream__Mark(stream) | 0;
|
|
1320
1320
|
let matchValue_27;
|
|
1321
1321
|
const baseExpr_1 = parseExpr();
|
|
1322
1322
|
TokenStream__SkipNewlines(stream);
|
|
1323
|
-
if (!TokenStream__Match_5CEB78CD(stream,
|
|
1323
|
+
if (!TokenStream__Match_5CEB78CD(stream, TokenKind.With)) {
|
|
1324
1324
|
TokenStream__Restore_Z524259A4(stream, mark_2);
|
|
1325
1325
|
matchValue_27 = undefined;
|
|
1326
1326
|
}
|
|
@@ -1331,14 +1331,14 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1331
1331
|
const matchValue_26 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record update").Kind;
|
|
1332
1332
|
name_10 = ((matchValue_26.tag === 4) ? matchValue_26.fields[0] : "");
|
|
1333
1333
|
TokenStream__SkipNewlines(stream);
|
|
1334
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1334
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record update field");
|
|
1335
1335
|
const value_53 = parseEntryExpr();
|
|
1336
1336
|
void (updates_1.push([name_10, value_53]));
|
|
1337
1337
|
};
|
|
1338
1338
|
parseUpdateField_1();
|
|
1339
1339
|
let keepParsing_4 = true;
|
|
1340
1340
|
while (keepParsing_4) {
|
|
1341
|
-
if ((TokenStream__Match_5CEB78CD(stream,
|
|
1341
|
+
if ((TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon) ? ((void consumeLayoutSeparators(), true)) : consumeLayoutSeparators()) && !equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace)) {
|
|
1342
1342
|
parseUpdateField_1();
|
|
1343
1343
|
}
|
|
1344
1344
|
else {
|
|
@@ -1346,11 +1346,11 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1346
1346
|
}
|
|
1347
1347
|
}
|
|
1348
1348
|
const rbIndex_10 = TokenStream__get_Index(stream) | 0;
|
|
1349
|
-
const rb_11 = TokenStream__Expect_77B9EE56(stream,
|
|
1349
|
+
const rb_11 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in record update");
|
|
1350
1350
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_10, rb_11.Span.Start.Line)) {
|
|
1351
1351
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_11.Span));
|
|
1352
1352
|
}
|
|
1353
|
-
matchValue_27 = (new Expr(19, [baseExpr_1, toList(updates_1), mkSpanFrom(lb_4.Span, rb_11.Span)]));
|
|
1353
|
+
matchValue_27 = (new Expr(/* ERecordUpdate */ 19, [baseExpr_1, toList(updates_1), mkSpanFrom(lb_4.Span, rb_11.Span)]));
|
|
1354
1354
|
}
|
|
1355
1355
|
if (matchValue_27 == null) {
|
|
1356
1356
|
const fields_7 = [];
|
|
@@ -1359,14 +1359,14 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1359
1359
|
const matchValue_28 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name in record literal").Kind;
|
|
1360
1360
|
name_11 = ((matchValue_28.tag === 4) ? matchValue_28.fields[0] : "");
|
|
1361
1361
|
TokenStream__SkipNewlines(stream);
|
|
1362
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1362
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in record field");
|
|
1363
1363
|
const value_56 = parseEntryExpr();
|
|
1364
1364
|
void (fields_7.push([name_11, value_56]));
|
|
1365
1365
|
};
|
|
1366
1366
|
parseField_4();
|
|
1367
1367
|
let keepParsing_5 = true;
|
|
1368
1368
|
while (keepParsing_5) {
|
|
1369
|
-
if ((TokenStream__Match_5CEB78CD(stream,
|
|
1369
|
+
if ((TokenStream__Match_5CEB78CD(stream, TokenKind.Semicolon) ? ((void consumeLayoutSeparators(), true)) : consumeLayoutSeparators()) && !equals(TokenStream__Peek(stream).Kind, TokenKind.RBrace)) {
|
|
1370
1370
|
parseField_4();
|
|
1371
1371
|
}
|
|
1372
1372
|
else {
|
|
@@ -1374,11 +1374,11 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1374
1374
|
}
|
|
1375
1375
|
}
|
|
1376
1376
|
const rbIndex_11 = TokenStream__get_Index(stream) | 0;
|
|
1377
|
-
const rb_12 = TokenStream__Expect_77B9EE56(stream,
|
|
1377
|
+
const rb_12 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBrace, "Expected \'}\' in record literal");
|
|
1378
1378
|
if (!hasNonLayoutTokenBeforeOnSameLine(rbIndex_11, rb_12.Span.Start.Line)) {
|
|
1379
1379
|
throw new ParseException(new ParseError("Closing \'}\' cannot be on its own line; keep it with the last entry", rb_12.Span));
|
|
1380
1380
|
}
|
|
1381
|
-
return new Expr(16, [toList(fields_7), mkSpanFrom(lb_4.Span, rb_12.Span)]);
|
|
1381
|
+
return new Expr(/* ERecord */ 16, [toList(fields_7), mkSpanFrom(lb_4.Span, rb_12.Span)]);
|
|
1382
1382
|
}
|
|
1383
1383
|
else {
|
|
1384
1384
|
return matchValue_27;
|
|
@@ -1394,7 +1394,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1394
1394
|
case 21: {
|
|
1395
1395
|
const raiseTok = TokenStream__Next(stream);
|
|
1396
1396
|
const value_58 = parsePrimary();
|
|
1397
|
-
return new Expr(7, [value_58, mkSpanFrom(raiseTok.Span, Ast_spanOfExpr(value_58))]);
|
|
1397
|
+
return new Expr(/* ERaise */ 7, [value_58, mkSpanFrom(raiseTok.Span, Ast_spanOfExpr(value_58))]);
|
|
1398
1398
|
}
|
|
1399
1399
|
case 22:
|
|
1400
1400
|
return parseFor();
|
|
@@ -1403,12 +1403,12 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1403
1403
|
case 46: {
|
|
1404
1404
|
const t_10 = TokenStream__Next(stream);
|
|
1405
1405
|
const nameTok_10 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected type name after \'typeof\'");
|
|
1406
|
-
return new Expr(28, [(matchValue_29 = nameTok_10.Kind, (matchValue_29.tag === 4) ? matchValue_29.fields[0] : ""), mkSpanFrom(t_10.Span, nameTok_10.Span)]);
|
|
1406
|
+
return new Expr(/* ETypeOf */ 28, [(matchValue_29 = nameTok_10.Kind, (matchValue_29.tag === 4) ? matchValue_29.fields[0] : ""), mkSpanFrom(t_10.Span, nameTok_10.Span)]);
|
|
1407
1407
|
}
|
|
1408
1408
|
case 47: {
|
|
1409
1409
|
const t_11 = TokenStream__Next(stream);
|
|
1410
1410
|
const nameTok_11 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'nameof\'");
|
|
1411
|
-
return new Expr(29, [(matchValue_30 = nameTok_11.Kind, (matchValue_30.tag === 4) ? matchValue_30.fields[0] : ""), mkSpanFrom(t_11.Span, nameTok_11.Span)]);
|
|
1411
|
+
return new Expr(/* ENameOf */ 29, [(matchValue_30 = nameTok_11.Kind, (matchValue_30.tag === 4) ? matchValue_30.fields[0] : ""), mkSpanFrom(t_11.Span, nameTok_11.Span)]);
|
|
1412
1412
|
}
|
|
1413
1413
|
case 2:
|
|
1414
1414
|
throw new ParseException(new ParseError("Indentation error: unexpected indent in expression", t_6.Span));
|
|
@@ -1422,21 +1422,23 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1422
1422
|
let expr_3 = parsePrimary();
|
|
1423
1423
|
let keepGoing_1 = true;
|
|
1424
1424
|
while (keepGoing_1) {
|
|
1425
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1425
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Dot)) {
|
|
1426
1426
|
const fieldTok_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected field name after \'.\'");
|
|
1427
1427
|
let fieldName_3;
|
|
1428
1428
|
const matchValue_31 = fieldTok_1.Kind;
|
|
1429
1429
|
fieldName_3 = ((matchValue_31.tag === 4) ? matchValue_31.fields[0] : "");
|
|
1430
|
-
expr_3 = (new Expr(21, [expr_3, fieldName_3, mkSpanFrom(Ast_spanOfExpr(expr_3), fieldTok_1.Span)]));
|
|
1430
|
+
expr_3 = (new Expr(/* EFieldGet */ 21, [expr_3, fieldName_3, mkSpanFrom(Ast_spanOfExpr(expr_3), fieldTok_1.Span)]));
|
|
1431
1431
|
}
|
|
1432
|
-
else if (equals(TokenStream__Peek(stream).Kind,
|
|
1432
|
+
else if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket)) {
|
|
1433
1433
|
const lb_5 = TokenStream__Peek(stream);
|
|
1434
1434
|
const targetSpan = Ast_spanOfExpr(expr_3);
|
|
1435
|
-
|
|
1435
|
+
const isAdjacent = (lb_5.Span.Start.Line === targetSpan.End.Line) && (lb_5.Span.Start.Column === targetSpan.End.Column);
|
|
1436
|
+
const hasIndexerPayload = !equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.RBracket);
|
|
1437
|
+
if (isAdjacent && hasIndexerPayload) {
|
|
1436
1438
|
TokenStream__Next(stream);
|
|
1437
1439
|
const keyExpr_1 = parseExpr();
|
|
1438
|
-
const rb_13 = TokenStream__Expect_77B9EE56(stream,
|
|
1439
|
-
expr_3 = (new Expr(22, [expr_3, keyExpr_1, mkSpanFrom(targetSpan, rb_13.Span)]));
|
|
1440
|
+
const rb_13 = TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' after index expression");
|
|
1441
|
+
expr_3 = (new Expr(/* EIndexGet */ 22, [expr_3, keyExpr_1, mkSpanFrom(targetSpan, rb_13.Span)]));
|
|
1440
1442
|
}
|
|
1441
1443
|
else {
|
|
1442
1444
|
keepGoing_1 = false;
|
|
@@ -1456,24 +1458,24 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1456
1458
|
const next_2 = TokenStream__Peek(stream);
|
|
1457
1459
|
if ((next_2.Span.Start.Line === Ast_spanOfExpr(expr_4).End.Line) && isStartAtom(next_2.Kind)) {
|
|
1458
1460
|
const arg_1 = parsePostfix();
|
|
1459
|
-
expr_4 = (new Expr(5, [expr_4, arg_1, mkSpanFrom(Ast_spanOfExpr(expr_4), Ast_spanOfExpr(arg_1))]));
|
|
1461
|
+
expr_4 = (new Expr(/* EApply */ 5, [expr_4, arg_1, mkSpanFrom(Ast_spanOfExpr(expr_4), Ast_spanOfExpr(arg_1))]));
|
|
1460
1462
|
}
|
|
1461
1463
|
else {
|
|
1462
1464
|
const mark_3 = TokenStream__Mark(stream) | 0;
|
|
1463
1465
|
let sawNewline_3 = false;
|
|
1464
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
1466
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
1465
1467
|
sawNewline_3 = true;
|
|
1466
1468
|
}
|
|
1467
1469
|
if (sawNewline_3 && allowIndentedApplication) {
|
|
1468
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1470
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Indent)) {
|
|
1469
1471
|
hasMultilineArgBlock = true;
|
|
1470
1472
|
}
|
|
1471
1473
|
const candidate = TokenStream__Peek(stream);
|
|
1472
1474
|
if ((candidate.Span.Start.Column > Ast_spanOfExpr(expr_4).Start.Column) && isStartAtom(candidate.Kind)) {
|
|
1473
1475
|
const arg_2 = parsePostfix();
|
|
1474
|
-
expr_4 = (new Expr(5, [expr_4, arg_2, mkSpanFrom(Ast_spanOfExpr(expr_4), Ast_spanOfExpr(arg_2))]));
|
|
1476
|
+
expr_4 = (new Expr(/* EApply */ 5, [expr_4, arg_2, mkSpanFrom(Ast_spanOfExpr(expr_4), Ast_spanOfExpr(arg_2))]));
|
|
1475
1477
|
}
|
|
1476
|
-
else if (hasMultilineArgBlock && equals(candidate.Kind,
|
|
1478
|
+
else if (hasMultilineArgBlock && equals(candidate.Kind, TokenKind.Dedent)) {
|
|
1477
1479
|
TokenStream__Next(stream);
|
|
1478
1480
|
hasMultilineArgBlock = false;
|
|
1479
1481
|
keepGoing_2 = false;
|
|
@@ -1530,7 +1532,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1530
1532
|
while (continueLoop) {
|
|
1531
1533
|
TokenStream__SkipNewlines(stream);
|
|
1532
1534
|
const mark_4 = TokenStream__Mark(stream) | 0;
|
|
1533
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1535
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
|
|
1534
1536
|
if (precedence(TokenStream__Peek(stream).Kind) >= minPrec) {
|
|
1535
1537
|
}
|
|
1536
1538
|
else {
|
|
@@ -1548,7 +1550,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1548
1550
|
if (prec >= minPrec) {
|
|
1549
1551
|
const opTok = TokenStream__Next(stream);
|
|
1550
1552
|
const right_2 = parseBinary(prec + 1);
|
|
1551
|
-
left_2 = (new Expr(25, [(op_1 = opTok.Kind, (op_1.tag === 49) ? "+" : ((op_1.tag === 50) ? "-" : ((op_1.tag === 51) ? "*" : ((op_1.tag === 52) ? "/" : ((op_1.tag === 53) ? "%" : ((op_1.tag === 25) ? "=" : ((op_1.tag === 54) ? "<" : ((op_1.tag === 55) ? ">" : ((op_1.tag === 56) ? "<=" : ((op_1.tag === 57) ? ">=" : ((op_1.tag === 58) ? "&&" : ((op_1.tag === 59) ? "||" : ((op_1.tag === 60) ? "|>" : ((op_1.tag === 61) ? "::" : ((op_1.tag === 62) ? "@" : "?"))))))))))))))), left_2, right_2, mkSpanFrom(Ast_spanOfExpr(left_2), Ast_spanOfExpr(right_2))]));
|
|
1553
|
+
left_2 = (new Expr(/* EBinOp */ 25, [(op_1 = opTok.Kind, (op_1.tag === 49) ? "+" : ((op_1.tag === 50) ? "-" : ((op_1.tag === 51) ? "*" : ((op_1.tag === 52) ? "/" : ((op_1.tag === 53) ? "%" : ((op_1.tag === 25) ? "=" : ((op_1.tag === 54) ? "<" : ((op_1.tag === 55) ? ">" : ((op_1.tag === 56) ? "<=" : ((op_1.tag === 57) ? ">=" : ((op_1.tag === 58) ? "&&" : ((op_1.tag === 59) ? "||" : ((op_1.tag === 60) ? "|>" : ((op_1.tag === 61) ? "::" : ((op_1.tag === 62) ? "@" : "?"))))))))))))))), left_2, right_2, mkSpanFrom(Ast_spanOfExpr(left_2), Ast_spanOfExpr(right_2))]));
|
|
1552
1554
|
}
|
|
1553
1555
|
else {
|
|
1554
1556
|
looping = false;
|
|
@@ -1556,14 +1558,14 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1556
1558
|
}
|
|
1557
1559
|
return left_2;
|
|
1558
1560
|
};
|
|
1559
|
-
const parseIf = () => parseIfAfterKeyword(TokenStream__Expect_77B9EE56(stream,
|
|
1561
|
+
const parseIf = () => parseIfAfterKeyword(TokenStream__Expect_77B9EE56(stream, TokenKind.If, "Expected \'if\'").Span);
|
|
1560
1562
|
const parseIfAfterKeyword = (startSpan) => {
|
|
1561
1563
|
const cond = parseExpr();
|
|
1562
1564
|
TokenStream__SkipNewlines(stream);
|
|
1563
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1565
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Then, "Expected \'then\'");
|
|
1564
1566
|
const thenExpr = parseExprOrBlock();
|
|
1565
1567
|
TokenStream__SkipNewlines(stream);
|
|
1566
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
1568
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Dedent)) {
|
|
1567
1569
|
TokenStream__SkipNewlines(stream);
|
|
1568
1570
|
}
|
|
1569
1571
|
let elseExpr;
|
|
@@ -1581,10 +1583,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1581
1583
|
default:
|
|
1582
1584
|
throw new ParseException(new ParseError("Expected \'else\' or \'elif\'", TokenStream__Peek(stream).Span));
|
|
1583
1585
|
}
|
|
1584
|
-
return new Expr(6, [cond, thenExpr, elseExpr, mkSpanFrom(startSpan, Ast_spanOfExpr(elseExpr))]);
|
|
1586
|
+
return new Expr(/* EIf */ 6, [cond, thenExpr, elseExpr, mkSpanFrom(startSpan, Ast_spanOfExpr(elseExpr))]);
|
|
1585
1587
|
};
|
|
1586
1588
|
const parseFor = () => {
|
|
1587
|
-
const forTok = TokenStream__Expect_77B9EE56(stream,
|
|
1589
|
+
const forTok = TokenStream__Expect_77B9EE56(stream, TokenKind.For, "Expected \'for\'");
|
|
1588
1590
|
let name_14;
|
|
1589
1591
|
const matchValue_33 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'for\'").Kind;
|
|
1590
1592
|
name_14 = ((matchValue_33.tag === 4) ? matchValue_33.fields[0] : "");
|
|
@@ -1638,10 +1640,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1638
1640
|
}
|
|
1639
1641
|
}
|
|
1640
1642
|
const body = parseExprOrBlock();
|
|
1641
|
-
return new Expr(8, [name_14, source_19, body, mkSpanFrom(forTok.Span, Ast_spanOfExpr(body))]);
|
|
1643
|
+
return new Expr(/* EFor */ 8, [name_14, source_19, body, mkSpanFrom(forTok.Span, Ast_spanOfExpr(body))]);
|
|
1642
1644
|
};
|
|
1643
1645
|
const parseLambda = () => {
|
|
1644
|
-
const funTok = TokenStream__Expect_77B9EE56(stream,
|
|
1646
|
+
const funTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Fun, "Expected \'fun\'");
|
|
1645
1647
|
const parameters = [];
|
|
1646
1648
|
let doneParams = false;
|
|
1647
1649
|
while (!doneParams) {
|
|
@@ -1661,23 +1663,23 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1661
1663
|
throw new ParseException(new ParseError("Expected at least one lambda parameter", TokenStream__Peek(stream).Span));
|
|
1662
1664
|
}
|
|
1663
1665
|
TokenStream__SkipNewlines(stream);
|
|
1664
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1665
|
-
return foldBack_1((param_1, acc) => (new Expr(4, [param_1, acc, mkSpanFrom(funTok.Span, Ast_spanOfExpr(acc))])), parameters, parseExprOrBlock());
|
|
1666
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Arrow, "Expected \'->\' in lambda");
|
|
1667
|
+
return foldBack_1((param_1, acc) => (new Expr(/* ELambda */ 4, [param_1, acc, mkSpanFrom(funTok.Span, Ast_spanOfExpr(acc))])), parameters, parseExprOrBlock());
|
|
1666
1668
|
};
|
|
1667
1669
|
const parseMatch = () => {
|
|
1668
|
-
const matchTok = TokenStream__Expect_77B9EE56(stream,
|
|
1670
|
+
const matchTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Match, "Expected \'match\'");
|
|
1669
1671
|
const expr_5 = parseExpr();
|
|
1670
1672
|
TokenStream__SkipNewlines(stream);
|
|
1671
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1673
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.With, "Expected \'with\' in match");
|
|
1672
1674
|
const cases_2 = [];
|
|
1673
1675
|
const parseCase_1 = () => {
|
|
1674
1676
|
TokenStream__SkipNewlines(stream);
|
|
1675
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1677
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Bar)) {
|
|
1676
1678
|
}
|
|
1677
1679
|
const pat = parsePatternCons();
|
|
1678
1680
|
TokenStream__SkipNewlines(stream);
|
|
1679
1681
|
let guard;
|
|
1680
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1682
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.When)) {
|
|
1681
1683
|
const g = parseExpr();
|
|
1682
1684
|
TokenStream__SkipNewlines(stream);
|
|
1683
1685
|
guard = g;
|
|
@@ -1685,17 +1687,17 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1685
1687
|
else {
|
|
1686
1688
|
guard = undefined;
|
|
1687
1689
|
}
|
|
1688
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1690
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Arrow, "Expected \'->\' in match case");
|
|
1689
1691
|
const body_2 = parseExprOrBlock();
|
|
1690
1692
|
const span_1 = mkSpanFrom(Ast_spanOfPattern(pat), Ast_spanOfExpr(body_2));
|
|
1691
1693
|
void (cases_2.push([pat, guard, body_2, span_1]));
|
|
1692
1694
|
};
|
|
1693
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1694
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
1695
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
1696
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
1695
1697
|
}
|
|
1696
|
-
const hasIndentedCaseBlock = TokenStream__Match_5CEB78CD(stream,
|
|
1698
|
+
const hasIndentedCaseBlock = TokenStream__Match_5CEB78CD(stream, TokenKind.Indent);
|
|
1697
1699
|
const firstCaseToken = TokenStream__Peek(stream);
|
|
1698
|
-
if (equals(firstCaseToken.Kind,
|
|
1700
|
+
if (equals(firstCaseToken.Kind, TokenKind.EOF) ? true : equals(firstCaseToken.Kind, TokenKind.Dedent)) {
|
|
1699
1701
|
throw new ParseException(new ParseError("Expected match case", firstCaseToken.Span));
|
|
1700
1702
|
}
|
|
1701
1703
|
const caseColumn = firstCaseToken.Span.Start.Column | 0;
|
|
@@ -1784,15 +1786,15 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1784
1786
|
}
|
|
1785
1787
|
}
|
|
1786
1788
|
}
|
|
1787
|
-
return new Expr(9, [expr_5, toList(cases_2), mkSpanFrom(matchTok.Span, Ast_spanOfExpr(expr_5))]);
|
|
1789
|
+
return new Expr(/* EMatch */ 9, [expr_5, toList(cases_2), mkSpanFrom(matchTok.Span, Ast_spanOfExpr(expr_5))]);
|
|
1788
1790
|
};
|
|
1789
1791
|
const parseLetExpr = () => {
|
|
1790
|
-
let matchValue_41
|
|
1791
|
-
const letTok = TokenStream__Expect_77B9EE56(stream,
|
|
1792
|
-
const isRec_1 = TokenStream__Match_5CEB78CD(stream,
|
|
1792
|
+
let matchValue_41;
|
|
1793
|
+
const letTok = TokenStream__Expect_77B9EE56(stream, TokenKind.Let, "Expected \'let\'");
|
|
1794
|
+
const isRec_1 = TokenStream__Match_5CEB78CD(stream, TokenKind.Rec);
|
|
1793
1795
|
let patternInput_2;
|
|
1794
1796
|
if (isRec_1) {
|
|
1795
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
1797
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.LParen)) {
|
|
1796
1798
|
throw new ParseException(new ParseError("\'let rec\' does not support pattern bindings", TokenStream__Peek(stream).Span));
|
|
1797
1799
|
}
|
|
1798
1800
|
const nameTok_13 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
|
|
@@ -1825,7 +1827,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1825
1827
|
const args_2 = patternInput_2[1];
|
|
1826
1828
|
TokenStream__SkipNewlines(stream);
|
|
1827
1829
|
let returnAnnotation;
|
|
1828
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1830
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Colon)) {
|
|
1829
1831
|
if (args_2.length === 0) {
|
|
1830
1832
|
throw new ParseException(new ParseError("Return type annotations are only supported on function let bindings", TokenStream__Peek(stream).Span));
|
|
1831
1833
|
}
|
|
@@ -1834,10 +1836,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1834
1836
|
else {
|
|
1835
1837
|
returnAnnotation = undefined;
|
|
1836
1838
|
}
|
|
1837
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
1839
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.Colon)) {
|
|
1838
1840
|
throw new ParseException(new ParseError("Annotated parameters must be parenthesized as (x: T)", TokenStream__Peek(stream).Span));
|
|
1839
1841
|
}
|
|
1840
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1842
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
|
|
1841
1843
|
const value_70 = parseExprOrBlock();
|
|
1842
1844
|
if (isRec_1) {
|
|
1843
1845
|
const bindings = [];
|
|
@@ -1846,7 +1848,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1846
1848
|
let doneBindings = false;
|
|
1847
1849
|
while (!doneBindings) {
|
|
1848
1850
|
TokenStream__SkipNewlines(stream);
|
|
1849
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
1851
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.And)) {
|
|
1850
1852
|
const nextNameTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'and\'");
|
|
1851
1853
|
let nextName;
|
|
1852
1854
|
const matchValue_42 = nextNameTok.Kind;
|
|
@@ -1856,11 +1858,11 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1856
1858
|
throw new ParseException(new ParseError("\'let rec ... and ...\' requires function arguments for each binding", nextNameTok.Span));
|
|
1857
1859
|
}
|
|
1858
1860
|
TokenStream__SkipNewlines(stream);
|
|
1859
|
-
const nextReturnAnnotation = TokenStream__Match_5CEB78CD(stream,
|
|
1860
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
1861
|
+
const nextReturnAnnotation = TokenStream__Match_5CEB78CD(stream, TokenKind.Colon) ? parseTypeRef() : undefined;
|
|
1862
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.Colon)) {
|
|
1861
1863
|
throw new ParseException(new ParseError("Annotated parameters must be parenthesized as (x: T)", TokenStream__Peek(stream).Span));
|
|
1862
1864
|
}
|
|
1863
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
1865
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
|
|
1864
1866
|
const nextValue = parseExprOrBlock();
|
|
1865
1867
|
const nextSpan = mkSpanFrom(nextNameTok.Span, Ast_spanOfExpr(nextValue));
|
|
1866
1868
|
void (bindings.push([nextName, toList(nextArgs), nextReturnAnnotation, nextValue, nextSpan]));
|
|
@@ -1895,10 +1897,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1895
1897
|
body_3 = parseExprOrBlock();
|
|
1896
1898
|
}
|
|
1897
1899
|
if (bindings.length === 1) {
|
|
1898
|
-
return new Expr(10, [bindingName, foldBack_1((arg_3, acc_1) => (new Expr(4, [arg_3, acc_1, Ast_spanOfExpr(acc_1)])), args_2, value_70), body_3, true, returnAnnotation, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
|
|
1900
|
+
return new Expr(/* ELet */ 10, [bindingName, foldBack_1((arg_3, acc_1) => (new Expr(/* ELambda */ 4, [arg_3, acc_1, Ast_spanOfExpr(acc_1)])), args_2, value_70), body_3, true, returnAnnotation, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
|
|
1899
1901
|
}
|
|
1900
1902
|
else {
|
|
1901
|
-
return new Expr(12, [toList(bindings), body_3, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
|
|
1903
|
+
return new Expr(/* ELetRecGroup */ 12, [toList(bindings), body_3, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_3))]);
|
|
1902
1904
|
}
|
|
1903
1905
|
}
|
|
1904
1906
|
}
|
|
@@ -1930,15 +1932,15 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1930
1932
|
body_4 = parseExprOrBlock();
|
|
1931
1933
|
}
|
|
1932
1934
|
if (tuplePatternOpt == null) {
|
|
1933
|
-
return new Expr(10, [bindingName, foldBack_1((arg_4, acc_2) => (new Expr(4, [arg_4, acc_2, Ast_spanOfExpr(acc_2)])), args_2, value_70), body_4, false, returnAnnotation, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
|
|
1935
|
+
return new Expr(/* ELet */ 10, [bindingName, foldBack_1((arg_4, acc_2) => (new Expr(/* ELambda */ 4, [arg_4, acc_2, Ast_spanOfExpr(acc_2)])), args_2, value_70), body_4, false, returnAnnotation, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
|
|
1934
1936
|
}
|
|
1935
|
-
else if (
|
|
1937
|
+
else if (args_2.length > 0) {
|
|
1936
1938
|
const pattern_3 = tuplePatternOpt;
|
|
1937
1939
|
throw new ParseException(new ParseError("Tuple let binding cannot take function parameters", Ast_spanOfPattern(pattern_3)));
|
|
1938
1940
|
}
|
|
1939
1941
|
else {
|
|
1940
1942
|
const pattern_4 = tuplePatternOpt;
|
|
1941
|
-
return new Expr(11, [pattern_4, value_70, body_4, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
|
|
1943
|
+
return new Expr(/* ELetPattern */ 11, [pattern_4, value_70, body_4, mkSpanFrom(letTok.Span, Ast_spanOfExpr(body_4))]);
|
|
1942
1944
|
}
|
|
1943
1945
|
}
|
|
1944
1946
|
}
|
|
@@ -1946,10 +1948,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1946
1948
|
};
|
|
1947
1949
|
const parseExprOrBlock = () => {
|
|
1948
1950
|
let sawNewline_4 = false;
|
|
1949
|
-
while (TokenStream__Match_5CEB78CD(stream,
|
|
1951
|
+
while (TokenStream__Match_5CEB78CD(stream, TokenKind.Newline)) {
|
|
1950
1952
|
sawNewline_4 = true;
|
|
1951
1953
|
}
|
|
1952
|
-
if (sawNewline_4 && TokenStream__Match_5CEB78CD(stream,
|
|
1954
|
+
if (sawNewline_4 && TokenStream__Match_5CEB78CD(stream, TokenKind.Indent)) {
|
|
1953
1955
|
return parseBlock();
|
|
1954
1956
|
}
|
|
1955
1957
|
else {
|
|
@@ -1994,7 +1996,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
1994
1996
|
break;
|
|
1995
1997
|
}
|
|
1996
1998
|
case 38: {
|
|
1997
|
-
if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind,
|
|
1999
|
+
if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Import) ? true : equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Include)) {
|
|
1998
2000
|
matchResult_8 = 5;
|
|
1999
2001
|
}
|
|
2000
2002
|
else {
|
|
@@ -2003,7 +2005,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2003
2005
|
break;
|
|
2004
2006
|
}
|
|
2005
2007
|
case 29: {
|
|
2006
|
-
if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind,
|
|
2008
|
+
if (equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Less)) {
|
|
2007
2009
|
matchResult_8 = 7;
|
|
2008
2010
|
}
|
|
2009
2011
|
else {
|
|
@@ -2037,7 +2039,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2037
2039
|
}
|
|
2038
2040
|
};
|
|
2039
2041
|
const nextSignificant = findNextNonLayout(0);
|
|
2040
|
-
|
|
2042
|
+
TokenStream__Peek(stream);
|
|
2041
2043
|
if (!((blockStatementColumn == null) ? false : ((col = (blockStatementColumn | 0), (matchValue_49 = nextSignificant.Kind, (matchValue_49.tag === 0) ? false : ((matchValue_49.tag === 3) ? false : ((matchValue_49.tag === 28) ? false : ((matchValue_49.tag === 30) ? false : ((matchValue_49.tag === 44) ? false : (nextSignificant.Span.Start.Column >= col)))))))))) {
|
|
2042
2044
|
doneBlock = true;
|
|
2043
2045
|
}
|
|
@@ -2079,7 +2081,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2079
2081
|
blockStatementColumn = TokenStream__Peek(stream).Span.Start.Column;
|
|
2080
2082
|
}
|
|
2081
2083
|
const expr_6 = parseExpr();
|
|
2082
|
-
void (statements.push(new Stmt(5, [expr_6])));
|
|
2084
|
+
void (statements.push(new Stmt(/* SExpr */ 5, [expr_6])));
|
|
2083
2085
|
break;
|
|
2084
2086
|
}
|
|
2085
2087
|
}
|
|
@@ -2095,9 +2097,9 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2095
2097
|
throw new ParseException(new ParseError("Block cannot end with a let binding; add a final expression", head_1(stmts).fields[6]));
|
|
2096
2098
|
}
|
|
2097
2099
|
else {
|
|
2098
|
-
const valExpr = foldBack_1((arg_5, acc_3) => (new Expr(4, [arg_5, acc_3, head_1(stmts).fields[6]])), head_1(stmts).fields[1], head_1(stmts).fields[3]);
|
|
2100
|
+
const valExpr = foldBack_1((arg_5, acc_3) => (new Expr(/* ELambda */ 4, [arg_5, acc_3, head_1(stmts).fields[6]])), head_1(stmts).fields[1], head_1(stmts).fields[3]);
|
|
2099
2101
|
const body_5 = desugar(tail_1(stmts));
|
|
2100
|
-
return new Expr(10, [head_1(stmts).fields[0], valExpr, body_5, head_1(stmts).fields[4], head_1(stmts).fields[2], mkSpanFrom(head_1(stmts).fields[6], Ast_spanOfExpr(body_5))]);
|
|
2102
|
+
return new Expr(/* ELet */ 10, [head_1(stmts).fields[0], valExpr, body_5, head_1(stmts).fields[4], head_1(stmts).fields[2], mkSpanFrom(head_1(stmts).fields[6], Ast_spanOfExpr(body_5))]);
|
|
2101
2103
|
}
|
|
2102
2104
|
case 3:
|
|
2103
2105
|
if (isEmpty(tail_1(stmts))) {
|
|
@@ -2105,7 +2107,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2105
2107
|
}
|
|
2106
2108
|
else {
|
|
2107
2109
|
const body_6 = desugar(tail_1(stmts));
|
|
2108
|
-
return new Expr(11, [head_1(stmts).fields[0], head_1(stmts).fields[1], body_6, mkSpanFrom(head_1(stmts).fields[3], Ast_spanOfExpr(body_6))]);
|
|
2110
|
+
return new Expr(/* ELetPattern */ 11, [head_1(stmts).fields[0], head_1(stmts).fields[1], body_6, mkSpanFrom(head_1(stmts).fields[3], Ast_spanOfExpr(body_6))]);
|
|
2109
2111
|
}
|
|
2110
2112
|
case 4:
|
|
2111
2113
|
if (isEmpty(tail_1(stmts))) {
|
|
@@ -2113,7 +2115,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2113
2115
|
}
|
|
2114
2116
|
else {
|
|
2115
2117
|
const body_7 = desugar(tail_1(stmts));
|
|
2116
|
-
return new Expr(12, [head_1(stmts).fields[0], body_7, mkSpanFrom(head_1(stmts).fields[2], Ast_spanOfExpr(body_7))]);
|
|
2118
|
+
return new Expr(/* ELetRecGroup */ 12, [head_1(stmts).fields[0], body_7, mkSpanFrom(head_1(stmts).fields[2], Ast_spanOfExpr(body_7))]);
|
|
2117
2119
|
}
|
|
2118
2120
|
case 0:
|
|
2119
2121
|
throw new ParseException(new ParseError("Type declarations are only supported at top level", head_1(stmts).fields[0].Span));
|
|
@@ -2125,23 +2127,23 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2125
2127
|
}
|
|
2126
2128
|
else {
|
|
2127
2129
|
const body_8 = desugar(tail_1(stmts));
|
|
2128
|
-
return new Expr(10, ["_", head_1(stmts).fields[0], body_8, false, undefined, mkSpanFrom(Ast_spanOfExpr(head_1(stmts).fields[0]), Ast_spanOfExpr(body_8))]);
|
|
2130
|
+
return new Expr(/* ELet */ 10, ["_", head_1(stmts).fields[0], body_8, false, undefined, mkSpanFrom(Ast_spanOfExpr(head_1(stmts).fields[0]), Ast_spanOfExpr(body_8))]);
|
|
2129
2131
|
}
|
|
2130
2132
|
}
|
|
2131
2133
|
}
|
|
2132
2134
|
else {
|
|
2133
|
-
return new Expr(0, [TokenStream__Peek(stream).Span]);
|
|
2135
|
+
return new Expr(/* EUnit */ 0, [TokenStream__Peek(stream).Span]);
|
|
2134
2136
|
}
|
|
2135
2137
|
};
|
|
2136
2138
|
return desugar(toList(statements));
|
|
2137
2139
|
};
|
|
2138
2140
|
const parseLetStmt = (isExported) => {
|
|
2139
|
-
let matchValue_52
|
|
2141
|
+
let matchValue_52;
|
|
2140
2142
|
const letTok_1 = TokenStream__Next(stream);
|
|
2141
|
-
const isRec_3 = TokenStream__Match_5CEB78CD(stream,
|
|
2143
|
+
const isRec_3 = TokenStream__Match_5CEB78CD(stream, TokenKind.Rec);
|
|
2142
2144
|
let patternInput_3;
|
|
2143
2145
|
if (isRec_3) {
|
|
2144
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
2146
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.LParen)) {
|
|
2145
2147
|
throw new ParseException(new ParseError("\'let rec\' does not support pattern bindings", TokenStream__Peek(stream).Span));
|
|
2146
2148
|
}
|
|
2147
2149
|
const nameTok_15 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'let\'");
|
|
@@ -2177,7 +2179,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2177
2179
|
const args_5 = patternInput_3[1];
|
|
2178
2180
|
TokenStream__SkipNewlines(stream);
|
|
2179
2181
|
let returnAnnotation_2;
|
|
2180
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
2182
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.Colon)) {
|
|
2181
2183
|
if (args_5.length === 0) {
|
|
2182
2184
|
throw new ParseException(new ParseError("Return type annotations are only supported on function let bindings", TokenStream__Peek(stream).Span));
|
|
2183
2185
|
}
|
|
@@ -2186,10 +2188,10 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2186
2188
|
else {
|
|
2187
2189
|
returnAnnotation_2 = undefined;
|
|
2188
2190
|
}
|
|
2189
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
2191
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.Colon)) {
|
|
2190
2192
|
throw new ParseException(new ParseError("Annotated parameters must be parenthesized as (x: T)", TokenStream__Peek(stream).Span));
|
|
2191
2193
|
}
|
|
2192
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
2194
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
|
|
2193
2195
|
const value_78 = parseExprOrBlock();
|
|
2194
2196
|
if (isRec_3) {
|
|
2195
2197
|
const bindings_2 = [];
|
|
@@ -2198,7 +2200,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2198
2200
|
let doneBindings_1 = false;
|
|
2199
2201
|
while (!doneBindings_1) {
|
|
2200
2202
|
TokenStream__SkipNewlines(stream);
|
|
2201
|
-
if (TokenStream__Match_5CEB78CD(stream,
|
|
2203
|
+
if (TokenStream__Match_5CEB78CD(stream, TokenKind.And)) {
|
|
2202
2204
|
const nextNameTok_1 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected identifier after \'and\'");
|
|
2203
2205
|
let nextName_1;
|
|
2204
2206
|
const matchValue_53 = nextNameTok_1.Kind;
|
|
@@ -2208,11 +2210,11 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2208
2210
|
throw new ParseException(new ParseError("\'let rec ... and ...\' requires function arguments for each binding", nextNameTok_1.Span));
|
|
2209
2211
|
}
|
|
2210
2212
|
TokenStream__SkipNewlines(stream);
|
|
2211
|
-
const nextReturnAnnotation_1 = TokenStream__Match_5CEB78CD(stream,
|
|
2212
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
2213
|
+
const nextReturnAnnotation_1 = TokenStream__Match_5CEB78CD(stream, TokenKind.Colon) ? parseTypeRef() : undefined;
|
|
2214
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.Colon)) {
|
|
2213
2215
|
throw new ParseException(new ParseError("Annotated parameters must be parenthesized as (x: T)", TokenStream__Peek(stream).Span));
|
|
2214
2216
|
}
|
|
2215
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
2217
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Equals, "Expected \'=\' in let binding");
|
|
2216
2218
|
const nextValue_1 = parseExprOrBlock();
|
|
2217
2219
|
const nextSpan_1 = mkSpanFrom(nextNameTok_1.Span, Ast_spanOfExpr(nextValue_1));
|
|
2218
2220
|
void (bindings_2.push([nextName_1, toList(nextArgs_1), nextReturnAnnotation_1, nextValue_1, nextSpan_1]));
|
|
@@ -2222,47 +2224,47 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2222
2224
|
}
|
|
2223
2225
|
}
|
|
2224
2226
|
if (bindings_2.length === 1) {
|
|
2225
|
-
return new Stmt(2, [bindingName_1, toList(args_5), returnAnnotation_2, value_78, true, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_78))]);
|
|
2227
|
+
return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_2, value_78, true, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_78))]);
|
|
2226
2228
|
}
|
|
2227
2229
|
else {
|
|
2228
2230
|
const patternInput_4 = item_1(bindings_2.length - 1, bindings_2);
|
|
2229
|
-
return new Stmt(4, [toList(bindings_2), isExported, mkSpanFrom(letTok_1.Span, patternInput_4[4])]);
|
|
2231
|
+
return new Stmt(/* SLetRecGroup */ 4, [toList(bindings_2), isExported, mkSpanFrom(letTok_1.Span, patternInput_4[4])]);
|
|
2230
2232
|
}
|
|
2231
2233
|
}
|
|
2232
2234
|
else if (tuplePatternOpt_1 == null) {
|
|
2233
|
-
return new Stmt(2, [bindingName_1, toList(args_5), returnAnnotation_2, value_78, false, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_78))]);
|
|
2235
|
+
return new Stmt(/* SLet */ 2, [bindingName_1, toList(args_5), returnAnnotation_2, value_78, false, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_78))]);
|
|
2234
2236
|
}
|
|
2235
|
-
else if (
|
|
2237
|
+
else if (args_5.length > 0) {
|
|
2236
2238
|
const pattern_9 = tuplePatternOpt_1;
|
|
2237
2239
|
throw new ParseException(new ParseError("Tuple let binding cannot take function parameters", Ast_spanOfPattern(pattern_9)));
|
|
2238
2240
|
}
|
|
2239
2241
|
else {
|
|
2240
2242
|
const pattern_10 = tuplePatternOpt_1;
|
|
2241
|
-
return new Stmt(3, [pattern_10, value_78, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_78))]);
|
|
2243
|
+
return new Stmt(/* SLetPattern */ 3, [pattern_10, value_78, isExported, mkSpanFrom(letTok_1.Span, Ast_spanOfExpr(value_78))]);
|
|
2242
2244
|
}
|
|
2243
2245
|
};
|
|
2244
2246
|
const parseAttributeName = () => {
|
|
2245
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
2246
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
2247
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.LBracket, "Expected \'[\' in attribute");
|
|
2248
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Less, "Expected \'<\' in attribute");
|
|
2247
2249
|
const nameTok_17 = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected attribute name");
|
|
2248
2250
|
let name_20;
|
|
2249
2251
|
const matchValue_54 = nameTok_17.Kind;
|
|
2250
2252
|
name_20 = ((matchValue_54.tag === 4) ? matchValue_54.fields[0] : "");
|
|
2251
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
2252
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
2253
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.Greater, "Expected \'>\' in attribute");
|
|
2254
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.RBracket, "Expected \']\' in attribute");
|
|
2253
2255
|
return [name_20, nameTok_17.Span];
|
|
2254
2256
|
};
|
|
2255
2257
|
const parseStmt = () => {
|
|
2256
2258
|
let matchValue_58;
|
|
2257
2259
|
TokenStream__SkipNewlines(stream);
|
|
2258
|
-
if (equals(TokenStream__Peek(stream).Kind, new TokenKind(4, ["export"])) && equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind,
|
|
2260
|
+
if (equals(TokenStream__Peek(stream).Kind, new TokenKind(/* Ident */ 4, ["export"])) && equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Let)) {
|
|
2259
2261
|
throw new ParseException(new ParseError("\'export let\' is no longer supported; use \'[<export>] let ...\'", TokenStream__Peek(stream).Span));
|
|
2260
2262
|
}
|
|
2261
2263
|
let isExported_1 = false;
|
|
2262
2264
|
let hasAttributes = false;
|
|
2263
2265
|
let parsingAttributes = true;
|
|
2264
2266
|
while (parsingAttributes) {
|
|
2265
|
-
if (equals(TokenStream__Peek(stream).Kind,
|
|
2267
|
+
if (equals(TokenStream__Peek(stream).Kind, TokenKind.LBracket) && equals(TokenStream__PeekAt_Z524259A4(stream, 1).Kind, TokenKind.Less)) {
|
|
2266
2268
|
hasAttributes = true;
|
|
2267
2269
|
const patternInput_5 = parseAttributeName();
|
|
2268
2270
|
const span_9 = patternInput_5[1];
|
|
@@ -2308,9 +2310,9 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2308
2310
|
const matchValue_57 = pathTok.Kind;
|
|
2309
2311
|
if (matchValue_57.tag === 7) {
|
|
2310
2312
|
if (!isNullOrWhiteSpace(matchValue_57.fields[0])) {
|
|
2311
|
-
TokenStream__Expect_77B9EE56(stream,
|
|
2313
|
+
TokenStream__Expect_77B9EE56(stream, TokenKind.As, "Expected \'as\' in import directive. Use: import \"file.fss\" as Alias");
|
|
2312
2314
|
const aliasTok = TokenStream__ExpectIdent_Z721C83C5(stream, "Expected module alias after \'as\'");
|
|
2313
|
-
return new Stmt(1, [(matchValue_58 = aliasTok.Kind, (matchValue_58.tag === 4) ? matchValue_58.fields[0] : ""), matchValue_57.fields[0], mkSpanFrom(importTok.Span, aliasTok.Span)]);
|
|
2315
|
+
return new Stmt(/* SImport */ 1, [(matchValue_58 = aliasTok.Kind, (matchValue_58.tag === 4) ? matchValue_58.fields[0] : ""), matchValue_57.fields[0], mkSpanFrom(importTok.Span, aliasTok.Span)]);
|
|
2314
2316
|
}
|
|
2315
2317
|
else {
|
|
2316
2318
|
throw new ParseException(new ParseError("Import path cannot be empty", pathTok.Span));
|
|
@@ -2335,7 +2337,7 @@ export function parseProgramWithSourceName(sourceName, src) {
|
|
|
2335
2337
|
throw new ParseException(new ParseError("\'[<export>]\' must be followed by a top-level let binding", TokenStream__Peek(stream).Span));
|
|
2336
2338
|
}
|
|
2337
2339
|
else {
|
|
2338
|
-
return new Stmt(5, [parseExpr()]);
|
|
2340
|
+
return new Stmt(/* SExpr */ 5, [parseExpr()]);
|
|
2339
2341
|
}
|
|
2340
2342
|
}
|
|
2341
2343
|
};
|