lrama 0.6.10 → 0.6.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yaml +5 -1
  3. data/Gemfile +2 -2
  4. data/NEWS.md +65 -30
  5. data/Steepfile +3 -0
  6. data/doc/development/compressed_state_table/main.md +635 -0
  7. data/doc/development/compressed_state_table/parse.output +174 -0
  8. data/doc/development/compressed_state_table/parse.y +22 -0
  9. data/doc/development/compressed_state_table/parser.rb +282 -0
  10. data/lib/lrama/bitmap.rb +1 -1
  11. data/lib/lrama/context.rb +3 -3
  12. data/lib/lrama/counterexamples/derivation.rb +6 -5
  13. data/lib/lrama/counterexamples/example.rb +7 -4
  14. data/lib/lrama/counterexamples/path.rb +4 -0
  15. data/lib/lrama/counterexamples.rb +19 -9
  16. data/lib/lrama/grammar/parameterizing_rule/rhs.rb +1 -1
  17. data/lib/lrama/grammar/rule_builder.rb +1 -1
  18. data/lib/lrama/grammar/symbols/resolver.rb +4 -0
  19. data/lib/lrama/grammar.rb +2 -2
  20. data/lib/lrama/lexer/token/user_code.rb +1 -1
  21. data/lib/lrama/lexer.rb +1 -0
  22. data/lib/lrama/parser.rb +520 -487
  23. data/lib/lrama/state/reduce.rb +2 -3
  24. data/lib/lrama/version.rb +1 -1
  25. data/parser.y +38 -27
  26. data/rbs_collection.lock.yaml +10 -2
  27. data/sig/lrama/counterexamples/derivation.rbs +33 -0
  28. data/sig/lrama/counterexamples/example.rbs +45 -0
  29. data/sig/lrama/counterexamples/path.rbs +21 -0
  30. data/sig/lrama/counterexamples/production_path.rbs +11 -0
  31. data/sig/lrama/counterexamples/start_path.rbs +13 -0
  32. data/sig/lrama/counterexamples/state_item.rbs +10 -0
  33. data/sig/lrama/counterexamples/transition_path.rbs +11 -0
  34. data/sig/lrama/counterexamples/triple.rbs +20 -0
  35. data/sig/lrama/counterexamples.rbs +29 -0
  36. data/sig/lrama/grammar/symbol.rbs +1 -1
  37. data/sig/lrama/grammar/symbols/resolver.rbs +3 -3
  38. data/sig/lrama/grammar.rbs +13 -0
  39. data/sig/lrama/state/reduce_reduce_conflict.rbs +2 -2
  40. data/sig/lrama/state.rbs +79 -0
  41. data/sig/lrama/states.rbs +101 -0
  42. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fce10e3be7a24cd5dcae139d72e41bb586cb2a34bb6a6cd06412a420e65513b
4
- data.tar.gz: 663d42179f28318ecb2a120d726dfcdfc8f599f2732771d39ed2d6a9e88fe07d
3
+ metadata.gz: 1d566a5097f0fd579e70f94769cca4e68a8f0e810e10cd55556583b1c2653945
4
+ data.tar.gz: e5ab505df1a8fffe46a9f526456b593db786f36f0e998e7e3acbf5f68b76d9a9
5
5
  SHA512:
6
- metadata.gz: 469a0e7bf84b68092e90187df12d7c9a71273e26caded2b27742cb7a83930a76626f73f2f872c931f496816348005a986d7edce639c326f7a83ed697708b4013
7
- data.tar.gz: f053199c82ca39d614c56c55fd09daeb441e7e3b7504165042ee3c6a1275c400d640822365d939145a3a7a6c791da63119e614c4e5a36ad4f0cfa57a7561baa4
6
+ metadata.gz: 753a7b6f0781f6b0bd2db8c98ef0e6171496d6fd8a2a16762b67dc471e34b4118b4439b89facc1915a364d4c4823edaef464d947cbda3d913ebd8eff87d91b76
7
+ data.tar.gz: 7f953657c7050c7d527bf190d284e5b56b3df5b92c2034d5f4425f73be1e21208d1869a4ffe6c9091b4adf79671e71865000797ec2d7ed1ad66cfe5d1846cd7b
@@ -186,4 +186,8 @@ jobs:
186
186
  - run: ../autogen.sh
187
187
  - run: ../configure -C --disable-install-doc
188
188
  - run: make
189
- - run: make test-all
189
+ - run: make test-all RUN_OPTS="$RUN_OPTS" SPECOPTS="$SPECOPTS"
190
+ env:
191
+ EXCLUDES: '../test/.excludes-parsey'
192
+ RUN_OPTS: ${{ matrix.run_opts || '--parser=parse.y' }}
193
+ SPECOPTS: ${{ matrix.specopts || '-T --parser=parse.y' }}
data/Gemfile CHANGED
@@ -15,6 +15,6 @@ gem "memory_profiler"
15
15
  # Recent steep requires Ruby >= 3.0.0.
16
16
  # Then skip install on some CI jobs.
17
17
  if !ENV['GITHUB_ACTION'] || ENV['INSTALL_STEEP'] == 'true'
18
- gem "rbs", "3.5.3", require: false
19
- gem "steep", "1.7.1", require: false
18
+ gem "rbs", "3.7.0", require: false
19
+ gem "steep", "1.9.1", require: false
20
20
  end
data/NEWS.md CHANGED
@@ -1,12 +1,47 @@
1
1
  # NEWS for Lrama
2
2
 
3
+ ## Lrama 0.6.11 (2024-12-23)
4
+
5
+ ### Add support for %type declarations using %nterm in Nonterminal Symbols
6
+
7
+ Allow to use `%nterm` in Nonterminal Symbols for `%type` declarations.
8
+
9
+ ```yacc
10
+ %nterm <type> nonterminal…
11
+ ```
12
+
13
+ This directive is also supported for compatibility with Bison, and only non-terminal symbols are allowed. In other words, definitions like the following will result in an error:
14
+
15
+ ```yacc
16
+ %{
17
+ // Prologue
18
+ %}
19
+
20
+ %token EOI 0 "EOI"
21
+ %nterm EOI
22
+
23
+ %%
24
+
25
+ program: /* empty */
26
+ ;
27
+ ```
28
+
29
+ It show an error message like the following:
30
+
31
+ ```command
32
+ ❯ exe/lrama nterm.y
33
+ nterm.y:6:7: symbol EOI redeclared as a nonterminal
34
+ %nterm EOI
35
+ ^^^
36
+ ```
37
+
3
38
  ## Lrama 0.6.10 (2024-09-11)
4
39
 
5
40
  ### Aliased Named References for actions of RHS in parameterizing rules
6
41
 
7
42
  Allow to use aliased named references for actions of RHS in parameterizing rules.
8
43
 
9
- ```
44
+ ```yacc
10
45
  %rule sum(X, Y): X[summand] '+' Y[addend] { $$ = $summand + $addend }
11
46
  ;
12
47
  ```
@@ -18,7 +53,7 @@ https://github.com/ruby/lrama/pull/410
18
53
 
19
54
  Allow to use named references for actions of RHS in parameterizing rules caller side.
20
55
 
21
- ```
56
+ ```yacc
22
57
  opt_nl: '\n'?[nl] <str> { $$ = $nl; }
23
58
  ;
24
59
  ```
@@ -29,7 +64,7 @@ https://github.com/ruby/lrama/pull/414
29
64
 
30
65
  Allow to define parameterizing rules in the middle of the grammar.
31
66
 
32
- ```
67
+ ```yacc
33
68
  %rule defined_option(X): /* empty */
34
69
  | X
35
70
  ;
@@ -52,8 +87,8 @@ https://github.com/ruby/lrama/pull/420
52
87
  Support to report unused terminal symbols.
53
88
  Run `exe/lrama --report=terms` to show unused terminal symbols.
54
89
 
55
- ```
56
- exe/lrama --report=terms sample/calc.y
90
+ ```console
91
+ $ exe/lrama --report=terms sample/calc.y
57
92
  11 Unused Terms
58
93
  0 YYerror
59
94
  1 YYUNDEF
@@ -74,8 +109,8 @@ https://github.com/ruby/lrama/pull/439
74
109
  Support to report unused rules.
75
110
  Run `exe/lrama --report=rules` to show unused rules.
76
111
 
77
- ```
78
- exe/lrama --report=rules sample/calc.y
112
+ ```console
113
+ $ exe/lrama --report=rules sample/calc.y
79
114
  3 Unused Rules
80
115
  0 unused_option
81
116
  1 unused_list
@@ -96,8 +131,8 @@ https://github.com/ruby/lrama/pull/446
96
131
  Support to warning redefined parameterizing rules.
97
132
  Run `exe/lrama -W` or `exe/lrama --warnings` to show redefined parameterizing rules.
98
133
 
99
- ```
100
- exe/lrama -W sample/calc.y
134
+ ```console
135
+ $ exe/lrama -W sample/calc.y
101
136
  parameterizing rule redefined: redefined_method(X)
102
137
  parameterizing rule redefined: redefined_method(X)
103
138
  ```
@@ -117,7 +152,7 @@ https://github.com/ruby/lrama/pull/457
117
152
 
118
153
  Allow to specify tag on callee side of parameterizing rules.
119
154
 
120
- ```
155
+ ```yacc
121
156
  %union {
122
157
  int i;
123
158
  }
@@ -130,7 +165,7 @@ Allow to specify tag on callee side of parameterizing rules.
130
165
 
131
166
  Allow to use named references for actions of RHS in parameterizing rules.
132
167
 
133
- ```
168
+ ```yacc
134
169
  %rule option(number): /* empty */
135
170
  | number { $$ = $number; }
136
171
  ;
@@ -142,7 +177,7 @@ Allow to use named references for actions of RHS in parameterizing rules.
142
177
 
143
178
  Allow to nested parameterizing rules with tag.
144
179
 
145
- ```
180
+ ```yacc
146
181
  %union {
147
182
  int i;
148
183
  }
@@ -179,8 +214,8 @@ User can use `'symbol'?`, `'symbol'+` and `'symbol'*` in RHS of user defined par
179
214
  Support trace actions for debugging.
180
215
  Run `exe/lrama --trace=actions` to show grammar rules with actions.
181
216
 
182
- ```
183
- exe/lrama --trace=actions sample/calc.y
217
+ ```console
218
+ $ exe/lrama --trace=actions sample/calc.y
184
219
  Grammar rules with actions:
185
220
  $accept -> list, YYEOF {}
186
221
  list -> ε {}
@@ -199,7 +234,7 @@ expr -> '(', expr, ')' { $$ = $2; }
199
234
  Support inlining for rules.
200
235
  The `%inline` directive causes all references to symbols to be replaced with its definition.
201
236
 
202
- ```
237
+ ```yacc
203
238
  %rule %inline op: PLUS { + }
204
239
  | TIMES { * }
205
240
  ;
@@ -213,7 +248,7 @@ expr : number { $$ = $1; }
213
248
 
214
249
  as same as
215
250
 
216
- ```
251
+ ```yacc
217
252
  expr : number { $$ = $1; }
218
253
  | expr '+' expr { $$ = $1 + $3; }
219
254
  | expr '*' expr { $$ = $1 * $3; }
@@ -226,7 +261,7 @@ expr : number { $$ = $1; }
226
261
 
227
262
  User can specify the type of mid rule action by tag (`<bar>`) instead of specifying it with in an action.
228
263
 
229
- ```
264
+ ```yacc
230
265
  primary: k_case expr_value terms?
231
266
  {
232
267
  $<val>$ = p->case_labels;
@@ -241,7 +276,7 @@ primary: k_case expr_value terms?
241
276
 
242
277
  can be written as
243
278
 
244
- ```
279
+ ```yacc
245
280
  primary: k_case expr_value terms?
246
281
  {
247
282
  $$ = p->case_labels;
@@ -266,7 +301,7 @@ Bison supports this feature from 3.1.
266
301
 
267
302
  Support `preceded`, `terminated` and `delimited` rules.
268
303
 
269
- ```
304
+ ```text
270
305
  program: preceded(opening, X)
271
306
 
272
307
  // Expanded to
@@ -302,7 +337,7 @@ In general, these resources are freed by actions or after parsing.
302
337
  However if syntax error happens in parsing, these codes may not be executed.
303
338
  Codes associated to `%destructor` are executed when semantic value is popped from the stack by an error.
304
339
 
305
- ```
340
+ ```yacc
306
341
  %token <val1> NUM
307
342
  %type <val2> expr2
308
343
  %type <val3> expr
@@ -350,7 +385,7 @@ Lrama provides these five callbacks. Registered functions are called when each e
350
385
  User also needs to access semantic value of their stack in grammar action. `$:n` provides the way to access to it. `$:n` is translated to the minus index from the top of the stack.
351
386
  For example
352
387
 
353
- ```
388
+ ```yacc
354
389
  primary: k_if expr_value then compstmt if_tail k_end
355
390
  {
356
391
  /*% ripper: if!($:2, $:4, $:5) %*/
@@ -375,7 +410,7 @@ https://github.com/ruby/lrama/pull/344
375
410
 
376
411
  Allow to pass an instantiated rule to other parameterizing rules.
377
412
 
378
- ```
413
+ ```yacc
379
414
  %rule constant(X) : X
380
415
  ;
381
416
 
@@ -392,7 +427,7 @@ program : option(constant(number)) // Nested rule
392
427
 
393
428
  Allow to use nested parameterizing rules when define parameterizing rules.
394
429
 
395
- ```
430
+ ```yacc
396
431
  %rule option(x) : /* empty */
397
432
  | X
398
433
  ;
@@ -419,7 +454,7 @@ https://github.com/ruby/lrama/pull/337
419
454
 
420
455
  Allow to define parameterizing rule by `%rule` directive.
421
456
 
422
- ```
457
+ ```yacc
423
458
  %rule pair(X, Y): X Y { $$ = $1 + $2; }
424
459
  ;
425
460
 
@@ -442,7 +477,7 @@ https://github.com/ruby/lrama/pull/285
442
477
  Allow to specify type of rules by specifying tag, `<i>` in below example.
443
478
  Tag is post-modification style.
444
479
 
445
- ```
480
+ ```yacc
446
481
  %union {
447
482
  int i;
448
483
  }
@@ -469,7 +504,7 @@ https://github.com/ruby/lrama/pull/197
469
504
 
470
505
  Support `separated_list` and `separated_nonempty_list` parameterizing rules.
471
506
 
472
- ```
507
+ ```text
473
508
  program: separated_list(',', number)
474
509
 
475
510
  // Expanded to
@@ -500,7 +535,7 @@ https://github.com/ruby/lrama/pull/204
500
535
  Parameterizing rules are template of rules.
501
536
  It's very common pattern to write "list" grammar rule like:
502
537
 
503
- ```
538
+ ```yacc
504
539
  opt_args: /* none */
505
540
  | args
506
541
  ;
@@ -532,7 +567,7 @@ https://github.com/ruby/lrama/pull/62
532
567
 
533
568
  ### Runtime configuration for error recovery
534
569
 
535
- Meke error recovery function configurable on runtime by two new macros.
570
+ Make error recovery function configurable on runtime by two new macros.
536
571
 
537
572
  * `YYMAXREPAIR`: Expected to return max length of repair operations. `%parse-param` is passed to this function.
538
573
  * `YYERROR_RECOVERY_ENABLED`: Expected to return bool value to determine error recovery is enabled or not. `%parse-param` is passed to this function.
@@ -555,7 +590,7 @@ https://github.com/ruby/lrama/pull/44
555
590
  Instead of positional references like `$1` or `$$`,
556
591
  named references allow to access to symbol by name.
557
592
 
558
- ```
593
+ ```yacc
559
594
  primary: k_class cpath superclass bodystmt k_end
560
595
  {
561
596
  $primary = new_class($cpath, $bodystmt, $superclass);
@@ -564,7 +599,7 @@ primary: k_class cpath superclass bodystmt k_end
564
599
 
565
600
  Alias name can be declared.
566
601
 
567
- ```
602
+ ```yacc
568
603
  expr[result]: expr[ex-left] '+' expr[ex.right]
569
604
  {
570
605
  $result = $[ex-left] + $[ex.right];
data/Steepfile CHANGED
@@ -7,11 +7,14 @@ target :lib do
7
7
  signature "sig"
8
8
 
9
9
  check "lib/lrama/grammar"
10
+
11
+ check "lib/lrama/counterexamples"
10
12
  check "lib/lrama/lexer"
11
13
  check "lib/lrama/report"
12
14
  check "lib/lrama/state"
13
15
  check "lib/lrama/states"
14
16
  check "lib/lrama/bitmap.rb"
17
+ check "lib/lrama/counterexamples.rb"
15
18
  check "lib/lrama/digraph.rb"
16
19
  check "lib/lrama/grammar.rb"
17
20
  check "lib/lrama/options.rb"