parser-lr 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/parser-lr.js +110 -823
- package/bin/parser-lr.js.map +1 -1
- package/dist/lib/grammar/grammar-from-cst.js +4 -1
- package/dist/lib/grammar/grammar-from-cst.js.map +1 -1
- package/dist/lib/grammar/grammar.json +86 -820
- package/dist/lib/grammar/table-validator.d.ts.map +1 -1
- package/dist/lib/grammar/table-validator.js +19 -1
- package/dist/lib/grammar/table-validator.js.map +1 -1
- package/docs/The Ferrite Programming Language.md +568 -0
- package/docs/grammar.md +55 -3
- package/grammars/6502.grammar +2 -2
- package/grammars/ferrite.grammar +107 -97
- package/grammars/grammar.grammar +19 -140
- package/grammars/lisp.grammar +3 -2
- package/package.json +1 -1
package/bin/parser-lr.js
CHANGED
|
@@ -3781,7 +3781,7 @@ const {
|
|
|
3781
3781
|
Help,
|
|
3782
3782
|
} = commander;
|
|
3783
3783
|
|
|
3784
|
-
var version$1 = "0.
|
|
3784
|
+
var version$1 = "0.8.0";
|
|
3785
3785
|
var packageDefinition = {
|
|
3786
3786
|
version: version$1};
|
|
3787
3787
|
|
|
@@ -8241,8 +8241,11 @@ function parseExpressionNode(node) {
|
|
|
8241
8241
|
* @param node - `choice` CST node.
|
|
8242
8242
|
*/
|
|
8243
8243
|
function parseChoice(node) {
|
|
8244
|
+
// Parse each labeled or unlabeled alternative.
|
|
8244
8245
|
const alternatives = collectAlternatives(node).map(parseLabeledAlternative);
|
|
8245
|
-
|
|
8246
|
+
// Collapse a sole unlabeled alternative; keep labeled singles as a choice
|
|
8247
|
+
// so AST / transform variants remain visible to validation and consumers.
|
|
8248
|
+
if (alternatives.length === 1 && alternatives[0].label === null) {
|
|
8246
8249
|
return alternatives[0].expression;
|
|
8247
8250
|
}
|
|
8248
8251
|
return {
|
|
@@ -13126,134 +13129,35 @@ var gotos = [
|
|
|
13126
13129
|
var ast = [
|
|
13127
13130
|
{
|
|
13128
13131
|
name: "grammar_file",
|
|
13129
|
-
expression: {
|
|
13130
|
-
kind: "sequence",
|
|
13131
|
-
elements: [
|
|
13132
|
-
{
|
|
13133
|
-
kind: "reference",
|
|
13134
|
-
name: "name_decl"
|
|
13135
|
-
},
|
|
13136
|
-
{
|
|
13137
|
-
kind: "repeat",
|
|
13138
|
-
element: {
|
|
13139
|
-
kind: "reference",
|
|
13140
|
-
name: "section"
|
|
13141
|
-
}
|
|
13142
|
-
},
|
|
13143
|
-
{
|
|
13144
|
-
kind: "reference",
|
|
13145
|
-
name: "start_decl"
|
|
13146
|
-
},
|
|
13147
|
-
{
|
|
13148
|
-
kind: "reference",
|
|
13149
|
-
name: "grammar_section"
|
|
13150
|
-
},
|
|
13151
|
-
{
|
|
13152
|
-
kind: "optional",
|
|
13153
|
-
element: {
|
|
13154
|
-
kind: "reference",
|
|
13155
|
-
name: "ast_section"
|
|
13156
|
-
}
|
|
13157
|
-
},
|
|
13158
|
-
{
|
|
13159
|
-
kind: "optional",
|
|
13160
|
-
element: {
|
|
13161
|
-
kind: "reference",
|
|
13162
|
-
name: "transform_section"
|
|
13163
|
-
}
|
|
13164
|
-
}
|
|
13165
|
-
]
|
|
13166
|
-
}
|
|
13167
|
-
},
|
|
13168
|
-
{
|
|
13169
|
-
name: "name_decl",
|
|
13170
|
-
expression: {
|
|
13171
|
-
kind: "sequence",
|
|
13172
|
-
elements: [
|
|
13173
|
-
{
|
|
13174
|
-
kind: "reference",
|
|
13175
|
-
name: "name_kw"
|
|
13176
|
-
},
|
|
13177
|
-
{
|
|
13178
|
-
kind: "reference",
|
|
13179
|
-
name: "grammar_name"
|
|
13180
|
-
},
|
|
13181
|
-
{
|
|
13182
|
-
kind: "reference",
|
|
13183
|
-
name: "semicolon"
|
|
13184
|
-
}
|
|
13185
|
-
]
|
|
13186
|
-
}
|
|
13187
|
-
},
|
|
13188
|
-
{
|
|
13189
|
-
name: "grammar_name",
|
|
13190
13132
|
expression: {
|
|
13191
13133
|
kind: "choice",
|
|
13192
13134
|
alternatives: [
|
|
13193
13135
|
{
|
|
13194
|
-
label:
|
|
13136
|
+
label: "sections",
|
|
13195
13137
|
expression: {
|
|
13196
|
-
kind: "
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
label: null,
|
|
13202
|
-
expression: {
|
|
13203
|
-
kind: "reference",
|
|
13204
|
-
name: "string_literal"
|
|
13138
|
+
kind: "repeat",
|
|
13139
|
+
element: {
|
|
13140
|
+
kind: "reference",
|
|
13141
|
+
name: "section"
|
|
13142
|
+
}
|
|
13205
13143
|
}
|
|
13206
13144
|
}
|
|
13207
13145
|
]
|
|
13208
13146
|
}
|
|
13209
13147
|
},
|
|
13210
13148
|
{
|
|
13211
|
-
name: "
|
|
13149
|
+
name: "token_section",
|
|
13212
13150
|
expression: {
|
|
13213
13151
|
kind: "choice",
|
|
13214
13152
|
alternatives: [
|
|
13215
13153
|
{
|
|
13216
|
-
label:
|
|
13154
|
+
label: "definitions",
|
|
13217
13155
|
expression: {
|
|
13218
|
-
kind: "
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
|
|
13222
|
-
|
|
13223
|
-
label: null,
|
|
13224
|
-
expression: {
|
|
13225
|
-
kind: "reference",
|
|
13226
|
-
name: "skip_section"
|
|
13227
|
-
}
|
|
13228
|
-
},
|
|
13229
|
-
{
|
|
13230
|
-
label: null,
|
|
13231
|
-
expression: {
|
|
13232
|
-
kind: "reference",
|
|
13233
|
-
name: "states_section"
|
|
13234
|
-
}
|
|
13235
|
-
}
|
|
13236
|
-
]
|
|
13237
|
-
}
|
|
13238
|
-
},
|
|
13239
|
-
{
|
|
13240
|
-
name: "token_section",
|
|
13241
|
-
expression: {
|
|
13242
|
-
kind: "sequence",
|
|
13243
|
-
elements: [
|
|
13244
|
-
{
|
|
13245
|
-
kind: "reference",
|
|
13246
|
-
name: "tokens_kw"
|
|
13247
|
-
},
|
|
13248
|
-
{
|
|
13249
|
-
kind: "reference",
|
|
13250
|
-
name: "token_def"
|
|
13251
|
-
},
|
|
13252
|
-
{
|
|
13253
|
-
kind: "repeat",
|
|
13254
|
-
element: {
|
|
13255
|
-
kind: "reference",
|
|
13256
|
-
name: "token_def"
|
|
13156
|
+
kind: "repeat",
|
|
13157
|
+
element: {
|
|
13158
|
+
kind: "reference",
|
|
13159
|
+
name: "token_def"
|
|
13160
|
+
}
|
|
13257
13161
|
}
|
|
13258
13162
|
}
|
|
13259
13163
|
]
|
|
@@ -13262,109 +13166,17 @@ var ast = [
|
|
|
13262
13166
|
{
|
|
13263
13167
|
name: "skip_section",
|
|
13264
13168
|
expression: {
|
|
13265
|
-
kind: "
|
|
13266
|
-
|
|
13267
|
-
{
|
|
13268
|
-
kind: "reference",
|
|
13269
|
-
name: "skip_kw"
|
|
13270
|
-
},
|
|
13271
|
-
{
|
|
13272
|
-
kind: "reference",
|
|
13273
|
-
name: "token_def"
|
|
13274
|
-
},
|
|
13275
|
-
{
|
|
13276
|
-
kind: "repeat",
|
|
13277
|
-
element: {
|
|
13278
|
-
kind: "reference",
|
|
13279
|
-
name: "token_def"
|
|
13280
|
-
}
|
|
13281
|
-
}
|
|
13282
|
-
]
|
|
13283
|
-
}
|
|
13284
|
-
},
|
|
13285
|
-
{
|
|
13286
|
-
name: "states_section",
|
|
13287
|
-
expression: {
|
|
13288
|
-
kind: "sequence",
|
|
13289
|
-
elements: [
|
|
13290
|
-
{
|
|
13291
|
-
kind: "reference",
|
|
13292
|
-
name: "states_kw"
|
|
13293
|
-
},
|
|
13294
|
-
{
|
|
13295
|
-
kind: "reference",
|
|
13296
|
-
name: "state_name"
|
|
13297
|
-
},
|
|
13169
|
+
kind: "choice",
|
|
13170
|
+
alternatives: [
|
|
13298
13171
|
{
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
kind: "
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
},
|
|
13307
|
-
{
|
|
13308
|
-
kind: "reference",
|
|
13309
|
-
name: "state_name"
|
|
13310
|
-
}
|
|
13311
|
-
]
|
|
13172
|
+
label: "definitions",
|
|
13173
|
+
expression: {
|
|
13174
|
+
kind: "repeat",
|
|
13175
|
+
element: {
|
|
13176
|
+
kind: "reference",
|
|
13177
|
+
name: "token_def"
|
|
13178
|
+
}
|
|
13312
13179
|
}
|
|
13313
|
-
},
|
|
13314
|
-
{
|
|
13315
|
-
kind: "reference",
|
|
13316
|
-
name: "semicolon"
|
|
13317
|
-
}
|
|
13318
|
-
]
|
|
13319
|
-
}
|
|
13320
|
-
},
|
|
13321
|
-
{
|
|
13322
|
-
name: "token_def",
|
|
13323
|
-
expression: {
|
|
13324
|
-
kind: "sequence",
|
|
13325
|
-
elements: [
|
|
13326
|
-
{
|
|
13327
|
-
kind: "reference",
|
|
13328
|
-
name: "identifier"
|
|
13329
|
-
},
|
|
13330
|
-
{
|
|
13331
|
-
kind: "reference",
|
|
13332
|
-
name: "equal"
|
|
13333
|
-
},
|
|
13334
|
-
{
|
|
13335
|
-
kind: "reference",
|
|
13336
|
-
name: "regex_literal"
|
|
13337
|
-
},
|
|
13338
|
-
{
|
|
13339
|
-
kind: "reference",
|
|
13340
|
-
name: "semicolon"
|
|
13341
|
-
}
|
|
13342
|
-
]
|
|
13343
|
-
}
|
|
13344
|
-
},
|
|
13345
|
-
{
|
|
13346
|
-
name: "state_name",
|
|
13347
|
-
expression: {
|
|
13348
|
-
kind: "reference",
|
|
13349
|
-
name: "identifier"
|
|
13350
|
-
}
|
|
13351
|
-
},
|
|
13352
|
-
{
|
|
13353
|
-
name: "start_decl",
|
|
13354
|
-
expression: {
|
|
13355
|
-
kind: "sequence",
|
|
13356
|
-
elements: [
|
|
13357
|
-
{
|
|
13358
|
-
kind: "reference",
|
|
13359
|
-
name: "start_kw"
|
|
13360
|
-
},
|
|
13361
|
-
{
|
|
13362
|
-
kind: "reference",
|
|
13363
|
-
name: "identifier"
|
|
13364
|
-
},
|
|
13365
|
-
{
|
|
13366
|
-
kind: "reference",
|
|
13367
|
-
name: "semicolon"
|
|
13368
13180
|
}
|
|
13369
13181
|
]
|
|
13370
13182
|
}
|
|
@@ -13372,21 +13184,16 @@ var ast = [
|
|
|
13372
13184
|
{
|
|
13373
13185
|
name: "grammar_section",
|
|
13374
13186
|
expression: {
|
|
13375
|
-
kind: "
|
|
13376
|
-
|
|
13377
|
-
{
|
|
13378
|
-
kind: "reference",
|
|
13379
|
-
name: "grammar_kw"
|
|
13380
|
-
},
|
|
13381
|
-
{
|
|
13382
|
-
kind: "reference",
|
|
13383
|
-
name: "production"
|
|
13384
|
-
},
|
|
13187
|
+
kind: "choice",
|
|
13188
|
+
alternatives: [
|
|
13385
13189
|
{
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
kind: "
|
|
13389
|
-
|
|
13190
|
+
label: "productions",
|
|
13191
|
+
expression: {
|
|
13192
|
+
kind: "repeat",
|
|
13193
|
+
element: {
|
|
13194
|
+
kind: "reference",
|
|
13195
|
+
name: "production"
|
|
13196
|
+
}
|
|
13390
13197
|
}
|
|
13391
13198
|
}
|
|
13392
13199
|
]
|
|
@@ -13395,21 +13202,16 @@ var ast = [
|
|
|
13395
13202
|
{
|
|
13396
13203
|
name: "ast_section",
|
|
13397
13204
|
expression: {
|
|
13398
|
-
kind: "
|
|
13399
|
-
|
|
13400
|
-
{
|
|
13401
|
-
kind: "reference",
|
|
13402
|
-
name: "ast_kw"
|
|
13403
|
-
},
|
|
13404
|
-
{
|
|
13405
|
-
kind: "reference",
|
|
13406
|
-
name: "ast_type"
|
|
13407
|
-
},
|
|
13205
|
+
kind: "choice",
|
|
13206
|
+
alternatives: [
|
|
13408
13207
|
{
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
kind: "
|
|
13412
|
-
|
|
13208
|
+
label: "types",
|
|
13209
|
+
expression: {
|
|
13210
|
+
kind: "repeat",
|
|
13211
|
+
element: {
|
|
13212
|
+
kind: "reference",
|
|
13213
|
+
name: "ast_type"
|
|
13214
|
+
}
|
|
13413
13215
|
}
|
|
13414
13216
|
}
|
|
13415
13217
|
]
|
|
@@ -13418,621 +13220,88 @@ var ast = [
|
|
|
13418
13220
|
{
|
|
13419
13221
|
name: "transform_section",
|
|
13420
13222
|
expression: {
|
|
13421
|
-
kind: "
|
|
13422
|
-
|
|
13423
|
-
{
|
|
13424
|
-
kind: "reference",
|
|
13425
|
-
name: "transform_kw"
|
|
13426
|
-
},
|
|
13427
|
-
{
|
|
13428
|
-
kind: "reference",
|
|
13429
|
-
name: "transform_rule"
|
|
13430
|
-
},
|
|
13223
|
+
kind: "choice",
|
|
13224
|
+
alternatives: [
|
|
13431
13225
|
{
|
|
13432
|
-
|
|
13433
|
-
|
|
13434
|
-
kind: "
|
|
13435
|
-
|
|
13226
|
+
label: "rules",
|
|
13227
|
+
expression: {
|
|
13228
|
+
kind: "repeat",
|
|
13229
|
+
element: {
|
|
13230
|
+
kind: "reference",
|
|
13231
|
+
name: "transform_rule"
|
|
13232
|
+
}
|
|
13436
13233
|
}
|
|
13437
13234
|
}
|
|
13438
13235
|
]
|
|
13439
13236
|
}
|
|
13440
13237
|
},
|
|
13441
|
-
{
|
|
13442
|
-
name: "production",
|
|
13443
|
-
expression: {
|
|
13444
|
-
kind: "sequence",
|
|
13445
|
-
elements: [
|
|
13446
|
-
{
|
|
13447
|
-
kind: "reference",
|
|
13448
|
-
name: "identifier"
|
|
13449
|
-
},
|
|
13450
|
-
{
|
|
13451
|
-
kind: "reference",
|
|
13452
|
-
name: "equal"
|
|
13453
|
-
},
|
|
13454
|
-
{
|
|
13455
|
-
kind: "reference",
|
|
13456
|
-
name: "expression"
|
|
13457
|
-
},
|
|
13458
|
-
{
|
|
13459
|
-
kind: "reference",
|
|
13460
|
-
name: "semicolon"
|
|
13461
|
-
}
|
|
13462
|
-
]
|
|
13463
|
-
}
|
|
13464
|
-
},
|
|
13465
|
-
{
|
|
13466
|
-
name: "ast_type",
|
|
13467
|
-
expression: {
|
|
13468
|
-
kind: "sequence",
|
|
13469
|
-
elements: [
|
|
13470
|
-
{
|
|
13471
|
-
kind: "reference",
|
|
13472
|
-
name: "identifier"
|
|
13473
|
-
},
|
|
13474
|
-
{
|
|
13475
|
-
kind: "reference",
|
|
13476
|
-
name: "equal"
|
|
13477
|
-
},
|
|
13478
|
-
{
|
|
13479
|
-
kind: "reference",
|
|
13480
|
-
name: "expression"
|
|
13481
|
-
},
|
|
13482
|
-
{
|
|
13483
|
-
kind: "reference",
|
|
13484
|
-
name: "semicolon"
|
|
13485
|
-
}
|
|
13486
|
-
]
|
|
13487
|
-
}
|
|
13488
|
-
},
|
|
13489
13238
|
{
|
|
13490
13239
|
name: "transform_rule",
|
|
13491
|
-
expression: {
|
|
13492
|
-
kind: "sequence",
|
|
13493
|
-
elements: [
|
|
13494
|
-
{
|
|
13495
|
-
kind: "reference",
|
|
13496
|
-
name: "identifier"
|
|
13497
|
-
},
|
|
13498
|
-
{
|
|
13499
|
-
kind: "reference",
|
|
13500
|
-
name: "arrow"
|
|
13501
|
-
},
|
|
13502
|
-
{
|
|
13503
|
-
kind: "reference",
|
|
13504
|
-
name: "labeled_transform"
|
|
13505
|
-
},
|
|
13506
|
-
{
|
|
13507
|
-
kind: "repeat",
|
|
13508
|
-
element: {
|
|
13509
|
-
kind: "sequence",
|
|
13510
|
-
elements: [
|
|
13511
|
-
{
|
|
13512
|
-
kind: "reference",
|
|
13513
|
-
name: "bar"
|
|
13514
|
-
},
|
|
13515
|
-
{
|
|
13516
|
-
kind: "reference",
|
|
13517
|
-
name: "labeled_transform"
|
|
13518
|
-
}
|
|
13519
|
-
]
|
|
13520
|
-
}
|
|
13521
|
-
},
|
|
13522
|
-
{
|
|
13523
|
-
kind: "reference",
|
|
13524
|
-
name: "semicolon"
|
|
13525
|
-
}
|
|
13526
|
-
]
|
|
13527
|
-
}
|
|
13528
|
-
},
|
|
13529
|
-
{
|
|
13530
|
-
name: "labeled_transform",
|
|
13531
|
-
expression: {
|
|
13532
|
-
kind: "sequence",
|
|
13533
|
-
elements: [
|
|
13534
|
-
{
|
|
13535
|
-
kind: "reference",
|
|
13536
|
-
name: "hash"
|
|
13537
|
-
},
|
|
13538
|
-
{
|
|
13539
|
-
kind: "reference",
|
|
13540
|
-
name: "identifier"
|
|
13541
|
-
},
|
|
13542
|
-
{
|
|
13543
|
-
kind: "reference",
|
|
13544
|
-
name: "transform_expr"
|
|
13545
|
-
}
|
|
13546
|
-
]
|
|
13547
|
-
}
|
|
13548
|
-
},
|
|
13549
|
-
{
|
|
13550
|
-
name: "transform_expr",
|
|
13551
13240
|
expression: {
|
|
13552
13241
|
kind: "choice",
|
|
13553
13242
|
alternatives: [
|
|
13554
13243
|
{
|
|
13555
|
-
label:
|
|
13556
|
-
expression: {
|
|
13557
|
-
kind: "reference",
|
|
13558
|
-
name: "drop_kw"
|
|
13559
|
-
}
|
|
13560
|
-
},
|
|
13561
|
-
{
|
|
13562
|
-
label: null,
|
|
13244
|
+
label: "alternatives",
|
|
13563
13245
|
expression: {
|
|
13564
|
-
kind: "
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
label: null,
|
|
13570
|
-
expression: {
|
|
13571
|
-
kind: "reference",
|
|
13572
|
-
name: "fold_left_expr"
|
|
13573
|
-
}
|
|
13574
|
-
},
|
|
13575
|
-
{
|
|
13576
|
-
label: null,
|
|
13577
|
-
expression: {
|
|
13578
|
-
kind: "reference",
|
|
13579
|
-
name: "fold_right_expr"
|
|
13580
|
-
}
|
|
13581
|
-
},
|
|
13582
|
-
{
|
|
13583
|
-
label: null,
|
|
13584
|
-
expression: {
|
|
13585
|
-
kind: "reference",
|
|
13586
|
-
name: "flatten_expr"
|
|
13587
|
-
}
|
|
13588
|
-
},
|
|
13589
|
-
{
|
|
13590
|
-
label: null,
|
|
13591
|
-
expression: {
|
|
13592
|
-
kind: "reference",
|
|
13593
|
-
name: "build_expr"
|
|
13594
|
-
}
|
|
13595
|
-
}
|
|
13596
|
-
]
|
|
13597
|
-
}
|
|
13598
|
-
},
|
|
13599
|
-
{
|
|
13600
|
-
name: "pass_expr",
|
|
13601
|
-
expression: {
|
|
13602
|
-
kind: "sequence",
|
|
13603
|
-
elements: [
|
|
13604
|
-
{
|
|
13605
|
-
kind: "reference",
|
|
13606
|
-
name: "pass_kw"
|
|
13607
|
-
},
|
|
13608
|
-
{
|
|
13609
|
-
kind: "reference",
|
|
13610
|
-
name: "lpar"
|
|
13611
|
-
},
|
|
13612
|
-
{
|
|
13613
|
-
kind: "reference",
|
|
13614
|
-
name: "reference"
|
|
13615
|
-
},
|
|
13616
|
-
{
|
|
13617
|
-
kind: "reference",
|
|
13618
|
-
name: "rpar"
|
|
13619
|
-
}
|
|
13620
|
-
]
|
|
13621
|
-
}
|
|
13622
|
-
},
|
|
13623
|
-
{
|
|
13624
|
-
name: "fold_left_expr",
|
|
13625
|
-
expression: {
|
|
13626
|
-
kind: "sequence",
|
|
13627
|
-
elements: [
|
|
13628
|
-
{
|
|
13629
|
-
kind: "reference",
|
|
13630
|
-
name: "fold_left_kw"
|
|
13631
|
-
},
|
|
13632
|
-
{
|
|
13633
|
-
kind: "reference",
|
|
13634
|
-
name: "lpar"
|
|
13635
|
-
},
|
|
13636
|
-
{
|
|
13637
|
-
kind: "reference",
|
|
13638
|
-
name: "build_target"
|
|
13639
|
-
},
|
|
13640
|
-
{
|
|
13641
|
-
kind: "reference",
|
|
13642
|
-
name: "comma"
|
|
13643
|
-
},
|
|
13644
|
-
{
|
|
13645
|
-
kind: "reference",
|
|
13646
|
-
name: "reference_list"
|
|
13647
|
-
},
|
|
13648
|
-
{
|
|
13649
|
-
kind: "reference",
|
|
13650
|
-
name: "rpar"
|
|
13651
|
-
}
|
|
13652
|
-
]
|
|
13653
|
-
}
|
|
13654
|
-
},
|
|
13655
|
-
{
|
|
13656
|
-
name: "fold_right_expr",
|
|
13657
|
-
expression: {
|
|
13658
|
-
kind: "sequence",
|
|
13659
|
-
elements: [
|
|
13660
|
-
{
|
|
13661
|
-
kind: "reference",
|
|
13662
|
-
name: "fold_right_kw"
|
|
13663
|
-
},
|
|
13664
|
-
{
|
|
13665
|
-
kind: "reference",
|
|
13666
|
-
name: "lpar"
|
|
13667
|
-
},
|
|
13668
|
-
{
|
|
13669
|
-
kind: "reference",
|
|
13670
|
-
name: "build_target"
|
|
13671
|
-
},
|
|
13672
|
-
{
|
|
13673
|
-
kind: "reference",
|
|
13674
|
-
name: "comma"
|
|
13675
|
-
},
|
|
13676
|
-
{
|
|
13677
|
-
kind: "reference",
|
|
13678
|
-
name: "reference_list"
|
|
13679
|
-
},
|
|
13680
|
-
{
|
|
13681
|
-
kind: "reference",
|
|
13682
|
-
name: "rpar"
|
|
13683
|
-
}
|
|
13684
|
-
]
|
|
13685
|
-
}
|
|
13686
|
-
},
|
|
13687
|
-
{
|
|
13688
|
-
name: "flatten_expr",
|
|
13689
|
-
expression: {
|
|
13690
|
-
kind: "sequence",
|
|
13691
|
-
elements: [
|
|
13692
|
-
{
|
|
13693
|
-
kind: "reference",
|
|
13694
|
-
name: "flatten_kw"
|
|
13695
|
-
},
|
|
13696
|
-
{
|
|
13697
|
-
kind: "reference",
|
|
13698
|
-
name: "lpar"
|
|
13699
|
-
},
|
|
13700
|
-
{
|
|
13701
|
-
kind: "reference",
|
|
13702
|
-
name: "build_target"
|
|
13703
|
-
},
|
|
13704
|
-
{
|
|
13705
|
-
kind: "reference",
|
|
13706
|
-
name: "comma"
|
|
13707
|
-
},
|
|
13708
|
-
{
|
|
13709
|
-
kind: "reference",
|
|
13710
|
-
name: "reference"
|
|
13711
|
-
},
|
|
13712
|
-
{
|
|
13713
|
-
kind: "reference",
|
|
13714
|
-
name: "comma"
|
|
13715
|
-
},
|
|
13716
|
-
{
|
|
13717
|
-
kind: "reference",
|
|
13718
|
-
name: "reference"
|
|
13719
|
-
},
|
|
13720
|
-
{
|
|
13721
|
-
kind: "reference",
|
|
13722
|
-
name: "rpar"
|
|
13723
|
-
}
|
|
13724
|
-
]
|
|
13725
|
-
}
|
|
13726
|
-
},
|
|
13727
|
-
{
|
|
13728
|
-
name: "build_expr",
|
|
13729
|
-
expression: {
|
|
13730
|
-
kind: "sequence",
|
|
13731
|
-
elements: [
|
|
13732
|
-
{
|
|
13733
|
-
kind: "reference",
|
|
13734
|
-
name: "build_target"
|
|
13735
|
-
},
|
|
13736
|
-
{
|
|
13737
|
-
kind: "optional",
|
|
13738
|
-
element: {
|
|
13739
|
-
kind: "sequence",
|
|
13740
|
-
elements: [
|
|
13741
|
-
{
|
|
13742
|
-
kind: "reference",
|
|
13743
|
-
name: "lpar"
|
|
13744
|
-
},
|
|
13745
|
-
{
|
|
13746
|
-
kind: "reference",
|
|
13747
|
-
name: "reference_list"
|
|
13748
|
-
},
|
|
13749
|
-
{
|
|
13750
|
-
kind: "reference",
|
|
13751
|
-
name: "rpar"
|
|
13752
|
-
}
|
|
13753
|
-
]
|
|
13246
|
+
kind: "repeat",
|
|
13247
|
+
element: {
|
|
13248
|
+
kind: "reference",
|
|
13249
|
+
name: "labeled_transform"
|
|
13250
|
+
}
|
|
13754
13251
|
}
|
|
13755
13252
|
}
|
|
13756
13253
|
]
|
|
13757
13254
|
}
|
|
13758
13255
|
},
|
|
13759
|
-
{
|
|
13760
|
-
name: "build_target",
|
|
13761
|
-
expression: {
|
|
13762
|
-
kind: "sequence",
|
|
13763
|
-
elements: [
|
|
13764
|
-
{
|
|
13765
|
-
kind: "reference",
|
|
13766
|
-
name: "identifier"
|
|
13767
|
-
},
|
|
13768
|
-
{
|
|
13769
|
-
kind: "reference",
|
|
13770
|
-
name: "dot"
|
|
13771
|
-
},
|
|
13772
|
-
{
|
|
13773
|
-
kind: "reference",
|
|
13774
|
-
name: "hash"
|
|
13775
|
-
},
|
|
13776
|
-
{
|
|
13777
|
-
kind: "reference",
|
|
13778
|
-
name: "identifier"
|
|
13779
|
-
}
|
|
13780
|
-
]
|
|
13781
|
-
}
|
|
13782
|
-
},
|
|
13783
13256
|
{
|
|
13784
13257
|
name: "reference_list",
|
|
13785
13258
|
expression: {
|
|
13786
|
-
kind: "
|
|
13787
|
-
|
|
13788
|
-
{
|
|
13789
|
-
kind: "reference",
|
|
13790
|
-
name: "reference"
|
|
13791
|
-
},
|
|
13259
|
+
kind: "choice",
|
|
13260
|
+
alternatives: [
|
|
13792
13261
|
{
|
|
13793
|
-
|
|
13794
|
-
|
|
13795
|
-
kind: "
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
},
|
|
13801
|
-
{
|
|
13802
|
-
kind: "reference",
|
|
13803
|
-
name: "reference"
|
|
13804
|
-
}
|
|
13805
|
-
]
|
|
13262
|
+
label: "references",
|
|
13263
|
+
expression: {
|
|
13264
|
+
kind: "repeat",
|
|
13265
|
+
element: {
|
|
13266
|
+
kind: "reference",
|
|
13267
|
+
name: "reference"
|
|
13268
|
+
}
|
|
13806
13269
|
}
|
|
13807
13270
|
}
|
|
13808
13271
|
]
|
|
13809
13272
|
}
|
|
13810
13273
|
},
|
|
13811
|
-
{
|
|
13812
|
-
name: "reference",
|
|
13813
|
-
expression: {
|
|
13814
|
-
kind: "reference",
|
|
13815
|
-
name: "identifier"
|
|
13816
|
-
}
|
|
13817
|
-
},
|
|
13818
|
-
{
|
|
13819
|
-
name: "expression",
|
|
13820
|
-
expression: {
|
|
13821
|
-
kind: "reference",
|
|
13822
|
-
name: "choice"
|
|
13823
|
-
}
|
|
13824
|
-
},
|
|
13825
13274
|
{
|
|
13826
13275
|
name: "choice",
|
|
13827
|
-
expression: {
|
|
13828
|
-
kind: "sequence",
|
|
13829
|
-
elements: [
|
|
13830
|
-
{
|
|
13831
|
-
kind: "reference",
|
|
13832
|
-
name: "alternative"
|
|
13833
|
-
},
|
|
13834
|
-
{
|
|
13835
|
-
kind: "repeat",
|
|
13836
|
-
element: {
|
|
13837
|
-
kind: "sequence",
|
|
13838
|
-
elements: [
|
|
13839
|
-
{
|
|
13840
|
-
kind: "reference",
|
|
13841
|
-
name: "bar"
|
|
13842
|
-
},
|
|
13843
|
-
{
|
|
13844
|
-
kind: "reference",
|
|
13845
|
-
name: "alternative"
|
|
13846
|
-
}
|
|
13847
|
-
]
|
|
13848
|
-
}
|
|
13849
|
-
}
|
|
13850
|
-
]
|
|
13851
|
-
}
|
|
13852
|
-
},
|
|
13853
|
-
{
|
|
13854
|
-
name: "alternative",
|
|
13855
|
-
expression: {
|
|
13856
|
-
kind: "reference",
|
|
13857
|
-
name: "labeled_alternative"
|
|
13858
|
-
}
|
|
13859
|
-
},
|
|
13860
|
-
{
|
|
13861
|
-
name: "labeled_alternative",
|
|
13862
|
-
expression: {
|
|
13863
|
-
kind: "sequence",
|
|
13864
|
-
elements: [
|
|
13865
|
-
{
|
|
13866
|
-
kind: "optional",
|
|
13867
|
-
element: {
|
|
13868
|
-
kind: "sequence",
|
|
13869
|
-
elements: [
|
|
13870
|
-
{
|
|
13871
|
-
kind: "reference",
|
|
13872
|
-
name: "hash"
|
|
13873
|
-
},
|
|
13874
|
-
{
|
|
13875
|
-
kind: "reference",
|
|
13876
|
-
name: "identifier"
|
|
13877
|
-
}
|
|
13878
|
-
]
|
|
13879
|
-
}
|
|
13880
|
-
},
|
|
13881
|
-
{
|
|
13882
|
-
kind: "reference",
|
|
13883
|
-
name: "sequence"
|
|
13884
|
-
}
|
|
13885
|
-
]
|
|
13886
|
-
}
|
|
13887
|
-
},
|
|
13888
|
-
{
|
|
13889
|
-
name: "sequence",
|
|
13890
|
-
expression: {
|
|
13891
|
-
kind: "sequence",
|
|
13892
|
-
elements: [
|
|
13893
|
-
{
|
|
13894
|
-
kind: "reference",
|
|
13895
|
-
name: "factor"
|
|
13896
|
-
},
|
|
13897
|
-
{
|
|
13898
|
-
kind: "repeat",
|
|
13899
|
-
element: {
|
|
13900
|
-
kind: "reference",
|
|
13901
|
-
name: "factor"
|
|
13902
|
-
}
|
|
13903
|
-
}
|
|
13904
|
-
]
|
|
13905
|
-
}
|
|
13906
|
-
},
|
|
13907
|
-
{
|
|
13908
|
-
name: "factor",
|
|
13909
13276
|
expression: {
|
|
13910
13277
|
kind: "choice",
|
|
13911
13278
|
alternatives: [
|
|
13912
13279
|
{
|
|
13913
|
-
label:
|
|
13280
|
+
label: "alternatives",
|
|
13914
13281
|
expression: {
|
|
13915
|
-
kind: "
|
|
13916
|
-
|
|
13917
|
-
|
|
13918
|
-
|
|
13919
|
-
|
|
13920
|
-
label: null,
|
|
13921
|
-
expression: {
|
|
13922
|
-
kind: "reference",
|
|
13923
|
-
name: "repeat"
|
|
13924
|
-
}
|
|
13925
|
-
},
|
|
13926
|
-
{
|
|
13927
|
-
label: null,
|
|
13928
|
-
expression: {
|
|
13929
|
-
kind: "reference",
|
|
13930
|
-
name: "group"
|
|
13931
|
-
}
|
|
13932
|
-
},
|
|
13933
|
-
{
|
|
13934
|
-
label: null,
|
|
13935
|
-
expression: {
|
|
13936
|
-
kind: "reference",
|
|
13937
|
-
name: "primary"
|
|
13282
|
+
kind: "repeat",
|
|
13283
|
+
element: {
|
|
13284
|
+
kind: "reference",
|
|
13285
|
+
name: "alternative"
|
|
13286
|
+
}
|
|
13938
13287
|
}
|
|
13939
13288
|
}
|
|
13940
13289
|
]
|
|
13941
13290
|
}
|
|
13942
13291
|
},
|
|
13943
13292
|
{
|
|
13944
|
-
name: "
|
|
13945
|
-
expression: {
|
|
13946
|
-
kind: "sequence",
|
|
13947
|
-
elements: [
|
|
13948
|
-
{
|
|
13949
|
-
kind: "reference",
|
|
13950
|
-
name: "lbracket"
|
|
13951
|
-
},
|
|
13952
|
-
{
|
|
13953
|
-
kind: "reference",
|
|
13954
|
-
name: "expression"
|
|
13955
|
-
},
|
|
13956
|
-
{
|
|
13957
|
-
kind: "reference",
|
|
13958
|
-
name: "rbracket"
|
|
13959
|
-
},
|
|
13960
|
-
{
|
|
13961
|
-
kind: "optional",
|
|
13962
|
-
element: {
|
|
13963
|
-
kind: "sequence",
|
|
13964
|
-
elements: [
|
|
13965
|
-
{
|
|
13966
|
-
kind: "reference",
|
|
13967
|
-
name: "colon"
|
|
13968
|
-
},
|
|
13969
|
-
{
|
|
13970
|
-
kind: "reference",
|
|
13971
|
-
name: "identifier"
|
|
13972
|
-
}
|
|
13973
|
-
]
|
|
13974
|
-
}
|
|
13975
|
-
}
|
|
13976
|
-
]
|
|
13977
|
-
}
|
|
13978
|
-
},
|
|
13979
|
-
{
|
|
13980
|
-
name: "repeat",
|
|
13981
|
-
expression: {
|
|
13982
|
-
kind: "sequence",
|
|
13983
|
-
elements: [
|
|
13984
|
-
{
|
|
13985
|
-
kind: "reference",
|
|
13986
|
-
name: "lbrace"
|
|
13987
|
-
},
|
|
13988
|
-
{
|
|
13989
|
-
kind: "reference",
|
|
13990
|
-
name: "expression"
|
|
13991
|
-
},
|
|
13992
|
-
{
|
|
13993
|
-
kind: "reference",
|
|
13994
|
-
name: "rbrace"
|
|
13995
|
-
}
|
|
13996
|
-
]
|
|
13997
|
-
}
|
|
13998
|
-
},
|
|
13999
|
-
{
|
|
14000
|
-
name: "group",
|
|
14001
|
-
expression: {
|
|
14002
|
-
kind: "sequence",
|
|
14003
|
-
elements: [
|
|
14004
|
-
{
|
|
14005
|
-
kind: "reference",
|
|
14006
|
-
name: "lpar"
|
|
14007
|
-
},
|
|
14008
|
-
{
|
|
14009
|
-
kind: "reference",
|
|
14010
|
-
name: "expression"
|
|
14011
|
-
},
|
|
14012
|
-
{
|
|
14013
|
-
kind: "reference",
|
|
14014
|
-
name: "rpar"
|
|
14015
|
-
}
|
|
14016
|
-
]
|
|
14017
|
-
}
|
|
14018
|
-
},
|
|
14019
|
-
{
|
|
14020
|
-
name: "primary",
|
|
13293
|
+
name: "sequence",
|
|
14021
13294
|
expression: {
|
|
14022
13295
|
kind: "choice",
|
|
14023
13296
|
alternatives: [
|
|
14024
13297
|
{
|
|
14025
|
-
label:
|
|
13298
|
+
label: "factors",
|
|
14026
13299
|
expression: {
|
|
14027
|
-
kind: "
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
label: null,
|
|
14033
|
-
expression: {
|
|
14034
|
-
kind: "reference",
|
|
14035
|
-
name: "identifier"
|
|
13300
|
+
kind: "repeat",
|
|
13301
|
+
element: {
|
|
13302
|
+
kind: "reference",
|
|
13303
|
+
name: "factor"
|
|
13304
|
+
}
|
|
14036
13305
|
}
|
|
14037
13306
|
}
|
|
14038
13307
|
]
|
|
@@ -14056,7 +13325,7 @@ var transform = [
|
|
|
14056
13325
|
]
|
|
14057
13326
|
},
|
|
14058
13327
|
{
|
|
14059
|
-
production: "token_section
|
|
13328
|
+
production: "token_section",
|
|
14060
13329
|
alternatives: [
|
|
14061
13330
|
{
|
|
14062
13331
|
label: "main",
|
|
@@ -14071,7 +13340,7 @@ var transform = [
|
|
|
14071
13340
|
]
|
|
14072
13341
|
},
|
|
14073
13342
|
{
|
|
14074
|
-
production: "skip_section
|
|
13343
|
+
production: "skip_section",
|
|
14075
13344
|
alternatives: [
|
|
14076
13345
|
{
|
|
14077
13346
|
label: "main",
|
|
@@ -14086,7 +13355,7 @@ var transform = [
|
|
|
14086
13355
|
]
|
|
14087
13356
|
},
|
|
14088
13357
|
{
|
|
14089
|
-
production: "grammar_section
|
|
13358
|
+
production: "grammar_section",
|
|
14090
13359
|
alternatives: [
|
|
14091
13360
|
{
|
|
14092
13361
|
label: "main",
|
|
@@ -14101,7 +13370,7 @@ var transform = [
|
|
|
14101
13370
|
]
|
|
14102
13371
|
},
|
|
14103
13372
|
{
|
|
14104
|
-
production: "ast_section
|
|
13373
|
+
production: "ast_section",
|
|
14105
13374
|
alternatives: [
|
|
14106
13375
|
{
|
|
14107
13376
|
label: "main",
|
|
@@ -14116,7 +13385,7 @@ var transform = [
|
|
|
14116
13385
|
]
|
|
14117
13386
|
},
|
|
14118
13387
|
{
|
|
14119
|
-
production: "transform_section
|
|
13388
|
+
production: "transform_section",
|
|
14120
13389
|
alternatives: [
|
|
14121
13390
|
{
|
|
14122
13391
|
label: "main",
|
|
@@ -14131,7 +13400,7 @@ var transform = [
|
|
|
14131
13400
|
]
|
|
14132
13401
|
},
|
|
14133
13402
|
{
|
|
14134
|
-
production: "transform_rule
|
|
13403
|
+
production: "transform_rule",
|
|
14135
13404
|
alternatives: [
|
|
14136
13405
|
{
|
|
14137
13406
|
label: "main",
|
|
@@ -14146,7 +13415,7 @@ var transform = [
|
|
|
14146
13415
|
]
|
|
14147
13416
|
},
|
|
14148
13417
|
{
|
|
14149
|
-
production: "reference_list
|
|
13418
|
+
production: "reference_list",
|
|
14150
13419
|
alternatives: [
|
|
14151
13420
|
{
|
|
14152
13421
|
label: "main",
|
|
@@ -14161,7 +13430,7 @@ var transform = [
|
|
|
14161
13430
|
]
|
|
14162
13431
|
},
|
|
14163
13432
|
{
|
|
14164
|
-
production: "choice
|
|
13433
|
+
production: "choice",
|
|
14165
13434
|
alternatives: [
|
|
14166
13435
|
{
|
|
14167
13436
|
label: "main",
|
|
@@ -14176,7 +13445,7 @@ var transform = [
|
|
|
14176
13445
|
]
|
|
14177
13446
|
},
|
|
14178
13447
|
{
|
|
14179
|
-
production: "sequence
|
|
13448
|
+
production: "sequence",
|
|
14180
13449
|
alternatives: [
|
|
14181
13450
|
{
|
|
14182
13451
|
label: "main",
|
|
@@ -14331,13 +13600,31 @@ function reportDuplicateNames(names, section, kind, issues) {
|
|
|
14331
13600
|
* @param issues - Issue list to append to.
|
|
14332
13601
|
*/
|
|
14333
13602
|
function validateTransformProductionExists(rule, bnfProductionNames, issues) {
|
|
14334
|
-
|
|
13603
|
+
// Accept direct production names.
|
|
13604
|
+
if (bnfProductionNames.has(rule.production)) {
|
|
13605
|
+
return;
|
|
13606
|
+
}
|
|
13607
|
+
// Match authored `$repeat_0` aliases to globally numbered repeats.
|
|
13608
|
+
const repeatPrefix = syntheticRepeatPrefix(rule.production);
|
|
13609
|
+
const matchesRepeat = repeatPrefix !== null
|
|
13610
|
+
&& [...bnfProductionNames].some((productionName) => syntheticRepeatPrefix(productionName) === repeatPrefix);
|
|
13611
|
+
if (!matchesRepeat) {
|
|
14335
13612
|
issues.push({
|
|
14336
13613
|
severity: 'error',
|
|
14337
13614
|
message: `transform rule for unknown production ${JSON.stringify(rule.production)}`,
|
|
14338
13615
|
});
|
|
14339
13616
|
}
|
|
14340
13617
|
}
|
|
13618
|
+
/**
|
|
13619
|
+
* Returns the stable prefix of a numbered synthetic repeat production.
|
|
13620
|
+
*
|
|
13621
|
+
* @param name - Production or transform-rule name.
|
|
13622
|
+
* @returns Prefix ending in `$repeat`, or null for a regular production.
|
|
13623
|
+
*/
|
|
13624
|
+
function syntheticRepeatPrefix(name) {
|
|
13625
|
+
const match = /^(.+\$repeat)_\d+$/.exec(name);
|
|
13626
|
+
return match?.[1] ?? null;
|
|
13627
|
+
}
|
|
14341
13628
|
/**
|
|
14342
13629
|
* Validates one transform expression against the grammar AST schema.
|
|
14343
13630
|
*
|