parser-lr 0.8.1 → 0.8.3

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 CHANGED
@@ -3781,7 +3781,7 @@ const {
3781
3781
  Help,
3782
3782
  } = commander;
3783
3783
 
3784
- var version$1 = "0.8.1";
3784
+ var version$1 = "0.8.3";
3785
3785
  var packageDefinition = {
3786
3786
  version: version$1};
3787
3787
 
@@ -7063,6 +7063,46 @@ function referenceSlotIndex(production, reference) {
7063
7063
  return null;
7064
7064
  }
7065
7065
 
7066
+ /**
7067
+ * Returns whether a CST node was reduced by an empty right-hand side.
7068
+ *
7069
+ * @param node - CST node to test.
7070
+ * @param table - Parse table supplying production metadata.
7071
+ */
7072
+ function isEpsilonNode(node, table) {
7073
+ if (node.isTerminal || node.children.length > 0 || node.productionId === null) {
7074
+ return false;
7075
+ }
7076
+ const production = table.production(node.productionId);
7077
+ return production !== null && production.rhs.length === 0;
7078
+ }
7079
+ /**
7080
+ * Returns whether a CST node is an authored labeled empty alternative.
7081
+ *
7082
+ * @remarks
7083
+ * Labeled epsilons such as `#absent` are first-class grammar alternatives.
7084
+ * They keep identity through default transforms.
7085
+ *
7086
+ * @param node - CST node to test.
7087
+ * @param table - Parse table supplying production metadata.
7088
+ */
7089
+ function isAuthoredEpsilonNode(node, table) {
7090
+ return isEpsilonNode(node, table) && node.variant !== null;
7091
+ }
7092
+ /**
7093
+ * Returns whether a CST node is synthetic unlabeled epsilon scaffolding.
7094
+ *
7095
+ * @remarks
7096
+ * Unlabeled empty productions come from `{…}` / `[…]` desugaring. They are
7097
+ * not authored alternatives and should disappear from AST construction.
7098
+ *
7099
+ * @param node - CST node to test.
7100
+ * @param table - Parse table supplying production metadata.
7101
+ */
7102
+ function isSyntheticEpsilonNode(node, table) {
7103
+ return isEpsilonNode(node, table) && node.variant === null;
7104
+ }
7105
+
7066
7106
  /**
7067
7107
  * Applies CST-to-AST transform rules to a concrete syntax tree.
7068
7108
  */
@@ -7188,7 +7228,8 @@ class CstTransformer {
7188
7228
  if (childNode === null) {
7189
7229
  return null;
7190
7230
  }
7191
- if (this.isEpsilonNode(childNode)) {
7231
+ // Drop synthetic unlabeled epsilons; keep authored `#label` empty alts.
7232
+ if (isSyntheticEpsilonNode(childNode, this.table)) {
7192
7233
  continue;
7193
7234
  }
7194
7235
  const child = this.transformNode(childNode);
@@ -7220,7 +7261,7 @@ class CstTransformer {
7220
7261
  }
7221
7262
  let acc = this.buildAstNode(expression.typeName, expression.variant, [left, operator, right], node.location);
7222
7263
  let tail = this.findRepeatTail(node, slots);
7223
- while (tail !== null && !this.isEpsilonNode(tail)) {
7264
+ while (tail !== null && !isSyntheticEpsilonNode(tail, this.table)) {
7224
7265
  const tailSlots = this.resolveReferences(tail, expression.references);
7225
7266
  if (tailSlots === null) {
7226
7267
  return null;
@@ -7244,7 +7285,7 @@ class CstTransformer {
7244
7285
  applyFoldRight(node, expression) {
7245
7286
  const parts = [];
7246
7287
  let current = node;
7247
- while (current !== null && !this.isEpsilonNode(current)) {
7288
+ while (current !== null && !isSyntheticEpsilonNode(current, this.table)) {
7248
7289
  const leftRef = expression.references[0];
7249
7290
  const operatorRef = expression.references[1];
7250
7291
  const rightRef = expression.references[2];
@@ -7286,14 +7327,14 @@ class CstTransformer {
7286
7327
  applyFlatten(node, expression) {
7287
7328
  const items = [];
7288
7329
  let current = node;
7289
- while (current !== null && !this.isEpsilonNode(current)) {
7330
+ while (current !== null && !isSyntheticEpsilonNode(current, this.table)) {
7290
7331
  const head = this.transformFlattenHead(current, expression.head);
7291
7332
  if (head === null) {
7292
7333
  return null;
7293
7334
  }
7294
7335
  items.push(head);
7295
7336
  const tail = this.resolveReferenceNode(current, expression.tail);
7296
- if (tail === null || this.isEpsilonNode(tail)) {
7337
+ if (tail === null || isSyntheticEpsilonNode(tail, this.table)) {
7297
7338
  break;
7298
7339
  }
7299
7340
  current = tail;
@@ -7333,10 +7374,19 @@ class CstTransformer {
7333
7374
  /**
7334
7375
  * Transforms a CST node without explicit transform rules.
7335
7376
  *
7377
+ * @remarks
7378
+ * Authored labeled epsilon alternatives (`#absent`) keep their identity.
7379
+ * Synthetic unlabeled epsilons from `{…}` / `[…]` desugaring are dropped.
7380
+ *
7336
7381
  * @param node - CST node to pass through or unwrap.
7337
7382
  */
7338
7383
  defaultTransform(node) {
7339
- if (this.isEpsilonNode(node)) {
7384
+ // Authored `#label` empty alternatives are first-class nodes.
7385
+ if (isAuthoredEpsilonNode(node, this.table)) {
7386
+ return AstNode.rule(node.symbol, [], node.location, node.variant);
7387
+ }
7388
+ // Synthetic unlabeled epsilons are scaffolding, not AST content.
7389
+ if (isSyntheticEpsilonNode(node, this.table)) {
7340
7390
  return null;
7341
7391
  }
7342
7392
  const children = this.transformChildren(node.children);
@@ -7458,21 +7508,6 @@ class CstTransformer {
7458
7508
  }
7459
7509
  return null;
7460
7510
  }
7461
- /**
7462
- * Returns whether a CST node represents an epsilon production.
7463
- *
7464
- * @param node - CST node to test.
7465
- */
7466
- isEpsilonNode(node) {
7467
- if (node.isTerminal) {
7468
- return false;
7469
- }
7470
- if (node.children.length > 0) {
7471
- return false;
7472
- }
7473
- const production = this.productionFor(node);
7474
- return production !== null && production.rhs.length === 0;
7475
- }
7476
7511
  /**
7477
7512
  * Returns parse table production metadata for a CST node.
7478
7513
  *
@@ -8382,10 +8417,12 @@ function parseLabeledAlternative(node) {
8382
8417
  const label = labelNode === null || findChild(node, 'hash') === null
8383
8418
  ? null
8384
8419
  : identifierText(labelNode);
8385
- const sequence = requireChild(node, 'sequence');
8420
+ const sequence = findChild(node, 'sequence');
8386
8421
  return {
8387
8422
  label,
8388
- expression: parseSequence(sequence),
8423
+ expression: sequence === null
8424
+ ? { kind: 'sequence', elements: [] }
8425
+ : parseSequence(sequence),
8389
8426
  };
8390
8427
  }
8391
8428
  /**
@@ -9381,7 +9418,8 @@ var productions = [
9381
9418
  id: 61,
9382
9419
  name: "labeled_alternative",
9383
9420
  rhs: [
9384
- "sequence"
9421
+ "hash",
9422
+ "identifier"
9385
9423
  ],
9386
9424
  variant: null,
9387
9425
  origin: "labeled_alternative"
@@ -9399,6 +9437,15 @@ var productions = [
9399
9437
  },
9400
9438
  {
9401
9439
  id: 63,
9440
+ name: "labeled_alternative",
9441
+ rhs: [
9442
+ "sequence"
9443
+ ],
9444
+ variant: null,
9445
+ origin: "labeled_alternative"
9446
+ },
9447
+ {
9448
+ id: 64,
9402
9449
  name: "sequence$repeat_10",
9403
9450
  rhs: [
9404
9451
  "factor",
@@ -9408,7 +9455,7 @@ var productions = [
9408
9455
  origin: "sequence$repeat_10"
9409
9456
  },
9410
9457
  {
9411
- id: 64,
9458
+ id: 65,
9412
9459
  name: "sequence$repeat_10",
9413
9460
  rhs: [
9414
9461
  ],
@@ -9416,7 +9463,7 @@ var productions = [
9416
9463
  origin: "sequence$repeat_10"
9417
9464
  },
9418
9465
  {
9419
- id: 65,
9466
+ id: 66,
9420
9467
  name: "sequence",
9421
9468
  rhs: [
9422
9469
  "factor",
@@ -9426,7 +9473,7 @@ var productions = [
9426
9473
  origin: "sequence"
9427
9474
  },
9428
9475
  {
9429
- id: 66,
9476
+ id: 67,
9430
9477
  name: "factor",
9431
9478
  rhs: [
9432
9479
  "bracketed"
@@ -9435,7 +9482,7 @@ var productions = [
9435
9482
  origin: "factor"
9436
9483
  },
9437
9484
  {
9438
- id: 67,
9485
+ id: 68,
9439
9486
  name: "factor",
9440
9487
  rhs: [
9441
9488
  "repeat"
@@ -9444,7 +9491,7 @@ var productions = [
9444
9491
  origin: "factor"
9445
9492
  },
9446
9493
  {
9447
- id: 68,
9494
+ id: 69,
9448
9495
  name: "factor",
9449
9496
  rhs: [
9450
9497
  "group"
@@ -9453,7 +9500,7 @@ var productions = [
9453
9500
  origin: "factor"
9454
9501
  },
9455
9502
  {
9456
- id: 69,
9503
+ id: 70,
9457
9504
  name: "factor",
9458
9505
  rhs: [
9459
9506
  "primary"
@@ -9462,7 +9509,7 @@ var productions = [
9462
9509
  origin: "factor"
9463
9510
  },
9464
9511
  {
9465
- id: 70,
9512
+ id: 71,
9466
9513
  name: "bracketed",
9467
9514
  rhs: [
9468
9515
  "lbracket",
@@ -9473,7 +9520,7 @@ var productions = [
9473
9520
  origin: "bracketed"
9474
9521
  },
9475
9522
  {
9476
- id: 71,
9523
+ id: 72,
9477
9524
  name: "bracketed",
9478
9525
  rhs: [
9479
9526
  "lbracket",
@@ -9486,7 +9533,7 @@ var productions = [
9486
9533
  origin: "bracketed"
9487
9534
  },
9488
9535
  {
9489
- id: 72,
9536
+ id: 73,
9490
9537
  name: "repeat",
9491
9538
  rhs: [
9492
9539
  "lbrace",
@@ -9497,7 +9544,7 @@ var productions = [
9497
9544
  origin: "repeat"
9498
9545
  },
9499
9546
  {
9500
- id: 73,
9547
+ id: 74,
9501
9548
  name: "group",
9502
9549
  rhs: [
9503
9550
  "lpar",
@@ -9508,7 +9555,7 @@ var productions = [
9508
9555
  origin: "group"
9509
9556
  },
9510
9557
  {
9511
- id: 74,
9558
+ id: 75,
9512
9559
  name: "primary",
9513
9560
  rhs: [
9514
9561
  "string_literal"
@@ -9517,7 +9564,7 @@ var productions = [
9517
9564
  origin: "primary"
9518
9565
  },
9519
9566
  {
9520
- id: 75,
9567
+ id: 76,
9521
9568
  name: "primary",
9522
9569
  rhs: [
9523
9570
  "identifier"
@@ -9526,7 +9573,7 @@ var productions = [
9526
9573
  origin: "primary"
9527
9574
  },
9528
9575
  {
9529
- id: 76,
9576
+ id: 77,
9530
9577
  name: "$accept",
9531
9578
  rhs: [
9532
9579
  "grammar_file"
@@ -10985,67 +11032,67 @@ var actions = [
10985
11032
  state: 110,
10986
11033
  symbol: "$eof",
10987
11034
  kind: "reduce",
10988
- productionId: 66
11035
+ productionId: 67
10989
11036
  },
10990
11037
  {
10991
11038
  state: 110,
10992
11039
  symbol: "bar",
10993
11040
  kind: "reduce",
10994
- productionId: 66
11041
+ productionId: 67
10995
11042
  },
10996
11043
  {
10997
11044
  state: 110,
10998
11045
  symbol: "identifier",
10999
11046
  kind: "reduce",
11000
- productionId: 66
11047
+ productionId: 67
11001
11048
  },
11002
11049
  {
11003
11050
  state: 110,
11004
11051
  symbol: "lbrace",
11005
11052
  kind: "reduce",
11006
- productionId: 66
11053
+ productionId: 67
11007
11054
  },
11008
11055
  {
11009
11056
  state: 110,
11010
11057
  symbol: "lbracket",
11011
11058
  kind: "reduce",
11012
- productionId: 66
11059
+ productionId: 67
11013
11060
  },
11014
11061
  {
11015
11062
  state: 110,
11016
11063
  symbol: "lpar",
11017
11064
  kind: "reduce",
11018
- productionId: 66
11065
+ productionId: 67
11019
11066
  },
11020
11067
  {
11021
11068
  state: 110,
11022
11069
  symbol: "rbrace",
11023
11070
  kind: "reduce",
11024
- productionId: 66
11071
+ productionId: 67
11025
11072
  },
11026
11073
  {
11027
11074
  state: 110,
11028
11075
  symbol: "rbracket",
11029
11076
  kind: "reduce",
11030
- productionId: 66
11077
+ productionId: 67
11031
11078
  },
11032
11079
  {
11033
11080
  state: 110,
11034
11081
  symbol: "rpar",
11035
11082
  kind: "reduce",
11036
- productionId: 66
11083
+ productionId: 67
11037
11084
  },
11038
11085
  {
11039
11086
  state: 110,
11040
11087
  symbol: "semicolon",
11041
11088
  kind: "reduce",
11042
- productionId: 66
11089
+ productionId: 67
11043
11090
  },
11044
11091
  {
11045
11092
  state: 110,
11046
11093
  symbol: "string_literal",
11047
11094
  kind: "reduce",
11048
- productionId: 66
11095
+ productionId: 67
11049
11096
  },
11050
11097
  {
11051
11098
  state: 111,
@@ -11081,13 +11128,13 @@ var actions = [
11081
11128
  state: 113,
11082
11129
  symbol: "$eof",
11083
11130
  kind: "reduce",
11084
- productionId: 64
11131
+ productionId: 65
11085
11132
  },
11086
11133
  {
11087
11134
  state: 113,
11088
11135
  symbol: "bar",
11089
11136
  kind: "reduce",
11090
- productionId: 64
11137
+ productionId: 65
11091
11138
  },
11092
11139
  {
11093
11140
  state: 113,
@@ -11117,25 +11164,25 @@ var actions = [
11117
11164
  state: 113,
11118
11165
  symbol: "rbrace",
11119
11166
  kind: "reduce",
11120
- productionId: 64
11167
+ productionId: 65
11121
11168
  },
11122
11169
  {
11123
11170
  state: 113,
11124
11171
  symbol: "rbracket",
11125
11172
  kind: "reduce",
11126
- productionId: 64
11173
+ productionId: 65
11127
11174
  },
11128
11175
  {
11129
11176
  state: 113,
11130
11177
  symbol: "rpar",
11131
11178
  kind: "reduce",
11132
- productionId: 64
11179
+ productionId: 65
11133
11180
  },
11134
11181
  {
11135
11182
  state: 113,
11136
11183
  symbol: "semicolon",
11137
11184
  kind: "reduce",
11138
- productionId: 64
11185
+ productionId: 65
11139
11186
  },
11140
11187
  {
11141
11188
  state: 113,
@@ -11147,67 +11194,67 @@ var actions = [
11147
11194
  state: 114,
11148
11195
  symbol: "$eof",
11149
11196
  kind: "reduce",
11150
- productionId: 68
11197
+ productionId: 69
11151
11198
  },
11152
11199
  {
11153
11200
  state: 114,
11154
11201
  symbol: "bar",
11155
11202
  kind: "reduce",
11156
- productionId: 68
11203
+ productionId: 69
11157
11204
  },
11158
11205
  {
11159
11206
  state: 114,
11160
11207
  symbol: "identifier",
11161
11208
  kind: "reduce",
11162
- productionId: 68
11209
+ productionId: 69
11163
11210
  },
11164
11211
  {
11165
11212
  state: 114,
11166
11213
  symbol: "lbrace",
11167
11214
  kind: "reduce",
11168
- productionId: 68
11215
+ productionId: 69
11169
11216
  },
11170
11217
  {
11171
11218
  state: 114,
11172
11219
  symbol: "lbracket",
11173
11220
  kind: "reduce",
11174
- productionId: 68
11221
+ productionId: 69
11175
11222
  },
11176
11223
  {
11177
11224
  state: 114,
11178
11225
  symbol: "lpar",
11179
11226
  kind: "reduce",
11180
- productionId: 68
11227
+ productionId: 69
11181
11228
  },
11182
11229
  {
11183
11230
  state: 114,
11184
11231
  symbol: "rbrace",
11185
11232
  kind: "reduce",
11186
- productionId: 68
11233
+ productionId: 69
11187
11234
  },
11188
11235
  {
11189
11236
  state: 114,
11190
11237
  symbol: "rbracket",
11191
11238
  kind: "reduce",
11192
- productionId: 68
11239
+ productionId: 69
11193
11240
  },
11194
11241
  {
11195
11242
  state: 114,
11196
11243
  symbol: "rpar",
11197
11244
  kind: "reduce",
11198
- productionId: 68
11245
+ productionId: 69
11199
11246
  },
11200
11247
  {
11201
11248
  state: 114,
11202
11249
  symbol: "semicolon",
11203
11250
  kind: "reduce",
11204
- productionId: 68
11251
+ productionId: 69
11205
11252
  },
11206
11253
  {
11207
11254
  state: 114,
11208
11255
  symbol: "string_literal",
11209
11256
  kind: "reduce",
11210
- productionId: 68
11257
+ productionId: 69
11211
11258
  },
11212
11259
  {
11213
11260
  state: 115,
@@ -11219,67 +11266,67 @@ var actions = [
11219
11266
  state: 116,
11220
11267
  symbol: "$eof",
11221
11268
  kind: "reduce",
11222
- productionId: 75
11269
+ productionId: 76
11223
11270
  },
11224
11271
  {
11225
11272
  state: 116,
11226
11273
  symbol: "bar",
11227
11274
  kind: "reduce",
11228
- productionId: 75
11275
+ productionId: 76
11229
11276
  },
11230
11277
  {
11231
11278
  state: 116,
11232
11279
  symbol: "identifier",
11233
11280
  kind: "reduce",
11234
- productionId: 75
11281
+ productionId: 76
11235
11282
  },
11236
11283
  {
11237
11284
  state: 116,
11238
11285
  symbol: "lbrace",
11239
11286
  kind: "reduce",
11240
- productionId: 75
11287
+ productionId: 76
11241
11288
  },
11242
11289
  {
11243
11290
  state: 116,
11244
11291
  symbol: "lbracket",
11245
11292
  kind: "reduce",
11246
- productionId: 75
11293
+ productionId: 76
11247
11294
  },
11248
11295
  {
11249
11296
  state: 116,
11250
11297
  symbol: "lpar",
11251
11298
  kind: "reduce",
11252
- productionId: 75
11299
+ productionId: 76
11253
11300
  },
11254
11301
  {
11255
11302
  state: 116,
11256
11303
  symbol: "rbrace",
11257
11304
  kind: "reduce",
11258
- productionId: 75
11305
+ productionId: 76
11259
11306
  },
11260
11307
  {
11261
11308
  state: 116,
11262
11309
  symbol: "rbracket",
11263
11310
  kind: "reduce",
11264
- productionId: 75
11311
+ productionId: 76
11265
11312
  },
11266
11313
  {
11267
11314
  state: 116,
11268
11315
  symbol: "rpar",
11269
11316
  kind: "reduce",
11270
- productionId: 75
11317
+ productionId: 76
11271
11318
  },
11272
11319
  {
11273
11320
  state: 116,
11274
11321
  symbol: "semicolon",
11275
11322
  kind: "reduce",
11276
- productionId: 75
11323
+ productionId: 76
11277
11324
  },
11278
11325
  {
11279
11326
  state: 116,
11280
11327
  symbol: "string_literal",
11281
11328
  kind: "reduce",
11282
- productionId: 75
11329
+ productionId: 76
11283
11330
  },
11284
11331
  {
11285
11332
  state: 117,
@@ -11429,235 +11476,235 @@ var actions = [
11429
11476
  state: 121,
11430
11477
  symbol: "$eof",
11431
11478
  kind: "reduce",
11432
- productionId: 69
11479
+ productionId: 70
11433
11480
  },
11434
11481
  {
11435
11482
  state: 121,
11436
11483
  symbol: "bar",
11437
11484
  kind: "reduce",
11438
- productionId: 69
11485
+ productionId: 70
11439
11486
  },
11440
11487
  {
11441
11488
  state: 121,
11442
11489
  symbol: "identifier",
11443
11490
  kind: "reduce",
11444
- productionId: 69
11491
+ productionId: 70
11445
11492
  },
11446
11493
  {
11447
11494
  state: 121,
11448
11495
  symbol: "lbrace",
11449
11496
  kind: "reduce",
11450
- productionId: 69
11497
+ productionId: 70
11451
11498
  },
11452
11499
  {
11453
11500
  state: 121,
11454
11501
  symbol: "lbracket",
11455
11502
  kind: "reduce",
11456
- productionId: 69
11503
+ productionId: 70
11457
11504
  },
11458
11505
  {
11459
11506
  state: 121,
11460
11507
  symbol: "lpar",
11461
11508
  kind: "reduce",
11462
- productionId: 69
11509
+ productionId: 70
11463
11510
  },
11464
11511
  {
11465
11512
  state: 121,
11466
11513
  symbol: "rbrace",
11467
11514
  kind: "reduce",
11468
- productionId: 69
11515
+ productionId: 70
11469
11516
  },
11470
11517
  {
11471
11518
  state: 121,
11472
11519
  symbol: "rbracket",
11473
11520
  kind: "reduce",
11474
- productionId: 69
11521
+ productionId: 70
11475
11522
  },
11476
11523
  {
11477
11524
  state: 121,
11478
11525
  symbol: "rpar",
11479
11526
  kind: "reduce",
11480
- productionId: 69
11527
+ productionId: 70
11481
11528
  },
11482
11529
  {
11483
11530
  state: 121,
11484
11531
  symbol: "semicolon",
11485
11532
  kind: "reduce",
11486
- productionId: 69
11533
+ productionId: 70
11487
11534
  },
11488
11535
  {
11489
11536
  state: 121,
11490
11537
  symbol: "string_literal",
11491
11538
  kind: "reduce",
11492
- productionId: 69
11539
+ productionId: 70
11493
11540
  },
11494
11541
  {
11495
11542
  state: 122,
11496
11543
  symbol: "$eof",
11497
11544
  kind: "reduce",
11498
- productionId: 67
11545
+ productionId: 68
11499
11546
  },
11500
11547
  {
11501
11548
  state: 122,
11502
11549
  symbol: "bar",
11503
11550
  kind: "reduce",
11504
- productionId: 67
11551
+ productionId: 68
11505
11552
  },
11506
11553
  {
11507
11554
  state: 122,
11508
11555
  symbol: "identifier",
11509
11556
  kind: "reduce",
11510
- productionId: 67
11557
+ productionId: 68
11511
11558
  },
11512
11559
  {
11513
11560
  state: 122,
11514
11561
  symbol: "lbrace",
11515
11562
  kind: "reduce",
11516
- productionId: 67
11563
+ productionId: 68
11517
11564
  },
11518
11565
  {
11519
11566
  state: 122,
11520
11567
  symbol: "lbracket",
11521
11568
  kind: "reduce",
11522
- productionId: 67
11569
+ productionId: 68
11523
11570
  },
11524
11571
  {
11525
11572
  state: 122,
11526
11573
  symbol: "lpar",
11527
11574
  kind: "reduce",
11528
- productionId: 67
11575
+ productionId: 68
11529
11576
  },
11530
11577
  {
11531
11578
  state: 122,
11532
11579
  symbol: "rbrace",
11533
11580
  kind: "reduce",
11534
- productionId: 67
11581
+ productionId: 68
11535
11582
  },
11536
11583
  {
11537
11584
  state: 122,
11538
11585
  symbol: "rbracket",
11539
11586
  kind: "reduce",
11540
- productionId: 67
11587
+ productionId: 68
11541
11588
  },
11542
11589
  {
11543
11590
  state: 122,
11544
11591
  symbol: "rpar",
11545
11592
  kind: "reduce",
11546
- productionId: 67
11593
+ productionId: 68
11547
11594
  },
11548
11595
  {
11549
11596
  state: 122,
11550
11597
  symbol: "semicolon",
11551
11598
  kind: "reduce",
11552
- productionId: 67
11599
+ productionId: 68
11553
11600
  },
11554
11601
  {
11555
11602
  state: 122,
11556
11603
  symbol: "string_literal",
11557
11604
  kind: "reduce",
11558
- productionId: 67
11605
+ productionId: 68
11559
11606
  },
11560
11607
  {
11561
11608
  state: 123,
11562
11609
  symbol: "$eof",
11563
11610
  kind: "reduce",
11564
- productionId: 61
11611
+ productionId: 63
11565
11612
  },
11566
11613
  {
11567
11614
  state: 123,
11568
11615
  symbol: "bar",
11569
11616
  kind: "reduce",
11570
- productionId: 61
11617
+ productionId: 63
11571
11618
  },
11572
11619
  {
11573
11620
  state: 123,
11574
11621
  symbol: "rbrace",
11575
11622
  kind: "reduce",
11576
- productionId: 61
11623
+ productionId: 63
11577
11624
  },
11578
11625
  {
11579
11626
  state: 123,
11580
11627
  symbol: "rbracket",
11581
11628
  kind: "reduce",
11582
- productionId: 61
11629
+ productionId: 63
11583
11630
  },
11584
11631
  {
11585
11632
  state: 123,
11586
11633
  symbol: "rpar",
11587
11634
  kind: "reduce",
11588
- productionId: 61
11635
+ productionId: 63
11589
11636
  },
11590
11637
  {
11591
11638
  state: 123,
11592
11639
  symbol: "semicolon",
11593
11640
  kind: "reduce",
11594
- productionId: 61
11641
+ productionId: 63
11595
11642
  },
11596
11643
  {
11597
11644
  state: 124,
11598
11645
  symbol: "$eof",
11599
11646
  kind: "reduce",
11600
- productionId: 74
11647
+ productionId: 75
11601
11648
  },
11602
11649
  {
11603
11650
  state: 124,
11604
11651
  symbol: "bar",
11605
11652
  kind: "reduce",
11606
- productionId: 74
11653
+ productionId: 75
11607
11654
  },
11608
11655
  {
11609
11656
  state: 124,
11610
11657
  symbol: "identifier",
11611
11658
  kind: "reduce",
11612
- productionId: 74
11659
+ productionId: 75
11613
11660
  },
11614
11661
  {
11615
11662
  state: 124,
11616
11663
  symbol: "lbrace",
11617
11664
  kind: "reduce",
11618
- productionId: 74
11665
+ productionId: 75
11619
11666
  },
11620
11667
  {
11621
11668
  state: 124,
11622
11669
  symbol: "lbracket",
11623
11670
  kind: "reduce",
11624
- productionId: 74
11671
+ productionId: 75
11625
11672
  },
11626
11673
  {
11627
11674
  state: 124,
11628
11675
  symbol: "lpar",
11629
11676
  kind: "reduce",
11630
- productionId: 74
11677
+ productionId: 75
11631
11678
  },
11632
11679
  {
11633
11680
  state: 124,
11634
11681
  symbol: "rbrace",
11635
11682
  kind: "reduce",
11636
- productionId: 74
11683
+ productionId: 75
11637
11684
  },
11638
11685
  {
11639
11686
  state: 124,
11640
11687
  symbol: "rbracket",
11641
11688
  kind: "reduce",
11642
- productionId: 74
11689
+ productionId: 75
11643
11690
  },
11644
11691
  {
11645
11692
  state: 124,
11646
11693
  symbol: "rpar",
11647
11694
  kind: "reduce",
11648
- productionId: 74
11695
+ productionId: 75
11649
11696
  },
11650
11697
  {
11651
11698
  state: 124,
11652
11699
  symbol: "semicolon",
11653
11700
  kind: "reduce",
11654
- productionId: 74
11701
+ productionId: 75
11655
11702
  },
11656
11703
  {
11657
11704
  state: 124,
11658
11705
  symbol: "string_literal",
11659
11706
  kind: "reduce",
11660
- productionId: 74
11707
+ productionId: 75
11661
11708
  },
11662
11709
  {
11663
11710
  state: 125,
@@ -11669,67 +11716,67 @@ var actions = [
11669
11716
  state: 126,
11670
11717
  symbol: "$eof",
11671
11718
  kind: "reduce",
11672
- productionId: 73
11719
+ productionId: 74
11673
11720
  },
11674
11721
  {
11675
11722
  state: 126,
11676
11723
  symbol: "bar",
11677
11724
  kind: "reduce",
11678
- productionId: 73
11725
+ productionId: 74
11679
11726
  },
11680
11727
  {
11681
11728
  state: 126,
11682
11729
  symbol: "identifier",
11683
11730
  kind: "reduce",
11684
- productionId: 73
11731
+ productionId: 74
11685
11732
  },
11686
11733
  {
11687
11734
  state: 126,
11688
11735
  symbol: "lbrace",
11689
11736
  kind: "reduce",
11690
- productionId: 73
11737
+ productionId: 74
11691
11738
  },
11692
11739
  {
11693
11740
  state: 126,
11694
11741
  symbol: "lbracket",
11695
11742
  kind: "reduce",
11696
- productionId: 73
11743
+ productionId: 74
11697
11744
  },
11698
11745
  {
11699
11746
  state: 126,
11700
11747
  symbol: "lpar",
11701
11748
  kind: "reduce",
11702
- productionId: 73
11749
+ productionId: 74
11703
11750
  },
11704
11751
  {
11705
11752
  state: 126,
11706
11753
  symbol: "rbrace",
11707
11754
  kind: "reduce",
11708
- productionId: 73
11755
+ productionId: 74
11709
11756
  },
11710
11757
  {
11711
11758
  state: 126,
11712
11759
  symbol: "rbracket",
11713
11760
  kind: "reduce",
11714
- productionId: 73
11761
+ productionId: 74
11715
11762
  },
11716
11763
  {
11717
11764
  state: 126,
11718
11765
  symbol: "rpar",
11719
11766
  kind: "reduce",
11720
- productionId: 73
11767
+ productionId: 74
11721
11768
  },
11722
11769
  {
11723
11770
  state: 126,
11724
11771
  symbol: "semicolon",
11725
11772
  kind: "reduce",
11726
- productionId: 73
11773
+ productionId: 74
11727
11774
  },
11728
11775
  {
11729
11776
  state: 126,
11730
11777
  symbol: "string_literal",
11731
11778
  kind: "reduce",
11732
- productionId: 73
11779
+ productionId: 74
11733
11780
  },
11734
11781
  {
11735
11782
  state: 127,
@@ -11741,13 +11788,13 @@ var actions = [
11741
11788
  state: 128,
11742
11789
  symbol: "$eof",
11743
11790
  kind: "reduce",
11744
- productionId: 70
11791
+ productionId: 71
11745
11792
  },
11746
11793
  {
11747
11794
  state: 128,
11748
11795
  symbol: "bar",
11749
11796
  kind: "reduce",
11750
- productionId: 70
11797
+ productionId: 71
11751
11798
  },
11752
11799
  {
11753
11800
  state: 128,
@@ -11759,55 +11806,55 @@ var actions = [
11759
11806
  state: 128,
11760
11807
  symbol: "identifier",
11761
11808
  kind: "reduce",
11762
- productionId: 70
11809
+ productionId: 71
11763
11810
  },
11764
11811
  {
11765
11812
  state: 128,
11766
11813
  symbol: "lbrace",
11767
11814
  kind: "reduce",
11768
- productionId: 70
11815
+ productionId: 71
11769
11816
  },
11770
11817
  {
11771
11818
  state: 128,
11772
11819
  symbol: "lbracket",
11773
11820
  kind: "reduce",
11774
- productionId: 70
11821
+ productionId: 71
11775
11822
  },
11776
11823
  {
11777
11824
  state: 128,
11778
11825
  symbol: "lpar",
11779
11826
  kind: "reduce",
11780
- productionId: 70
11827
+ productionId: 71
11781
11828
  },
11782
11829
  {
11783
11830
  state: 128,
11784
11831
  symbol: "rbrace",
11785
11832
  kind: "reduce",
11786
- productionId: 70
11833
+ productionId: 71
11787
11834
  },
11788
11835
  {
11789
11836
  state: 128,
11790
11837
  symbol: "rbracket",
11791
11838
  kind: "reduce",
11792
- productionId: 70
11839
+ productionId: 71
11793
11840
  },
11794
11841
  {
11795
11842
  state: 128,
11796
11843
  symbol: "rpar",
11797
11844
  kind: "reduce",
11798
- productionId: 70
11845
+ productionId: 71
11799
11846
  },
11800
11847
  {
11801
11848
  state: 128,
11802
11849
  symbol: "semicolon",
11803
11850
  kind: "reduce",
11804
- productionId: 70
11851
+ productionId: 71
11805
11852
  },
11806
11853
  {
11807
11854
  state: 128,
11808
11855
  symbol: "string_literal",
11809
11856
  kind: "reduce",
11810
- productionId: 70
11857
+ productionId: 71
11811
11858
  },
11812
11859
  {
11813
11860
  state: 129,
@@ -11819,67 +11866,67 @@ var actions = [
11819
11866
  state: 130,
11820
11867
  symbol: "$eof",
11821
11868
  kind: "reduce",
11822
- productionId: 71
11869
+ productionId: 72
11823
11870
  },
11824
11871
  {
11825
11872
  state: 130,
11826
11873
  symbol: "bar",
11827
11874
  kind: "reduce",
11828
- productionId: 71
11875
+ productionId: 72
11829
11876
  },
11830
11877
  {
11831
11878
  state: 130,
11832
11879
  symbol: "identifier",
11833
11880
  kind: "reduce",
11834
- productionId: 71
11881
+ productionId: 72
11835
11882
  },
11836
11883
  {
11837
11884
  state: 130,
11838
11885
  symbol: "lbrace",
11839
11886
  kind: "reduce",
11840
- productionId: 71
11887
+ productionId: 72
11841
11888
  },
11842
11889
  {
11843
11890
  state: 130,
11844
11891
  symbol: "lbracket",
11845
11892
  kind: "reduce",
11846
- productionId: 71
11893
+ productionId: 72
11847
11894
  },
11848
11895
  {
11849
11896
  state: 130,
11850
11897
  symbol: "lpar",
11851
11898
  kind: "reduce",
11852
- productionId: 71
11899
+ productionId: 72
11853
11900
  },
11854
11901
  {
11855
11902
  state: 130,
11856
11903
  symbol: "rbrace",
11857
11904
  kind: "reduce",
11858
- productionId: 71
11905
+ productionId: 72
11859
11906
  },
11860
11907
  {
11861
11908
  state: 130,
11862
11909
  symbol: "rbracket",
11863
11910
  kind: "reduce",
11864
- productionId: 71
11911
+ productionId: 72
11865
11912
  },
11866
11913
  {
11867
11914
  state: 130,
11868
11915
  symbol: "rpar",
11869
11916
  kind: "reduce",
11870
- productionId: 71
11917
+ productionId: 72
11871
11918
  },
11872
11919
  {
11873
11920
  state: 130,
11874
11921
  symbol: "semicolon",
11875
11922
  kind: "reduce",
11876
- productionId: 71
11923
+ productionId: 72
11877
11924
  },
11878
11925
  {
11879
11926
  state: 130,
11880
11927
  symbol: "string_literal",
11881
11928
  kind: "reduce",
11882
- productionId: 71
11929
+ productionId: 72
11883
11930
  },
11884
11931
  {
11885
11932
  state: 131,
@@ -11891,67 +11938,79 @@ var actions = [
11891
11938
  state: 132,
11892
11939
  symbol: "$eof",
11893
11940
  kind: "reduce",
11894
- productionId: 72
11941
+ productionId: 73
11895
11942
  },
11896
11943
  {
11897
11944
  state: 132,
11898
11945
  symbol: "bar",
11899
11946
  kind: "reduce",
11900
- productionId: 72
11947
+ productionId: 73
11901
11948
  },
11902
11949
  {
11903
11950
  state: 132,
11904
11951
  symbol: "identifier",
11905
11952
  kind: "reduce",
11906
- productionId: 72
11953
+ productionId: 73
11907
11954
  },
11908
11955
  {
11909
11956
  state: 132,
11910
11957
  symbol: "lbrace",
11911
11958
  kind: "reduce",
11912
- productionId: 72
11959
+ productionId: 73
11913
11960
  },
11914
11961
  {
11915
11962
  state: 132,
11916
11963
  symbol: "lbracket",
11917
11964
  kind: "reduce",
11918
- productionId: 72
11965
+ productionId: 73
11919
11966
  },
11920
11967
  {
11921
11968
  state: 132,
11922
11969
  symbol: "lpar",
11923
11970
  kind: "reduce",
11924
- productionId: 72
11971
+ productionId: 73
11925
11972
  },
11926
11973
  {
11927
11974
  state: 132,
11928
11975
  symbol: "rbrace",
11929
11976
  kind: "reduce",
11930
- productionId: 72
11977
+ productionId: 73
11931
11978
  },
11932
11979
  {
11933
11980
  state: 132,
11934
11981
  symbol: "rbracket",
11935
11982
  kind: "reduce",
11936
- productionId: 72
11983
+ productionId: 73
11937
11984
  },
11938
11985
  {
11939
11986
  state: 132,
11940
11987
  symbol: "rpar",
11941
11988
  kind: "reduce",
11942
- productionId: 72
11989
+ productionId: 73
11943
11990
  },
11944
11991
  {
11945
11992
  state: 132,
11946
11993
  symbol: "semicolon",
11947
11994
  kind: "reduce",
11948
- productionId: 72
11995
+ productionId: 73
11949
11996
  },
11950
11997
  {
11951
11998
  state: 132,
11952
11999
  symbol: "string_literal",
11953
12000
  kind: "reduce",
11954
- productionId: 72
12001
+ productionId: 73
12002
+ },
12003
+ {
12004
+ state: 133,
12005
+ symbol: "$eof",
12006
+ kind: "reduce",
12007
+ productionId: 61
12008
+ },
12009
+ {
12010
+ state: 133,
12011
+ symbol: "bar",
12012
+ kind: "reduce",
12013
+ productionId: 61
11955
12014
  },
11956
12015
  {
11957
12016
  state: 133,
@@ -11977,6 +12036,30 @@ var actions = [
11977
12036
  kind: "shift",
11978
12037
  target: 120
11979
12038
  },
12039
+ {
12040
+ state: 133,
12041
+ symbol: "rbrace",
12042
+ kind: "reduce",
12043
+ productionId: 61
12044
+ },
12045
+ {
12046
+ state: 133,
12047
+ symbol: "rbracket",
12048
+ kind: "reduce",
12049
+ productionId: 61
12050
+ },
12051
+ {
12052
+ state: 133,
12053
+ symbol: "rpar",
12054
+ kind: "reduce",
12055
+ productionId: 61
12056
+ },
12057
+ {
12058
+ state: 133,
12059
+ symbol: "semicolon",
12060
+ kind: "reduce",
12061
+ productionId: 61
12062
+ },
11980
12063
  {
11981
12064
  state: 133,
11982
12065
  symbol: "string_literal",
@@ -12023,13 +12106,13 @@ var actions = [
12023
12106
  state: 135,
12024
12107
  symbol: "$eof",
12025
12108
  kind: "reduce",
12026
- productionId: 64
12109
+ productionId: 65
12027
12110
  },
12028
12111
  {
12029
12112
  state: 135,
12030
12113
  symbol: "bar",
12031
12114
  kind: "reduce",
12032
- productionId: 64
12115
+ productionId: 65
12033
12116
  },
12034
12117
  {
12035
12118
  state: 135,
@@ -12059,25 +12142,25 @@ var actions = [
12059
12142
  state: 135,
12060
12143
  symbol: "rbrace",
12061
12144
  kind: "reduce",
12062
- productionId: 64
12145
+ productionId: 65
12063
12146
  },
12064
12147
  {
12065
12148
  state: 135,
12066
12149
  symbol: "rbracket",
12067
12150
  kind: "reduce",
12068
- productionId: 64
12151
+ productionId: 65
12069
12152
  },
12070
12153
  {
12071
12154
  state: 135,
12072
12155
  symbol: "rpar",
12073
12156
  kind: "reduce",
12074
- productionId: 64
12157
+ productionId: 65
12075
12158
  },
12076
12159
  {
12077
12160
  state: 135,
12078
12161
  symbol: "semicolon",
12079
12162
  kind: "reduce",
12080
- productionId: 64
12163
+ productionId: 65
12081
12164
  },
12082
12165
  {
12083
12166
  state: 135,
@@ -12089,73 +12172,73 @@ var actions = [
12089
12172
  state: 136,
12090
12173
  symbol: "$eof",
12091
12174
  kind: "reduce",
12092
- productionId: 65
12175
+ productionId: 66
12093
12176
  },
12094
12177
  {
12095
12178
  state: 136,
12096
12179
  symbol: "bar",
12097
12180
  kind: "reduce",
12098
- productionId: 65
12181
+ productionId: 66
12099
12182
  },
12100
12183
  {
12101
12184
  state: 136,
12102
12185
  symbol: "rbrace",
12103
12186
  kind: "reduce",
12104
- productionId: 65
12187
+ productionId: 66
12105
12188
  },
12106
12189
  {
12107
12190
  state: 136,
12108
12191
  symbol: "rbracket",
12109
12192
  kind: "reduce",
12110
- productionId: 65
12193
+ productionId: 66
12111
12194
  },
12112
12195
  {
12113
12196
  state: 136,
12114
12197
  symbol: "rpar",
12115
12198
  kind: "reduce",
12116
- productionId: 65
12199
+ productionId: 66
12117
12200
  },
12118
12201
  {
12119
12202
  state: 136,
12120
12203
  symbol: "semicolon",
12121
12204
  kind: "reduce",
12122
- productionId: 65
12205
+ productionId: 66
12123
12206
  },
12124
12207
  {
12125
12208
  state: 137,
12126
12209
  symbol: "$eof",
12127
12210
  kind: "reduce",
12128
- productionId: 63
12211
+ productionId: 64
12129
12212
  },
12130
12213
  {
12131
12214
  state: 137,
12132
12215
  symbol: "bar",
12133
12216
  kind: "reduce",
12134
- productionId: 63
12217
+ productionId: 64
12135
12218
  },
12136
12219
  {
12137
12220
  state: 137,
12138
12221
  symbol: "rbrace",
12139
12222
  kind: "reduce",
12140
- productionId: 63
12223
+ productionId: 64
12141
12224
  },
12142
12225
  {
12143
12226
  state: 137,
12144
12227
  symbol: "rbracket",
12145
12228
  kind: "reduce",
12146
- productionId: 63
12229
+ productionId: 64
12147
12230
  },
12148
12231
  {
12149
12232
  state: 137,
12150
12233
  symbol: "rpar",
12151
12234
  kind: "reduce",
12152
- productionId: 63
12235
+ productionId: 64
12153
12236
  },
12154
12237
  {
12155
12238
  state: 137,
12156
12239
  symbol: "semicolon",
12157
12240
  kind: "reduce",
12158
- productionId: 63
12241
+ productionId: 64
12159
12242
  },
12160
12243
  {
12161
12244
  state: 138,
@@ -13262,6 +13345,10 @@ var ast = [
13262
13345
  }
13263
13346
  }
13264
13347
  ]
13348
+ },
13349
+ location: {
13350
+ offset: 4736,
13351
+ length: 50
13265
13352
  }
13266
13353
  },
13267
13354
  {
@@ -13280,6 +13367,10 @@ var ast = [
13280
13367
  }
13281
13368
  }
13282
13369
  ]
13370
+ },
13371
+ location: {
13372
+ offset: 4792,
13373
+ length: 56
13283
13374
  }
13284
13375
  },
13285
13376
  {
@@ -13298,6 +13389,10 @@ var ast = [
13298
13389
  }
13299
13390
  }
13300
13391
  ]
13392
+ },
13393
+ location: {
13394
+ offset: 4854,
13395
+ length: 55
13301
13396
  }
13302
13397
  },
13303
13398
  {
@@ -13316,6 +13411,10 @@ var ast = [
13316
13411
  }
13317
13412
  }
13318
13413
  ]
13414
+ },
13415
+ location: {
13416
+ offset: 4915,
13417
+ length: 59
13319
13418
  }
13320
13419
  },
13321
13420
  {
@@ -13334,6 +13433,10 @@ var ast = [
13334
13433
  }
13335
13434
  }
13336
13435
  ]
13436
+ },
13437
+ location: {
13438
+ offset: 4980,
13439
+ length: 47
13337
13440
  }
13338
13441
  },
13339
13442
  {
@@ -13352,6 +13455,10 @@ var ast = [
13352
13455
  }
13353
13456
  }
13354
13457
  ]
13458
+ },
13459
+ location: {
13460
+ offset: 5033,
13461
+ length: 59
13355
13462
  }
13356
13463
  },
13357
13464
  {
@@ -13370,6 +13477,10 @@ var ast = [
13370
13477
  }
13371
13478
  }
13372
13479
  ]
13480
+ },
13481
+ location: {
13482
+ offset: 5098,
13483
+ length: 66
13373
13484
  }
13374
13485
  },
13375
13486
  {
@@ -13388,6 +13499,10 @@ var ast = [
13388
13499
  }
13389
13500
  }
13390
13501
  ]
13502
+ },
13503
+ location: {
13504
+ offset: 5170,
13505
+ length: 56
13391
13506
  }
13392
13507
  },
13393
13508
  {
@@ -13406,6 +13521,10 @@ var ast = [
13406
13521
  }
13407
13522
  }
13408
13523
  ]
13524
+ },
13525
+ location: {
13526
+ offset: 5232,
13527
+ length: 52
13409
13528
  }
13410
13529
  },
13411
13530
  {
@@ -13424,6 +13543,10 @@ var ast = [
13424
13543
  }
13425
13544
  }
13426
13545
  ]
13546
+ },
13547
+ location: {
13548
+ offset: 5290,
13549
+ length: 44
13427
13550
  }
13428
13551
  }
13429
13552
  ];
@@ -13439,9 +13562,17 @@ var transform = [
13439
13562
  variant: "sections",
13440
13563
  head: "section",
13441
13564
  tail: "grammar_file$repeat_0"
13565
+ },
13566
+ location: {
13567
+ offset: 5383,
13568
+ length: 69
13442
13569
  }
13443
13570
  }
13444
- ]
13571
+ ],
13572
+ location: {
13573
+ offset: 5350,
13574
+ length: 104
13575
+ }
13445
13576
  },
13446
13577
  {
13447
13578
  production: "token_section",
@@ -13454,9 +13585,17 @@ var transform = [
13454
13585
  variant: "definitions",
13455
13586
  head: "token_def",
13456
13587
  tail: "token_section$repeat_1"
13588
+ },
13589
+ location: {
13590
+ offset: 5485,
13591
+ length: 76
13457
13592
  }
13458
13593
  }
13459
- ]
13594
+ ],
13595
+ location: {
13596
+ offset: 5460,
13597
+ length: 103
13598
+ }
13460
13599
  },
13461
13600
  {
13462
13601
  production: "skip_section",
@@ -13469,9 +13608,17 @@ var transform = [
13469
13608
  variant: "definitions",
13470
13609
  head: "token_def",
13471
13610
  tail: "skip_section$repeat_2"
13611
+ },
13612
+ location: {
13613
+ offset: 5593,
13614
+ length: 74
13472
13615
  }
13473
13616
  }
13474
- ]
13617
+ ],
13618
+ location: {
13619
+ offset: 5569,
13620
+ length: 100
13621
+ }
13475
13622
  },
13476
13623
  {
13477
13624
  production: "grammar_section",
@@ -13484,9 +13631,17 @@ var transform = [
13484
13631
  variant: "productions",
13485
13632
  head: "production",
13486
13633
  tail: "grammar_section$repeat_4"
13634
+ },
13635
+ location: {
13636
+ offset: 5702,
13637
+ length: 81
13487
13638
  }
13488
13639
  }
13489
- ]
13640
+ ],
13641
+ location: {
13642
+ offset: 5675,
13643
+ length: 110
13644
+ }
13490
13645
  },
13491
13646
  {
13492
13647
  production: "ast_section",
@@ -13499,9 +13654,17 @@ var transform = [
13499
13654
  variant: "types",
13500
13655
  head: "ast_type",
13501
13656
  tail: "ast_section$repeat_5"
13657
+ },
13658
+ location: {
13659
+ offset: 5814,
13660
+ length: 65
13502
13661
  }
13503
13662
  }
13504
- ]
13663
+ ],
13664
+ location: {
13665
+ offset: 5791,
13666
+ length: 90
13667
+ }
13505
13668
  },
13506
13669
  {
13507
13670
  production: "transform_section",
@@ -13514,9 +13677,17 @@ var transform = [
13514
13677
  variant: "rules",
13515
13678
  head: "transform_rule",
13516
13679
  tail: "transform_section$repeat_6"
13680
+ },
13681
+ location: {
13682
+ offset: 5916,
13683
+ length: 83
13517
13684
  }
13518
13685
  }
13519
- ]
13686
+ ],
13687
+ location: {
13688
+ offset: 5887,
13689
+ length: 114
13690
+ }
13520
13691
  },
13521
13692
  {
13522
13693
  production: "transform_rule",
@@ -13529,9 +13700,17 @@ var transform = [
13529
13700
  variant: "alternatives",
13530
13701
  head: "labeled_transform",
13531
13702
  tail: "transform_rule$repeat_7"
13703
+ },
13704
+ location: {
13705
+ offset: 6033,
13706
+ length: 87
13532
13707
  }
13533
13708
  }
13534
- ]
13709
+ ],
13710
+ location: {
13711
+ offset: 6007,
13712
+ length: 115
13713
+ }
13535
13714
  },
13536
13715
  {
13537
13716
  production: "reference_list",
@@ -13544,9 +13723,17 @@ var transform = [
13544
13723
  variant: "references",
13545
13724
  head: "reference",
13546
13725
  tail: "reference_list$repeat_8"
13726
+ },
13727
+ location: {
13728
+ offset: 6154,
13729
+ length: 77
13547
13730
  }
13548
13731
  }
13549
- ]
13732
+ ],
13733
+ location: {
13734
+ offset: 6128,
13735
+ length: 105
13736
+ }
13550
13737
  },
13551
13738
  {
13552
13739
  production: "choice",
@@ -13559,9 +13746,17 @@ var transform = [
13559
13746
  variant: "alternatives",
13560
13747
  head: "alternative",
13561
13748
  tail: "choice$repeat_9"
13749
+ },
13750
+ location: {
13751
+ offset: 6257,
13752
+ length: 65
13562
13753
  }
13563
13754
  }
13564
- ]
13755
+ ],
13756
+ location: {
13757
+ offset: 6239,
13758
+ length: 85
13759
+ }
13565
13760
  },
13566
13761
  {
13567
13762
  production: "sequence",
@@ -13574,9 +13769,17 @@ var transform = [
13574
13769
  variant: "factors",
13575
13770
  head: "factor",
13576
13771
  tail: "sequence$repeat_10"
13772
+ },
13773
+ location: {
13774
+ offset: 6350,
13775
+ length: 60
13577
13776
  }
13578
13777
  }
13579
- ]
13778
+ ],
13779
+ location: {
13780
+ offset: 6330,
13781
+ length: 82
13782
+ }
13580
13783
  }
13581
13784
  ];
13582
13785
  var grammarTableJson = {
@@ -13658,7 +13861,7 @@ function validateGrammarTable(grammar) {
13658
13861
  for (const rule of grammar.transformSchema.rules) {
13659
13862
  validateTransformProductionExists(rule, bnfProductionNames, issues);
13660
13863
  for (const alternative of rule.alternatives) {
13661
- validateTransformExpression(grammar, alternative, issues);
13864
+ validateTransformExpression(grammar, rule, alternative, issues);
13662
13865
  collectPassCollapseWarnings(grammar, rule, alternative, bnf.productions, issues);
13663
13866
  }
13664
13867
  }
@@ -13762,12 +13965,13 @@ function syntheticRepeatPrefix(name) {
13762
13965
  * @param alternative - Transform alternative owning the expression.
13763
13966
  * @param issues - Issue list to append to.
13764
13967
  */
13765
- function validateTransformExpression(grammar, alternative, issues) {
13968
+ function validateTransformExpression(grammar, rule, alternative, issues) {
13766
13969
  const expression = alternative.expression;
13767
13970
  const location = alternative.location ?? null;
13768
13971
  switch (expression.kind) {
13769
13972
  case 'build':
13770
13973
  validateAstTarget(grammar, expression.typeName, expression.variant, location, issues);
13974
+ validateBuildArity(grammar, rule, alternative, expression, location, issues);
13771
13975
  break;
13772
13976
  case 'foldLeft':
13773
13977
  case 'foldRight':
@@ -13776,6 +13980,130 @@ function validateTransformExpression(grammar, alternative, issues) {
13776
13980
  break;
13777
13981
  }
13778
13982
  }
13983
+ /**
13984
+ * Records an error when a build argument list conflicts with a zero-factor shape.
13985
+ *
13986
+ * @remarks
13987
+ * Build argument counts are not required to match grammar or AST slot counts in
13988
+ * general: keywords may be dropped, punctuation may be kept, and child
13989
+ * productions may build a shared parent AST variant. The only coherent checks
13990
+ * are zero-factor cases and empty builds targeting a non-empty AST variant.
13991
+ *
13992
+ * @param grammar - Parsed grammar model.
13993
+ * @param rule - Transform rule owning the build expression.
13994
+ * @param alternative - Transform alternative owning the build expression.
13995
+ * @param expression - Build transform expression.
13996
+ * @param location - Source span of the transform alternative.
13997
+ * @param issues - Issue list to append to.
13998
+ */
13999
+ function validateBuildArity(grammar, rule, alternative, expression, location, issues) {
14000
+ const argumentCount = expression.arguments.length;
14001
+ const production = grammar.production(rule.production);
14002
+ // Reject build arguments on a labeled zero-factor grammar alternative.
14003
+ if (production !== null) {
14004
+ const alternativeExpression = findGrammarAlternativeExpression(production.expression, alternative.label);
14005
+ if (alternativeExpression !== null
14006
+ && isZeroFactorExpression(alternativeExpression)
14007
+ && argumentCount > 0) {
14008
+ issues.push({
14009
+ severity: 'error',
14010
+ message: `transform ${expression.typeName}.${expression.variant} has `
14011
+ + `${String(argumentCount)} argument(s) but ast variant declares 0`,
14012
+ location,
14013
+ });
14014
+ return;
14015
+ }
14016
+ }
14017
+ if (grammar.astSchema === null) {
14018
+ return;
14019
+ }
14020
+ const astType = grammar.astSchema.type(expression.typeName);
14021
+ if (astType === null) {
14022
+ return;
14023
+ }
14024
+ const variantExpression = findAstVariantExpression(astType.expression, expression.variant);
14025
+ if (variantExpression === null) {
14026
+ return;
14027
+ }
14028
+ // Reject build arguments on a zero-factor AST variant.
14029
+ if (isZeroFactorExpression(variantExpression)) {
14030
+ if (argumentCount > 0) {
14031
+ issues.push({
14032
+ severity: 'error',
14033
+ message: `transform ${expression.typeName}.${expression.variant} has `
14034
+ + `${String(argumentCount)} argument(s) but ast variant declares 0`,
14035
+ location,
14036
+ });
14037
+ }
14038
+ return;
14039
+ }
14040
+ // Reject empty builds that target a non-empty AST variant.
14041
+ if (argumentCount === 0) {
14042
+ issues.push({
14043
+ severity: 'error',
14044
+ message: `transform ${expression.typeName}.${expression.variant} has `
14045
+ + `0 argument(s) but ast variant requires 1`,
14046
+ location,
14047
+ });
14048
+ }
14049
+ }
14050
+ /**
14051
+ * Returns whether an expression is a labeled zero-factor alternative.
14052
+ *
14053
+ * @param expression - Grammar or AST alternative expression.
14054
+ */
14055
+ function isZeroFactorExpression(expression) {
14056
+ return expression.kind === 'sequence' && expression.elements.length === 0;
14057
+ }
14058
+ /**
14059
+ * Returns the expression for one labeled grammar alternative.
14060
+ *
14061
+ * @param expression - Production right-hand side expression.
14062
+ * @param label - Transform alternative label.
14063
+ */
14064
+ function findGrammarAlternativeExpression(expression, label) {
14065
+ if (expression.kind === 'choice') {
14066
+ for (const alternative of expression.alternatives) {
14067
+ if (alternative.label === label) {
14068
+ return alternative.expression;
14069
+ }
14070
+ }
14071
+ if (label === 'main' && expression.alternatives.length === 1) {
14072
+ return expression.alternatives[0]?.expression ?? null;
14073
+ }
14074
+ return null;
14075
+ }
14076
+ if (label === 'main') {
14077
+ return expression;
14078
+ }
14079
+ return null;
14080
+ }
14081
+ /**
14082
+ * Returns the expression for one labeled AST alternative.
14083
+ *
14084
+ * @param expression - AST type right-hand side.
14085
+ * @param variant - Variant label to find.
14086
+ */
14087
+ function findAstVariantExpression(expression, variant) {
14088
+ if (expression.kind === 'choice') {
14089
+ for (const alternative of expression.alternatives) {
14090
+ if (alternative.label === variant) {
14091
+ return alternative.expression;
14092
+ }
14093
+ }
14094
+ return null;
14095
+ }
14096
+ if (expression.kind === 'sequence' || expression.kind === 'group') {
14097
+ const inner = expression.kind === 'sequence'
14098
+ ? expression.elements[0]
14099
+ : expression.element;
14100
+ if (inner === undefined) {
14101
+ return null;
14102
+ }
14103
+ return findAstVariantExpression(inner, variant);
14104
+ }
14105
+ return null;
14106
+ }
13779
14107
  /**
13780
14108
  * Records an error when a transform references an undefined AST type or variant.
13781
14109
  *