parser-lr 0.3.1 → 0.4.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/README.md +6 -6
- package/bin/parser-lr.js +1100 -16
- package/bin/parser-lr.js.map +1 -1
- package/dist/lib/grammar/grammar.json +1068 -0
- package/dist/lib/parse-context.d.ts +6 -6
- package/dist/lib/parse-context.js +6 -6
- package/dist/lib/parse-table/parse-table-json.d.ts +4 -0
- package/dist/lib/parse-table/parse-table-json.d.ts.map +1 -1
- package/dist/lib/parse-table/parse-table-json.js.map +1 -1
- package/dist/lib/parse-table/parse-table.d.ts +13 -3
- package/dist/lib/parse-table/parse-table.d.ts.map +1 -1
- package/dist/lib/parse-table/parse-table.js +22 -6
- package/dist/lib/parse-table/parse-table.js.map +1 -1
- package/dist/lib/parser-lr.d.ts +2 -2
- package/dist/lib/parser-lr.js +2 -2
- package/docs/grammar.md +2 -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.4.0";
|
|
3785
3785
|
var packageDefinition = {
|
|
3786
3786
|
version: version$1};
|
|
3787
3787
|
|
|
@@ -7240,6 +7240,8 @@ class ParseTable {
|
|
|
7240
7240
|
algorithm;
|
|
7241
7241
|
parserStateCount;
|
|
7242
7242
|
conflicts;
|
|
7243
|
+
astSchema;
|
|
7244
|
+
transformSchema;
|
|
7243
7245
|
actionByState;
|
|
7244
7246
|
gotoByState;
|
|
7245
7247
|
productionById;
|
|
@@ -7258,8 +7260,10 @@ class ParseTable {
|
|
|
7258
7260
|
* @param actions - ACTION entries keyed by state and terminal symbol.
|
|
7259
7261
|
* @param gotos - GOTO entries keyed by state and non-terminal name.
|
|
7260
7262
|
* @param conflicts - Shift/reduce and reduce/reduce conflicts resolved during construction.
|
|
7263
|
+
* @param astSchema - AST types from the `ast` section, or null when absent.
|
|
7264
|
+
* @param transformSchema - CST-to-AST rules from the `transform` section, or null when absent.
|
|
7261
7265
|
*/
|
|
7262
|
-
constructor(grammarName, startSymbol, tokens, tokenRules, skipRules, states, algorithm, parserStateCount = 0, productions = [], actions = new Map(), gotos = new Map(), conflicts = []) {
|
|
7266
|
+
constructor(grammarName, startSymbol, tokens, tokenRules, skipRules, states, algorithm, parserStateCount = 0, productions = [], actions = new Map(), gotos = new Map(), conflicts = [], astSchema = null, transformSchema = null) {
|
|
7263
7267
|
this.grammarName = grammarName;
|
|
7264
7268
|
this.startSymbol = startSymbol;
|
|
7265
7269
|
this.tokens = tokens;
|
|
@@ -7269,6 +7273,8 @@ class ParseTable {
|
|
|
7269
7273
|
this.algorithm = algorithm;
|
|
7270
7274
|
this.parserStateCount = parserStateCount;
|
|
7271
7275
|
this.conflicts = conflicts;
|
|
7276
|
+
this.astSchema = astSchema;
|
|
7277
|
+
this.transformSchema = transformSchema;
|
|
7272
7278
|
this.actionByState = actions;
|
|
7273
7279
|
this.gotoByState = gotos;
|
|
7274
7280
|
const productionById = new Map();
|
|
@@ -7321,7 +7327,13 @@ class ParseTable {
|
|
|
7321
7327
|
if (!isParseTableJsonV2(json)) {
|
|
7322
7328
|
return new ParseTable(json.grammarName, json.startSymbol, [...json.tokens], [...json.tokenRules], [...json.skipRules], [...json.states], json.algorithm);
|
|
7323
7329
|
}
|
|
7324
|
-
|
|
7330
|
+
const astSchema = json.ast === undefined
|
|
7331
|
+
? null
|
|
7332
|
+
: new AstSchema([...json.ast]);
|
|
7333
|
+
const transformSchema = json.transform === undefined
|
|
7334
|
+
? null
|
|
7335
|
+
: new TransformSchema([...json.transform]);
|
|
7336
|
+
return new ParseTable(json.grammarName, json.startSymbol, [...json.tokens], [...json.tokenRules], [...json.skipRules], [...json.states], json.algorithm, json.parserStateCount, [...json.productions], ParseTable.actionsFromJson(json.actions), ParseTable.gotosFromJson(json.gotos), [], astSchema, transformSchema);
|
|
7325
7337
|
}
|
|
7326
7338
|
/**
|
|
7327
7339
|
* Parses a parse table from a JSON string.
|
|
@@ -7379,16 +7391,18 @@ class ParseTable {
|
|
|
7379
7391
|
productions: [...this.productionById.values()].sort((left, right) => left.id - right.id),
|
|
7380
7392
|
actions: ParseTable.actionsToJson(this.actionByState),
|
|
7381
7393
|
gotos: ParseTable.gotosToJson(this.gotoByState),
|
|
7394
|
+
...(this.astSchema === null ? {} : { ast: [...this.astSchema.types] }),
|
|
7395
|
+
...(this.transformSchema === null ? {} : { transform: [...this.transformSchema.rules] }),
|
|
7382
7396
|
};
|
|
7383
7397
|
return json;
|
|
7384
7398
|
}
|
|
7385
7399
|
/**
|
|
7386
|
-
* Builds a grammar
|
|
7400
|
+
* Builds a grammar from this table, including AST and transform schemas when present.
|
|
7387
7401
|
*
|
|
7388
|
-
* @returns A grammar suitable for lexing
|
|
7402
|
+
* @returns A grammar suitable for lexing and CST-to-AST transforms.
|
|
7389
7403
|
*/
|
|
7390
7404
|
toGrammar() {
|
|
7391
|
-
return new Grammar(this.grammarName, this.tokenRules, this.skipRules, this.states, this.startSymbol, []);
|
|
7405
|
+
return new Grammar(this.grammarName, this.tokenRules, this.skipRules, this.states, this.startSymbol, [], this.astSchema, this.transformSchema);
|
|
7392
7406
|
}
|
|
7393
7407
|
/**
|
|
7394
7408
|
* Returns the ACTION entry for a parser state and terminal symbol key.
|
|
@@ -7430,7 +7444,7 @@ class ParseTable {
|
|
|
7430
7444
|
variant: production.variant,
|
|
7431
7445
|
origin: production.origin,
|
|
7432
7446
|
}));
|
|
7433
|
-
return new ParseTable(grammar.name, grammar.startSymbol, tokenInventory(grammar), [...grammar.tokenRules], [...grammar.skipRules], [...grammar.states], lrTable.algorithm, lrTable.stateCount, productions, lrTable.actions, lrTable.gotos, [...lrTable.conflicts]);
|
|
7447
|
+
return new ParseTable(grammar.name, grammar.startSymbol, tokenInventory(grammar), [...grammar.tokenRules], [...grammar.skipRules], [...grammar.states], lrTable.algorithm, lrTable.stateCount, productions, lrTable.actions, lrTable.gotos, [...lrTable.conflicts], grammar.astSchema, grammar.transformSchema);
|
|
7434
7448
|
}
|
|
7435
7449
|
/**
|
|
7436
7450
|
* Converts ACTION maps into JSON rows.
|
|
@@ -15501,6 +15515,1074 @@ var gotos = [
|
|
|
15501
15515
|
target: 129
|
|
15502
15516
|
}
|
|
15503
15517
|
];
|
|
15518
|
+
var ast = [
|
|
15519
|
+
{
|
|
15520
|
+
name: "grammar_file",
|
|
15521
|
+
expression: {
|
|
15522
|
+
kind: "sequence",
|
|
15523
|
+
elements: [
|
|
15524
|
+
{
|
|
15525
|
+
kind: "reference",
|
|
15526
|
+
name: "name_decl"
|
|
15527
|
+
},
|
|
15528
|
+
{
|
|
15529
|
+
kind: "repeat",
|
|
15530
|
+
element: {
|
|
15531
|
+
kind: "reference",
|
|
15532
|
+
name: "section"
|
|
15533
|
+
}
|
|
15534
|
+
},
|
|
15535
|
+
{
|
|
15536
|
+
kind: "reference",
|
|
15537
|
+
name: "start_decl"
|
|
15538
|
+
},
|
|
15539
|
+
{
|
|
15540
|
+
kind: "reference",
|
|
15541
|
+
name: "grammar_section"
|
|
15542
|
+
},
|
|
15543
|
+
{
|
|
15544
|
+
kind: "optional",
|
|
15545
|
+
element: {
|
|
15546
|
+
kind: "reference",
|
|
15547
|
+
name: "ast_section"
|
|
15548
|
+
}
|
|
15549
|
+
},
|
|
15550
|
+
{
|
|
15551
|
+
kind: "optional",
|
|
15552
|
+
element: {
|
|
15553
|
+
kind: "reference",
|
|
15554
|
+
name: "transform_section"
|
|
15555
|
+
}
|
|
15556
|
+
}
|
|
15557
|
+
]
|
|
15558
|
+
}
|
|
15559
|
+
},
|
|
15560
|
+
{
|
|
15561
|
+
name: "name_decl",
|
|
15562
|
+
expression: {
|
|
15563
|
+
kind: "sequence",
|
|
15564
|
+
elements: [
|
|
15565
|
+
{
|
|
15566
|
+
kind: "reference",
|
|
15567
|
+
name: "name_kw"
|
|
15568
|
+
},
|
|
15569
|
+
{
|
|
15570
|
+
kind: "reference",
|
|
15571
|
+
name: "grammar_name"
|
|
15572
|
+
},
|
|
15573
|
+
{
|
|
15574
|
+
kind: "reference",
|
|
15575
|
+
name: "semicolon"
|
|
15576
|
+
}
|
|
15577
|
+
]
|
|
15578
|
+
}
|
|
15579
|
+
},
|
|
15580
|
+
{
|
|
15581
|
+
name: "grammar_name",
|
|
15582
|
+
expression: {
|
|
15583
|
+
kind: "choice",
|
|
15584
|
+
alternatives: [
|
|
15585
|
+
{
|
|
15586
|
+
label: null,
|
|
15587
|
+
expression: {
|
|
15588
|
+
kind: "reference",
|
|
15589
|
+
name: "identifier"
|
|
15590
|
+
}
|
|
15591
|
+
},
|
|
15592
|
+
{
|
|
15593
|
+
label: null,
|
|
15594
|
+
expression: {
|
|
15595
|
+
kind: "reference",
|
|
15596
|
+
name: "string_literal"
|
|
15597
|
+
}
|
|
15598
|
+
}
|
|
15599
|
+
]
|
|
15600
|
+
}
|
|
15601
|
+
},
|
|
15602
|
+
{
|
|
15603
|
+
name: "section",
|
|
15604
|
+
expression: {
|
|
15605
|
+
kind: "choice",
|
|
15606
|
+
alternatives: [
|
|
15607
|
+
{
|
|
15608
|
+
label: null,
|
|
15609
|
+
expression: {
|
|
15610
|
+
kind: "reference",
|
|
15611
|
+
name: "token_section"
|
|
15612
|
+
}
|
|
15613
|
+
},
|
|
15614
|
+
{
|
|
15615
|
+
label: null,
|
|
15616
|
+
expression: {
|
|
15617
|
+
kind: "reference",
|
|
15618
|
+
name: "skip_section"
|
|
15619
|
+
}
|
|
15620
|
+
},
|
|
15621
|
+
{
|
|
15622
|
+
label: null,
|
|
15623
|
+
expression: {
|
|
15624
|
+
kind: "reference",
|
|
15625
|
+
name: "states_section"
|
|
15626
|
+
}
|
|
15627
|
+
}
|
|
15628
|
+
]
|
|
15629
|
+
}
|
|
15630
|
+
},
|
|
15631
|
+
{
|
|
15632
|
+
name: "token_section",
|
|
15633
|
+
expression: {
|
|
15634
|
+
kind: "sequence",
|
|
15635
|
+
elements: [
|
|
15636
|
+
{
|
|
15637
|
+
kind: "reference",
|
|
15638
|
+
name: "tokens_kw"
|
|
15639
|
+
},
|
|
15640
|
+
{
|
|
15641
|
+
kind: "reference",
|
|
15642
|
+
name: "token_def"
|
|
15643
|
+
},
|
|
15644
|
+
{
|
|
15645
|
+
kind: "repeat",
|
|
15646
|
+
element: {
|
|
15647
|
+
kind: "reference",
|
|
15648
|
+
name: "token_def"
|
|
15649
|
+
}
|
|
15650
|
+
}
|
|
15651
|
+
]
|
|
15652
|
+
}
|
|
15653
|
+
},
|
|
15654
|
+
{
|
|
15655
|
+
name: "skip_section",
|
|
15656
|
+
expression: {
|
|
15657
|
+
kind: "sequence",
|
|
15658
|
+
elements: [
|
|
15659
|
+
{
|
|
15660
|
+
kind: "reference",
|
|
15661
|
+
name: "skip_kw"
|
|
15662
|
+
},
|
|
15663
|
+
{
|
|
15664
|
+
kind: "reference",
|
|
15665
|
+
name: "token_def"
|
|
15666
|
+
},
|
|
15667
|
+
{
|
|
15668
|
+
kind: "repeat",
|
|
15669
|
+
element: {
|
|
15670
|
+
kind: "reference",
|
|
15671
|
+
name: "token_def"
|
|
15672
|
+
}
|
|
15673
|
+
}
|
|
15674
|
+
]
|
|
15675
|
+
}
|
|
15676
|
+
},
|
|
15677
|
+
{
|
|
15678
|
+
name: "states_section",
|
|
15679
|
+
expression: {
|
|
15680
|
+
kind: "sequence",
|
|
15681
|
+
elements: [
|
|
15682
|
+
{
|
|
15683
|
+
kind: "reference",
|
|
15684
|
+
name: "states_kw"
|
|
15685
|
+
},
|
|
15686
|
+
{
|
|
15687
|
+
kind: "reference",
|
|
15688
|
+
name: "state_name"
|
|
15689
|
+
},
|
|
15690
|
+
{
|
|
15691
|
+
kind: "repeat",
|
|
15692
|
+
element: {
|
|
15693
|
+
kind: "sequence",
|
|
15694
|
+
elements: [
|
|
15695
|
+
{
|
|
15696
|
+
kind: "reference",
|
|
15697
|
+
name: "comma"
|
|
15698
|
+
},
|
|
15699
|
+
{
|
|
15700
|
+
kind: "reference",
|
|
15701
|
+
name: "state_name"
|
|
15702
|
+
}
|
|
15703
|
+
]
|
|
15704
|
+
}
|
|
15705
|
+
},
|
|
15706
|
+
{
|
|
15707
|
+
kind: "reference",
|
|
15708
|
+
name: "semicolon"
|
|
15709
|
+
}
|
|
15710
|
+
]
|
|
15711
|
+
}
|
|
15712
|
+
},
|
|
15713
|
+
{
|
|
15714
|
+
name: "token_def",
|
|
15715
|
+
expression: {
|
|
15716
|
+
kind: "sequence",
|
|
15717
|
+
elements: [
|
|
15718
|
+
{
|
|
15719
|
+
kind: "reference",
|
|
15720
|
+
name: "identifier"
|
|
15721
|
+
},
|
|
15722
|
+
{
|
|
15723
|
+
kind: "reference",
|
|
15724
|
+
name: "equal"
|
|
15725
|
+
},
|
|
15726
|
+
{
|
|
15727
|
+
kind: "reference",
|
|
15728
|
+
name: "regex_literal"
|
|
15729
|
+
},
|
|
15730
|
+
{
|
|
15731
|
+
kind: "reference",
|
|
15732
|
+
name: "semicolon"
|
|
15733
|
+
}
|
|
15734
|
+
]
|
|
15735
|
+
}
|
|
15736
|
+
},
|
|
15737
|
+
{
|
|
15738
|
+
name: "state_name",
|
|
15739
|
+
expression: {
|
|
15740
|
+
kind: "reference",
|
|
15741
|
+
name: "identifier"
|
|
15742
|
+
}
|
|
15743
|
+
},
|
|
15744
|
+
{
|
|
15745
|
+
name: "start_decl",
|
|
15746
|
+
expression: {
|
|
15747
|
+
kind: "sequence",
|
|
15748
|
+
elements: [
|
|
15749
|
+
{
|
|
15750
|
+
kind: "reference",
|
|
15751
|
+
name: "start_kw"
|
|
15752
|
+
},
|
|
15753
|
+
{
|
|
15754
|
+
kind: "reference",
|
|
15755
|
+
name: "identifier"
|
|
15756
|
+
},
|
|
15757
|
+
{
|
|
15758
|
+
kind: "reference",
|
|
15759
|
+
name: "semicolon"
|
|
15760
|
+
}
|
|
15761
|
+
]
|
|
15762
|
+
}
|
|
15763
|
+
},
|
|
15764
|
+
{
|
|
15765
|
+
name: "grammar_section",
|
|
15766
|
+
expression: {
|
|
15767
|
+
kind: "sequence",
|
|
15768
|
+
elements: [
|
|
15769
|
+
{
|
|
15770
|
+
kind: "reference",
|
|
15771
|
+
name: "grammar_kw"
|
|
15772
|
+
},
|
|
15773
|
+
{
|
|
15774
|
+
kind: "reference",
|
|
15775
|
+
name: "production"
|
|
15776
|
+
},
|
|
15777
|
+
{
|
|
15778
|
+
kind: "repeat",
|
|
15779
|
+
element: {
|
|
15780
|
+
kind: "reference",
|
|
15781
|
+
name: "production"
|
|
15782
|
+
}
|
|
15783
|
+
}
|
|
15784
|
+
]
|
|
15785
|
+
}
|
|
15786
|
+
},
|
|
15787
|
+
{
|
|
15788
|
+
name: "ast_section",
|
|
15789
|
+
expression: {
|
|
15790
|
+
kind: "sequence",
|
|
15791
|
+
elements: [
|
|
15792
|
+
{
|
|
15793
|
+
kind: "reference",
|
|
15794
|
+
name: "ast_kw"
|
|
15795
|
+
},
|
|
15796
|
+
{
|
|
15797
|
+
kind: "reference",
|
|
15798
|
+
name: "ast_type"
|
|
15799
|
+
},
|
|
15800
|
+
{
|
|
15801
|
+
kind: "repeat",
|
|
15802
|
+
element: {
|
|
15803
|
+
kind: "reference",
|
|
15804
|
+
name: "ast_type"
|
|
15805
|
+
}
|
|
15806
|
+
}
|
|
15807
|
+
]
|
|
15808
|
+
}
|
|
15809
|
+
},
|
|
15810
|
+
{
|
|
15811
|
+
name: "transform_section",
|
|
15812
|
+
expression: {
|
|
15813
|
+
kind: "sequence",
|
|
15814
|
+
elements: [
|
|
15815
|
+
{
|
|
15816
|
+
kind: "reference",
|
|
15817
|
+
name: "transform_kw"
|
|
15818
|
+
},
|
|
15819
|
+
{
|
|
15820
|
+
kind: "reference",
|
|
15821
|
+
name: "transform_rule"
|
|
15822
|
+
},
|
|
15823
|
+
{
|
|
15824
|
+
kind: "repeat",
|
|
15825
|
+
element: {
|
|
15826
|
+
kind: "reference",
|
|
15827
|
+
name: "transform_rule"
|
|
15828
|
+
}
|
|
15829
|
+
}
|
|
15830
|
+
]
|
|
15831
|
+
}
|
|
15832
|
+
},
|
|
15833
|
+
{
|
|
15834
|
+
name: "production",
|
|
15835
|
+
expression: {
|
|
15836
|
+
kind: "sequence",
|
|
15837
|
+
elements: [
|
|
15838
|
+
{
|
|
15839
|
+
kind: "reference",
|
|
15840
|
+
name: "identifier"
|
|
15841
|
+
},
|
|
15842
|
+
{
|
|
15843
|
+
kind: "reference",
|
|
15844
|
+
name: "equal"
|
|
15845
|
+
},
|
|
15846
|
+
{
|
|
15847
|
+
kind: "reference",
|
|
15848
|
+
name: "expression"
|
|
15849
|
+
},
|
|
15850
|
+
{
|
|
15851
|
+
kind: "reference",
|
|
15852
|
+
name: "semicolon"
|
|
15853
|
+
}
|
|
15854
|
+
]
|
|
15855
|
+
}
|
|
15856
|
+
},
|
|
15857
|
+
{
|
|
15858
|
+
name: "ast_type",
|
|
15859
|
+
expression: {
|
|
15860
|
+
kind: "sequence",
|
|
15861
|
+
elements: [
|
|
15862
|
+
{
|
|
15863
|
+
kind: "reference",
|
|
15864
|
+
name: "identifier"
|
|
15865
|
+
},
|
|
15866
|
+
{
|
|
15867
|
+
kind: "reference",
|
|
15868
|
+
name: "equal"
|
|
15869
|
+
},
|
|
15870
|
+
{
|
|
15871
|
+
kind: "reference",
|
|
15872
|
+
name: "expression"
|
|
15873
|
+
},
|
|
15874
|
+
{
|
|
15875
|
+
kind: "reference",
|
|
15876
|
+
name: "semicolon"
|
|
15877
|
+
}
|
|
15878
|
+
]
|
|
15879
|
+
}
|
|
15880
|
+
},
|
|
15881
|
+
{
|
|
15882
|
+
name: "transform_rule",
|
|
15883
|
+
expression: {
|
|
15884
|
+
kind: "sequence",
|
|
15885
|
+
elements: [
|
|
15886
|
+
{
|
|
15887
|
+
kind: "reference",
|
|
15888
|
+
name: "identifier"
|
|
15889
|
+
},
|
|
15890
|
+
{
|
|
15891
|
+
kind: "reference",
|
|
15892
|
+
name: "arrow"
|
|
15893
|
+
},
|
|
15894
|
+
{
|
|
15895
|
+
kind: "reference",
|
|
15896
|
+
name: "labeled_transform"
|
|
15897
|
+
},
|
|
15898
|
+
{
|
|
15899
|
+
kind: "repeat",
|
|
15900
|
+
element: {
|
|
15901
|
+
kind: "sequence",
|
|
15902
|
+
elements: [
|
|
15903
|
+
{
|
|
15904
|
+
kind: "reference",
|
|
15905
|
+
name: "bar"
|
|
15906
|
+
},
|
|
15907
|
+
{
|
|
15908
|
+
kind: "reference",
|
|
15909
|
+
name: "labeled_transform"
|
|
15910
|
+
}
|
|
15911
|
+
]
|
|
15912
|
+
}
|
|
15913
|
+
},
|
|
15914
|
+
{
|
|
15915
|
+
kind: "reference",
|
|
15916
|
+
name: "semicolon"
|
|
15917
|
+
}
|
|
15918
|
+
]
|
|
15919
|
+
}
|
|
15920
|
+
},
|
|
15921
|
+
{
|
|
15922
|
+
name: "labeled_transform",
|
|
15923
|
+
expression: {
|
|
15924
|
+
kind: "sequence",
|
|
15925
|
+
elements: [
|
|
15926
|
+
{
|
|
15927
|
+
kind: "reference",
|
|
15928
|
+
name: "hash"
|
|
15929
|
+
},
|
|
15930
|
+
{
|
|
15931
|
+
kind: "reference",
|
|
15932
|
+
name: "identifier"
|
|
15933
|
+
},
|
|
15934
|
+
{
|
|
15935
|
+
kind: "reference",
|
|
15936
|
+
name: "transform_expr"
|
|
15937
|
+
}
|
|
15938
|
+
]
|
|
15939
|
+
}
|
|
15940
|
+
},
|
|
15941
|
+
{
|
|
15942
|
+
name: "transform_expr",
|
|
15943
|
+
expression: {
|
|
15944
|
+
kind: "choice",
|
|
15945
|
+
alternatives: [
|
|
15946
|
+
{
|
|
15947
|
+
label: null,
|
|
15948
|
+
expression: {
|
|
15949
|
+
kind: "reference",
|
|
15950
|
+
name: "drop_kw"
|
|
15951
|
+
}
|
|
15952
|
+
},
|
|
15953
|
+
{
|
|
15954
|
+
label: null,
|
|
15955
|
+
expression: {
|
|
15956
|
+
kind: "reference",
|
|
15957
|
+
name: "pass_expr"
|
|
15958
|
+
}
|
|
15959
|
+
},
|
|
15960
|
+
{
|
|
15961
|
+
label: null,
|
|
15962
|
+
expression: {
|
|
15963
|
+
kind: "reference",
|
|
15964
|
+
name: "fold_left_expr"
|
|
15965
|
+
}
|
|
15966
|
+
},
|
|
15967
|
+
{
|
|
15968
|
+
label: null,
|
|
15969
|
+
expression: {
|
|
15970
|
+
kind: "reference",
|
|
15971
|
+
name: "fold_right_expr"
|
|
15972
|
+
}
|
|
15973
|
+
},
|
|
15974
|
+
{
|
|
15975
|
+
label: null,
|
|
15976
|
+
expression: {
|
|
15977
|
+
kind: "reference",
|
|
15978
|
+
name: "flatten_expr"
|
|
15979
|
+
}
|
|
15980
|
+
},
|
|
15981
|
+
{
|
|
15982
|
+
label: null,
|
|
15983
|
+
expression: {
|
|
15984
|
+
kind: "reference",
|
|
15985
|
+
name: "build_expr"
|
|
15986
|
+
}
|
|
15987
|
+
}
|
|
15988
|
+
]
|
|
15989
|
+
}
|
|
15990
|
+
},
|
|
15991
|
+
{
|
|
15992
|
+
name: "pass_expr",
|
|
15993
|
+
expression: {
|
|
15994
|
+
kind: "sequence",
|
|
15995
|
+
elements: [
|
|
15996
|
+
{
|
|
15997
|
+
kind: "reference",
|
|
15998
|
+
name: "pass_kw"
|
|
15999
|
+
},
|
|
16000
|
+
{
|
|
16001
|
+
kind: "reference",
|
|
16002
|
+
name: "lpar"
|
|
16003
|
+
},
|
|
16004
|
+
{
|
|
16005
|
+
kind: "reference",
|
|
16006
|
+
name: "reference"
|
|
16007
|
+
},
|
|
16008
|
+
{
|
|
16009
|
+
kind: "reference",
|
|
16010
|
+
name: "rpar"
|
|
16011
|
+
}
|
|
16012
|
+
]
|
|
16013
|
+
}
|
|
16014
|
+
},
|
|
16015
|
+
{
|
|
16016
|
+
name: "fold_left_expr",
|
|
16017
|
+
expression: {
|
|
16018
|
+
kind: "sequence",
|
|
16019
|
+
elements: [
|
|
16020
|
+
{
|
|
16021
|
+
kind: "reference",
|
|
16022
|
+
name: "fold_left_kw"
|
|
16023
|
+
},
|
|
16024
|
+
{
|
|
16025
|
+
kind: "reference",
|
|
16026
|
+
name: "lpar"
|
|
16027
|
+
},
|
|
16028
|
+
{
|
|
16029
|
+
kind: "reference",
|
|
16030
|
+
name: "build_target"
|
|
16031
|
+
},
|
|
16032
|
+
{
|
|
16033
|
+
kind: "reference",
|
|
16034
|
+
name: "comma"
|
|
16035
|
+
},
|
|
16036
|
+
{
|
|
16037
|
+
kind: "reference",
|
|
16038
|
+
name: "reference_list"
|
|
16039
|
+
},
|
|
16040
|
+
{
|
|
16041
|
+
kind: "reference",
|
|
16042
|
+
name: "rpar"
|
|
16043
|
+
}
|
|
16044
|
+
]
|
|
16045
|
+
}
|
|
16046
|
+
},
|
|
16047
|
+
{
|
|
16048
|
+
name: "fold_right_expr",
|
|
16049
|
+
expression: {
|
|
16050
|
+
kind: "sequence",
|
|
16051
|
+
elements: [
|
|
16052
|
+
{
|
|
16053
|
+
kind: "reference",
|
|
16054
|
+
name: "fold_right_kw"
|
|
16055
|
+
},
|
|
16056
|
+
{
|
|
16057
|
+
kind: "reference",
|
|
16058
|
+
name: "lpar"
|
|
16059
|
+
},
|
|
16060
|
+
{
|
|
16061
|
+
kind: "reference",
|
|
16062
|
+
name: "build_target"
|
|
16063
|
+
},
|
|
16064
|
+
{
|
|
16065
|
+
kind: "reference",
|
|
16066
|
+
name: "comma"
|
|
16067
|
+
},
|
|
16068
|
+
{
|
|
16069
|
+
kind: "reference",
|
|
16070
|
+
name: "reference_list"
|
|
16071
|
+
},
|
|
16072
|
+
{
|
|
16073
|
+
kind: "reference",
|
|
16074
|
+
name: "rpar"
|
|
16075
|
+
}
|
|
16076
|
+
]
|
|
16077
|
+
}
|
|
16078
|
+
},
|
|
16079
|
+
{
|
|
16080
|
+
name: "flatten_expr",
|
|
16081
|
+
expression: {
|
|
16082
|
+
kind: "sequence",
|
|
16083
|
+
elements: [
|
|
16084
|
+
{
|
|
16085
|
+
kind: "reference",
|
|
16086
|
+
name: "flatten_kw"
|
|
16087
|
+
},
|
|
16088
|
+
{
|
|
16089
|
+
kind: "reference",
|
|
16090
|
+
name: "lpar"
|
|
16091
|
+
},
|
|
16092
|
+
{
|
|
16093
|
+
kind: "reference",
|
|
16094
|
+
name: "build_target"
|
|
16095
|
+
},
|
|
16096
|
+
{
|
|
16097
|
+
kind: "reference",
|
|
16098
|
+
name: "comma"
|
|
16099
|
+
},
|
|
16100
|
+
{
|
|
16101
|
+
kind: "reference",
|
|
16102
|
+
name: "reference"
|
|
16103
|
+
},
|
|
16104
|
+
{
|
|
16105
|
+
kind: "reference",
|
|
16106
|
+
name: "comma"
|
|
16107
|
+
},
|
|
16108
|
+
{
|
|
16109
|
+
kind: "reference",
|
|
16110
|
+
name: "reference"
|
|
16111
|
+
},
|
|
16112
|
+
{
|
|
16113
|
+
kind: "reference",
|
|
16114
|
+
name: "rpar"
|
|
16115
|
+
}
|
|
16116
|
+
]
|
|
16117
|
+
}
|
|
16118
|
+
},
|
|
16119
|
+
{
|
|
16120
|
+
name: "build_expr",
|
|
16121
|
+
expression: {
|
|
16122
|
+
kind: "sequence",
|
|
16123
|
+
elements: [
|
|
16124
|
+
{
|
|
16125
|
+
kind: "reference",
|
|
16126
|
+
name: "build_target"
|
|
16127
|
+
},
|
|
16128
|
+
{
|
|
16129
|
+
kind: "optional",
|
|
16130
|
+
element: {
|
|
16131
|
+
kind: "sequence",
|
|
16132
|
+
elements: [
|
|
16133
|
+
{
|
|
16134
|
+
kind: "reference",
|
|
16135
|
+
name: "lpar"
|
|
16136
|
+
},
|
|
16137
|
+
{
|
|
16138
|
+
kind: "reference",
|
|
16139
|
+
name: "reference_list"
|
|
16140
|
+
},
|
|
16141
|
+
{
|
|
16142
|
+
kind: "reference",
|
|
16143
|
+
name: "rpar"
|
|
16144
|
+
}
|
|
16145
|
+
]
|
|
16146
|
+
}
|
|
16147
|
+
}
|
|
16148
|
+
]
|
|
16149
|
+
}
|
|
16150
|
+
},
|
|
16151
|
+
{
|
|
16152
|
+
name: "build_target",
|
|
16153
|
+
expression: {
|
|
16154
|
+
kind: "sequence",
|
|
16155
|
+
elements: [
|
|
16156
|
+
{
|
|
16157
|
+
kind: "reference",
|
|
16158
|
+
name: "identifier"
|
|
16159
|
+
},
|
|
16160
|
+
{
|
|
16161
|
+
kind: "reference",
|
|
16162
|
+
name: "dot"
|
|
16163
|
+
},
|
|
16164
|
+
{
|
|
16165
|
+
kind: "reference",
|
|
16166
|
+
name: "hash"
|
|
16167
|
+
},
|
|
16168
|
+
{
|
|
16169
|
+
kind: "reference",
|
|
16170
|
+
name: "identifier"
|
|
16171
|
+
}
|
|
16172
|
+
]
|
|
16173
|
+
}
|
|
16174
|
+
},
|
|
16175
|
+
{
|
|
16176
|
+
name: "reference_list",
|
|
16177
|
+
expression: {
|
|
16178
|
+
kind: "sequence",
|
|
16179
|
+
elements: [
|
|
16180
|
+
{
|
|
16181
|
+
kind: "reference",
|
|
16182
|
+
name: "reference"
|
|
16183
|
+
},
|
|
16184
|
+
{
|
|
16185
|
+
kind: "repeat",
|
|
16186
|
+
element: {
|
|
16187
|
+
kind: "sequence",
|
|
16188
|
+
elements: [
|
|
16189
|
+
{
|
|
16190
|
+
kind: "reference",
|
|
16191
|
+
name: "comma"
|
|
16192
|
+
},
|
|
16193
|
+
{
|
|
16194
|
+
kind: "reference",
|
|
16195
|
+
name: "reference"
|
|
16196
|
+
}
|
|
16197
|
+
]
|
|
16198
|
+
}
|
|
16199
|
+
}
|
|
16200
|
+
]
|
|
16201
|
+
}
|
|
16202
|
+
},
|
|
16203
|
+
{
|
|
16204
|
+
name: "reference",
|
|
16205
|
+
expression: {
|
|
16206
|
+
kind: "reference",
|
|
16207
|
+
name: "identifier"
|
|
16208
|
+
}
|
|
16209
|
+
},
|
|
16210
|
+
{
|
|
16211
|
+
name: "expression",
|
|
16212
|
+
expression: {
|
|
16213
|
+
kind: "reference",
|
|
16214
|
+
name: "choice"
|
|
16215
|
+
}
|
|
16216
|
+
},
|
|
16217
|
+
{
|
|
16218
|
+
name: "choice",
|
|
16219
|
+
expression: {
|
|
16220
|
+
kind: "sequence",
|
|
16221
|
+
elements: [
|
|
16222
|
+
{
|
|
16223
|
+
kind: "reference",
|
|
16224
|
+
name: "alternative"
|
|
16225
|
+
},
|
|
16226
|
+
{
|
|
16227
|
+
kind: "repeat",
|
|
16228
|
+
element: {
|
|
16229
|
+
kind: "sequence",
|
|
16230
|
+
elements: [
|
|
16231
|
+
{
|
|
16232
|
+
kind: "reference",
|
|
16233
|
+
name: "bar"
|
|
16234
|
+
},
|
|
16235
|
+
{
|
|
16236
|
+
kind: "reference",
|
|
16237
|
+
name: "alternative"
|
|
16238
|
+
}
|
|
16239
|
+
]
|
|
16240
|
+
}
|
|
16241
|
+
}
|
|
16242
|
+
]
|
|
16243
|
+
}
|
|
16244
|
+
},
|
|
16245
|
+
{
|
|
16246
|
+
name: "alternative",
|
|
16247
|
+
expression: {
|
|
16248
|
+
kind: "reference",
|
|
16249
|
+
name: "labeled_alternative"
|
|
16250
|
+
}
|
|
16251
|
+
},
|
|
16252
|
+
{
|
|
16253
|
+
name: "labeled_alternative",
|
|
16254
|
+
expression: {
|
|
16255
|
+
kind: "sequence",
|
|
16256
|
+
elements: [
|
|
16257
|
+
{
|
|
16258
|
+
kind: "optional",
|
|
16259
|
+
element: {
|
|
16260
|
+
kind: "sequence",
|
|
16261
|
+
elements: [
|
|
16262
|
+
{
|
|
16263
|
+
kind: "reference",
|
|
16264
|
+
name: "hash"
|
|
16265
|
+
},
|
|
16266
|
+
{
|
|
16267
|
+
kind: "reference",
|
|
16268
|
+
name: "identifier"
|
|
16269
|
+
}
|
|
16270
|
+
]
|
|
16271
|
+
}
|
|
16272
|
+
},
|
|
16273
|
+
{
|
|
16274
|
+
kind: "reference",
|
|
16275
|
+
name: "sequence"
|
|
16276
|
+
}
|
|
16277
|
+
]
|
|
16278
|
+
}
|
|
16279
|
+
},
|
|
16280
|
+
{
|
|
16281
|
+
name: "sequence",
|
|
16282
|
+
expression: {
|
|
16283
|
+
kind: "sequence",
|
|
16284
|
+
elements: [
|
|
16285
|
+
{
|
|
16286
|
+
kind: "reference",
|
|
16287
|
+
name: "factor"
|
|
16288
|
+
},
|
|
16289
|
+
{
|
|
16290
|
+
kind: "repeat",
|
|
16291
|
+
element: {
|
|
16292
|
+
kind: "reference",
|
|
16293
|
+
name: "factor"
|
|
16294
|
+
}
|
|
16295
|
+
}
|
|
16296
|
+
]
|
|
16297
|
+
}
|
|
16298
|
+
},
|
|
16299
|
+
{
|
|
16300
|
+
name: "factor",
|
|
16301
|
+
expression: {
|
|
16302
|
+
kind: "choice",
|
|
16303
|
+
alternatives: [
|
|
16304
|
+
{
|
|
16305
|
+
label: null,
|
|
16306
|
+
expression: {
|
|
16307
|
+
kind: "reference",
|
|
16308
|
+
name: "bracketed"
|
|
16309
|
+
}
|
|
16310
|
+
},
|
|
16311
|
+
{
|
|
16312
|
+
label: null,
|
|
16313
|
+
expression: {
|
|
16314
|
+
kind: "reference",
|
|
16315
|
+
name: "repeat"
|
|
16316
|
+
}
|
|
16317
|
+
},
|
|
16318
|
+
{
|
|
16319
|
+
label: null,
|
|
16320
|
+
expression: {
|
|
16321
|
+
kind: "reference",
|
|
16322
|
+
name: "group"
|
|
16323
|
+
}
|
|
16324
|
+
},
|
|
16325
|
+
{
|
|
16326
|
+
label: null,
|
|
16327
|
+
expression: {
|
|
16328
|
+
kind: "reference",
|
|
16329
|
+
name: "primary"
|
|
16330
|
+
}
|
|
16331
|
+
}
|
|
16332
|
+
]
|
|
16333
|
+
}
|
|
16334
|
+
},
|
|
16335
|
+
{
|
|
16336
|
+
name: "bracketed",
|
|
16337
|
+
expression: {
|
|
16338
|
+
kind: "sequence",
|
|
16339
|
+
elements: [
|
|
16340
|
+
{
|
|
16341
|
+
kind: "reference",
|
|
16342
|
+
name: "lbracket"
|
|
16343
|
+
},
|
|
16344
|
+
{
|
|
16345
|
+
kind: "reference",
|
|
16346
|
+
name: "expression"
|
|
16347
|
+
},
|
|
16348
|
+
{
|
|
16349
|
+
kind: "reference",
|
|
16350
|
+
name: "rbracket"
|
|
16351
|
+
},
|
|
16352
|
+
{
|
|
16353
|
+
kind: "optional",
|
|
16354
|
+
element: {
|
|
16355
|
+
kind: "sequence",
|
|
16356
|
+
elements: [
|
|
16357
|
+
{
|
|
16358
|
+
kind: "reference",
|
|
16359
|
+
name: "colon"
|
|
16360
|
+
},
|
|
16361
|
+
{
|
|
16362
|
+
kind: "reference",
|
|
16363
|
+
name: "identifier"
|
|
16364
|
+
}
|
|
16365
|
+
]
|
|
16366
|
+
}
|
|
16367
|
+
}
|
|
16368
|
+
]
|
|
16369
|
+
}
|
|
16370
|
+
},
|
|
16371
|
+
{
|
|
16372
|
+
name: "repeat",
|
|
16373
|
+
expression: {
|
|
16374
|
+
kind: "sequence",
|
|
16375
|
+
elements: [
|
|
16376
|
+
{
|
|
16377
|
+
kind: "reference",
|
|
16378
|
+
name: "lbrace"
|
|
16379
|
+
},
|
|
16380
|
+
{
|
|
16381
|
+
kind: "reference",
|
|
16382
|
+
name: "expression"
|
|
16383
|
+
},
|
|
16384
|
+
{
|
|
16385
|
+
kind: "reference",
|
|
16386
|
+
name: "rbrace"
|
|
16387
|
+
}
|
|
16388
|
+
]
|
|
16389
|
+
}
|
|
16390
|
+
},
|
|
16391
|
+
{
|
|
16392
|
+
name: "group",
|
|
16393
|
+
expression: {
|
|
16394
|
+
kind: "sequence",
|
|
16395
|
+
elements: [
|
|
16396
|
+
{
|
|
16397
|
+
kind: "reference",
|
|
16398
|
+
name: "lpar"
|
|
16399
|
+
},
|
|
16400
|
+
{
|
|
16401
|
+
kind: "reference",
|
|
16402
|
+
name: "expression"
|
|
16403
|
+
},
|
|
16404
|
+
{
|
|
16405
|
+
kind: "reference",
|
|
16406
|
+
name: "rpar"
|
|
16407
|
+
}
|
|
16408
|
+
]
|
|
16409
|
+
}
|
|
16410
|
+
},
|
|
16411
|
+
{
|
|
16412
|
+
name: "primary",
|
|
16413
|
+
expression: {
|
|
16414
|
+
kind: "choice",
|
|
16415
|
+
alternatives: [
|
|
16416
|
+
{
|
|
16417
|
+
label: null,
|
|
16418
|
+
expression: {
|
|
16419
|
+
kind: "reference",
|
|
16420
|
+
name: "string_literal"
|
|
16421
|
+
}
|
|
16422
|
+
},
|
|
16423
|
+
{
|
|
16424
|
+
label: null,
|
|
16425
|
+
expression: {
|
|
16426
|
+
kind: "reference",
|
|
16427
|
+
name: "identifier"
|
|
16428
|
+
}
|
|
16429
|
+
}
|
|
16430
|
+
]
|
|
16431
|
+
}
|
|
16432
|
+
}
|
|
16433
|
+
];
|
|
16434
|
+
var transform = [
|
|
16435
|
+
{
|
|
16436
|
+
production: "grammar_file$repeat_0",
|
|
16437
|
+
alternatives: [
|
|
16438
|
+
{
|
|
16439
|
+
label: "main",
|
|
16440
|
+
expression: {
|
|
16441
|
+
kind: "flatten",
|
|
16442
|
+
typeName: "grammar_file",
|
|
16443
|
+
variant: "sections",
|
|
16444
|
+
head: "section",
|
|
16445
|
+
tail: "grammar_file$repeat_0"
|
|
16446
|
+
}
|
|
16447
|
+
}
|
|
16448
|
+
]
|
|
16449
|
+
},
|
|
16450
|
+
{
|
|
16451
|
+
production: "token_section$repeat_1",
|
|
16452
|
+
alternatives: [
|
|
16453
|
+
{
|
|
16454
|
+
label: "main",
|
|
16455
|
+
expression: {
|
|
16456
|
+
kind: "flatten",
|
|
16457
|
+
typeName: "token_section",
|
|
16458
|
+
variant: "definitions",
|
|
16459
|
+
head: "token_def",
|
|
16460
|
+
tail: "token_section$repeat_1"
|
|
16461
|
+
}
|
|
16462
|
+
}
|
|
16463
|
+
]
|
|
16464
|
+
},
|
|
16465
|
+
{
|
|
16466
|
+
production: "skip_section$repeat_2",
|
|
16467
|
+
alternatives: [
|
|
16468
|
+
{
|
|
16469
|
+
label: "main",
|
|
16470
|
+
expression: {
|
|
16471
|
+
kind: "flatten",
|
|
16472
|
+
typeName: "skip_section",
|
|
16473
|
+
variant: "definitions",
|
|
16474
|
+
head: "token_def",
|
|
16475
|
+
tail: "skip_section$repeat_2"
|
|
16476
|
+
}
|
|
16477
|
+
}
|
|
16478
|
+
]
|
|
16479
|
+
},
|
|
16480
|
+
{
|
|
16481
|
+
production: "grammar_section$repeat_4",
|
|
16482
|
+
alternatives: [
|
|
16483
|
+
{
|
|
16484
|
+
label: "main",
|
|
16485
|
+
expression: {
|
|
16486
|
+
kind: "flatten",
|
|
16487
|
+
typeName: "grammar_section",
|
|
16488
|
+
variant: "productions",
|
|
16489
|
+
head: "production",
|
|
16490
|
+
tail: "grammar_section$repeat_4"
|
|
16491
|
+
}
|
|
16492
|
+
}
|
|
16493
|
+
]
|
|
16494
|
+
},
|
|
16495
|
+
{
|
|
16496
|
+
production: "ast_section$repeat_5",
|
|
16497
|
+
alternatives: [
|
|
16498
|
+
{
|
|
16499
|
+
label: "main",
|
|
16500
|
+
expression: {
|
|
16501
|
+
kind: "flatten",
|
|
16502
|
+
typeName: "ast_section",
|
|
16503
|
+
variant: "types",
|
|
16504
|
+
head: "ast_type",
|
|
16505
|
+
tail: "ast_section$repeat_5"
|
|
16506
|
+
}
|
|
16507
|
+
}
|
|
16508
|
+
]
|
|
16509
|
+
},
|
|
16510
|
+
{
|
|
16511
|
+
production: "transform_section$repeat_6",
|
|
16512
|
+
alternatives: [
|
|
16513
|
+
{
|
|
16514
|
+
label: "main",
|
|
16515
|
+
expression: {
|
|
16516
|
+
kind: "flatten",
|
|
16517
|
+
typeName: "transform_section",
|
|
16518
|
+
variant: "rules",
|
|
16519
|
+
head: "transform_rule",
|
|
16520
|
+
tail: "transform_section$repeat_6"
|
|
16521
|
+
}
|
|
16522
|
+
}
|
|
16523
|
+
]
|
|
16524
|
+
},
|
|
16525
|
+
{
|
|
16526
|
+
production: "transform_rule$repeat_7",
|
|
16527
|
+
alternatives: [
|
|
16528
|
+
{
|
|
16529
|
+
label: "main",
|
|
16530
|
+
expression: {
|
|
16531
|
+
kind: "flatten",
|
|
16532
|
+
typeName: "transform_rule",
|
|
16533
|
+
variant: "alternatives",
|
|
16534
|
+
head: "labeled_transform",
|
|
16535
|
+
tail: "transform_rule$repeat_7"
|
|
16536
|
+
}
|
|
16537
|
+
}
|
|
16538
|
+
]
|
|
16539
|
+
},
|
|
16540
|
+
{
|
|
16541
|
+
production: "reference_list$repeat_8",
|
|
16542
|
+
alternatives: [
|
|
16543
|
+
{
|
|
16544
|
+
label: "main",
|
|
16545
|
+
expression: {
|
|
16546
|
+
kind: "flatten",
|
|
16547
|
+
typeName: "reference_list",
|
|
16548
|
+
variant: "references",
|
|
16549
|
+
head: "reference",
|
|
16550
|
+
tail: "reference_list$repeat_8"
|
|
16551
|
+
}
|
|
16552
|
+
}
|
|
16553
|
+
]
|
|
16554
|
+
},
|
|
16555
|
+
{
|
|
16556
|
+
production: "choice$repeat_9",
|
|
16557
|
+
alternatives: [
|
|
16558
|
+
{
|
|
16559
|
+
label: "main",
|
|
16560
|
+
expression: {
|
|
16561
|
+
kind: "flatten",
|
|
16562
|
+
typeName: "choice",
|
|
16563
|
+
variant: "alternatives",
|
|
16564
|
+
head: "alternative",
|
|
16565
|
+
tail: "choice$repeat_9"
|
|
16566
|
+
}
|
|
16567
|
+
}
|
|
16568
|
+
]
|
|
16569
|
+
},
|
|
16570
|
+
{
|
|
16571
|
+
production: "sequence$repeat_10",
|
|
16572
|
+
alternatives: [
|
|
16573
|
+
{
|
|
16574
|
+
label: "main",
|
|
16575
|
+
expression: {
|
|
16576
|
+
kind: "flatten",
|
|
16577
|
+
typeName: "sequence",
|
|
16578
|
+
variant: "factors",
|
|
16579
|
+
head: "factor",
|
|
16580
|
+
tail: "sequence$repeat_10"
|
|
16581
|
+
}
|
|
16582
|
+
}
|
|
16583
|
+
]
|
|
16584
|
+
}
|
|
16585
|
+
];
|
|
15504
16586
|
var bootstrapTableJson = {
|
|
15505
16587
|
version: version,
|
|
15506
16588
|
algorithm: algorithm,
|
|
@@ -15513,7 +16595,9 @@ var bootstrapTableJson = {
|
|
|
15513
16595
|
parserStateCount: parserStateCount,
|
|
15514
16596
|
productions: productions,
|
|
15515
16597
|
actions: actions,
|
|
15516
|
-
gotos: gotos
|
|
16598
|
+
gotos: gotos,
|
|
16599
|
+
ast: ast,
|
|
16600
|
+
transform: transform
|
|
15517
16601
|
};
|
|
15518
16602
|
|
|
15519
16603
|
const bootstrapTable = bootstrapTableJson;
|
|
@@ -16104,8 +17188,8 @@ class ParserLr {
|
|
|
16104
17188
|
/**
|
|
16105
17189
|
* Creates a parser from a serialized parse table.
|
|
16106
17190
|
*
|
|
16107
|
-
* @param table - Parse table containing lexer metadata and
|
|
16108
|
-
* @returns A parser that
|
|
17191
|
+
* @param table - Parse table containing lexer metadata, parser entries, and optional AST transforms.
|
|
17192
|
+
* @returns A parser that lexes, parses, and applies transforms from the table JSON.
|
|
16109
17193
|
*/
|
|
16110
17194
|
static fromParseTable(table) {
|
|
16111
17195
|
return new ParserLr(table.toGrammar(), table);
|
|
@@ -16252,8 +17336,8 @@ class ParseContext {
|
|
|
16252
17336
|
/**
|
|
16253
17337
|
* Builds a parse context from serialized parse table JSON.
|
|
16254
17338
|
*
|
|
16255
|
-
* @param json - Serialized parse table JSON.
|
|
16256
|
-
* @returns Parser and parse table ready for lexing
|
|
17339
|
+
* @param json - Serialized parse table JSON including `ast` and `transform` when present.
|
|
17340
|
+
* @returns Parser and parse table ready for lexing and full AST parsing.
|
|
16257
17341
|
*/
|
|
16258
17342
|
static fromTableJson(json) {
|
|
16259
17343
|
const table = ParseTable.fromJsonString(json);
|
|
@@ -16329,19 +17413,19 @@ class ParseContext {
|
|
|
16329
17413
|
return this.parser.lexChunkStreamAsync(chunks);
|
|
16330
17414
|
}
|
|
16331
17415
|
/**
|
|
16332
|
-
* Parses a token stream into
|
|
17416
|
+
* Parses a token stream into an AST, applying transforms from the grammar or table when present.
|
|
16333
17417
|
*
|
|
16334
17418
|
* @param tokens - Token stream ending with `$eof`.
|
|
16335
|
-
* @returns
|
|
17419
|
+
* @returns Transformed AST, CST when no transform rules exist, or null on syntax error.
|
|
16336
17420
|
*/
|
|
16337
17421
|
parse(tokens) {
|
|
16338
17422
|
return this.parser.parse(tokens);
|
|
16339
17423
|
}
|
|
16340
17424
|
/**
|
|
16341
|
-
* Lexes and parses source text into
|
|
17425
|
+
* Lexes and parses source text into an AST, applying transforms when present.
|
|
16342
17426
|
*
|
|
16343
17427
|
* @param source - Input text to parse.
|
|
16344
|
-
* @returns
|
|
17428
|
+
* @returns Transformed AST, CST when no transform rules exist, or null on syntax error.
|
|
16345
17429
|
*/
|
|
16346
17430
|
parseSource(source) {
|
|
16347
17431
|
return this.parser.parseSource(source);
|