lrama 0.6.10 → 0.7.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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gh-pages.yml +46 -0
  3. data/.github/workflows/test.yaml +40 -8
  4. data/.gitignore +1 -0
  5. data/.rdoc_options +2 -0
  6. data/Gemfile +4 -2
  7. data/NEWS.md +125 -30
  8. data/README.md +44 -15
  9. data/Rakefile +13 -1
  10. data/Steepfile +5 -0
  11. data/doc/Index.md +58 -0
  12. data/doc/development/compressed_state_table/main.md +635 -0
  13. data/doc/development/compressed_state_table/parse.output +174 -0
  14. data/doc/development/compressed_state_table/parse.y +22 -0
  15. data/doc/development/compressed_state_table/parser.rb +282 -0
  16. data/lib/lrama/bitmap.rb +4 -1
  17. data/lib/lrama/command.rb +2 -1
  18. data/lib/lrama/context.rb +3 -3
  19. data/lib/lrama/counterexamples/derivation.rb +6 -5
  20. data/lib/lrama/counterexamples/example.rb +7 -4
  21. data/lib/lrama/counterexamples/path.rb +4 -0
  22. data/lib/lrama/counterexamples.rb +19 -9
  23. data/lib/lrama/digraph.rb +30 -0
  24. data/lib/lrama/grammar/binding.rb +47 -15
  25. data/lib/lrama/grammar/parameterizing_rule/rhs.rb +1 -1
  26. data/lib/lrama/grammar/rule.rb +8 -0
  27. data/lib/lrama/grammar/rule_builder.rb +4 -16
  28. data/lib/lrama/grammar/symbols/resolver.rb +4 -0
  29. data/lib/lrama/grammar.rb +10 -5
  30. data/lib/lrama/lexer/grammar_file.rb +8 -1
  31. data/lib/lrama/lexer/location.rb +17 -1
  32. data/lib/lrama/lexer/token/char.rb +1 -0
  33. data/lib/lrama/lexer/token/ident.rb +1 -0
  34. data/lib/lrama/lexer/token/instantiate_rule.rb +6 -1
  35. data/lib/lrama/lexer/token/tag.rb +3 -1
  36. data/lib/lrama/lexer/token/user_code.rb +6 -2
  37. data/lib/lrama/lexer/token.rb +14 -2
  38. data/lib/lrama/lexer.rb +5 -5
  39. data/lib/lrama/logger.rb +4 -0
  40. data/lib/lrama/option_parser.rb +10 -8
  41. data/lib/lrama/options.rb +2 -1
  42. data/lib/lrama/parser.rb +529 -490
  43. data/lib/lrama/state/reduce.rb +2 -3
  44. data/lib/lrama/state.rb +288 -1
  45. data/lib/lrama/states/item.rb +8 -0
  46. data/lib/lrama/states.rb +69 -2
  47. data/lib/lrama/trace_reporter.rb +17 -2
  48. data/lib/lrama/version.rb +1 -1
  49. data/lrama.gemspec +1 -1
  50. data/parser.y +42 -30
  51. data/rbs_collection.lock.yaml +10 -2
  52. data/sig/generated/lrama/bitmap.rbs +11 -0
  53. data/sig/generated/lrama/digraph.rbs +39 -0
  54. data/sig/generated/lrama/grammar/binding.rbs +34 -0
  55. data/sig/generated/lrama/lexer/grammar_file.rbs +28 -0
  56. data/sig/generated/lrama/lexer/location.rbs +52 -0
  57. data/sig/{lrama → generated/lrama}/lexer/token/char.rbs +2 -0
  58. data/sig/{lrama → generated/lrama}/lexer/token/ident.rbs +2 -0
  59. data/sig/{lrama → generated/lrama}/lexer/token/instantiate_rule.rbs +8 -0
  60. data/sig/{lrama → generated/lrama}/lexer/token/tag.rbs +3 -0
  61. data/sig/{lrama → generated/lrama}/lexer/token/user_code.rbs +6 -1
  62. data/sig/{lrama → generated/lrama}/lexer/token.rbs +26 -3
  63. data/sig/generated/lrama/logger.rbs +14 -0
  64. data/sig/generated/lrama/trace_reporter.rbs +25 -0
  65. data/sig/lrama/counterexamples/derivation.rbs +33 -0
  66. data/sig/lrama/counterexamples/example.rbs +45 -0
  67. data/sig/lrama/counterexamples/path.rbs +21 -0
  68. data/sig/lrama/counterexamples/production_path.rbs +11 -0
  69. data/sig/lrama/counterexamples/start_path.rbs +13 -0
  70. data/sig/lrama/counterexamples/state_item.rbs +10 -0
  71. data/sig/lrama/counterexamples/transition_path.rbs +11 -0
  72. data/sig/lrama/counterexamples/triple.rbs +20 -0
  73. data/sig/lrama/counterexamples.rbs +29 -0
  74. data/sig/lrama/grammar/rule_builder.rbs +0 -1
  75. data/sig/lrama/grammar/symbol.rbs +1 -1
  76. data/sig/lrama/grammar/symbols/resolver.rbs +3 -3
  77. data/sig/lrama/grammar.rbs +13 -0
  78. data/sig/lrama/options.rbs +1 -0
  79. data/sig/lrama/state/reduce_reduce_conflict.rbs +2 -2
  80. data/sig/lrama/state.rbs +79 -0
  81. data/sig/lrama/states.rbs +101 -0
  82. metadata +34 -14
  83. data/sig/lrama/bitmap.rbs +0 -7
  84. data/sig/lrama/digraph.rbs +0 -23
  85. data/sig/lrama/grammar/binding.rbs +0 -19
  86. data/sig/lrama/lexer/grammar_file.rbs +0 -17
  87. data/sig/lrama/lexer/location.rbs +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fce10e3be7a24cd5dcae139d72e41bb586cb2a34bb6a6cd06412a420e65513b
4
- data.tar.gz: 663d42179f28318ecb2a120d726dfcdfc8f599f2732771d39ed2d6a9e88fe07d
3
+ metadata.gz: 9c967547ee9de2d87e1e275bf5d9b1f525b7040f110ee41b9144b163923a3dd6
4
+ data.tar.gz: f9ada41c05e186245e11dfca1dc31da2f2bf8987090b91ed5312369ad1306e64
5
5
  SHA512:
6
- metadata.gz: 469a0e7bf84b68092e90187df12d7c9a71273e26caded2b27742cb7a83930a76626f73f2f872c931f496816348005a986d7edce639c326f7a83ed697708b4013
7
- data.tar.gz: f053199c82ca39d614c56c55fd09daeb441e7e3b7504165042ee3c6a1275c400d640822365d939145a3a7a6c791da63119e614c4e5a36ad4f0cfa57a7561baa4
6
+ metadata.gz: efa3c528e1f8070c26b42e71329c058b874b530d3e13a64047898928099994a94de131a05c491464cdd566c806a2424e427113987f5240ec13e281c7bcb9bdd2
7
+ data.tar.gz: da9ea52d9fa0534e168baf3f62fab8df091caca127201c085c641552fd3f7aaf09ad7f60ad49725a8874b444eb655e881064481907bd1f5ba82481d9db118398
@@ -0,0 +1,46 @@
1
+ name: Deploy Lrama documentation to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches: ["master"]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ pages: write
11
+ id-token: write
12
+
13
+ concurrency:
14
+ group: "pages"
15
+ cancel-in-progress: true
16
+
17
+ jobs:
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ if: ${{ github.repository == 'ruby/lrama' && !startsWith(github.event_name, 'pull') }}
21
+ steps:
22
+ - name: Checkout
23
+ uses: actions/checkout@v4
24
+ - name: Setup Ruby
25
+ uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # v1.196.0
26
+ with:
27
+ ruby-version: "3.4"
28
+ bundler-cache: true
29
+ - name: Setup Pages
30
+ id: pages
31
+ uses: actions/configure-pages@v5
32
+ - name: Build with Lrama
33
+ run: bundle exec rake rdoc
34
+ - name: Upload artifact
35
+ uses: actions/upload-pages-artifact@v3
36
+
37
+ deploy:
38
+ environment:
39
+ name: github-pages
40
+ url: ${{ steps.deployment.outputs.page_url }}
41
+ runs-on: ubuntu-latest
42
+ needs: build
43
+ steps:
44
+ - name: Deploy to GitHub Pages
45
+ id: deployment
46
+ uses: actions/deploy-pages@v4
@@ -16,7 +16,7 @@ jobs:
16
16
 
17
17
  test:
18
18
  needs: ruby-versions
19
- runs-on: ubuntu-20.04
19
+ runs-on: ubuntu-22.04
20
20
  strategy:
21
21
  fail-fast: false
22
22
  matrix:
@@ -54,9 +54,28 @@ jobs:
54
54
  - run: flex --help
55
55
  - run: bundle install
56
56
  - run: bundle exec rspec
57
+ test-c:
58
+ needs: ruby-versions
59
+ runs-on: ubuntu-22.04
60
+ strategy:
61
+ fail-fast: false
62
+ matrix:
63
+ ruby: ['head']
64
+ compiler: ['cc', 'gcc', 'clang']
65
+ steps:
66
+ - uses: actions/checkout@v4
67
+ - uses: ruby/setup-ruby@v1
68
+ with:
69
+ ruby-version: ${{ matrix.ruby }}
70
+ bundler-cache: true
71
+ - run: flex --help
72
+ - run: bundle install
73
+ - run: bundle exec rspec
74
+ env:
75
+ COMPILER: ${{ matrix.compiler }}
57
76
  test-cpp:
58
77
  needs: ruby-versions
59
- runs-on: ubuntu-20.04
78
+ runs-on: ubuntu-22.04
60
79
  strategy:
61
80
  fail-fast: false
62
81
  matrix:
@@ -74,7 +93,7 @@ jobs:
74
93
  env:
75
94
  COMPILER: ${{ matrix.compiler }}
76
95
  test-memory:
77
- runs-on: ubuntu-20.04
96
+ runs-on: ubuntu-22.04
78
97
  strategy:
79
98
  fail-fast: false
80
99
  matrix:
@@ -94,7 +113,7 @@ jobs:
94
113
  env:
95
114
  ENABEL_VALGRIND: 'true'
96
115
  check-misc:
97
- runs-on: ubuntu-20.04
116
+ runs-on: ubuntu-22.04
98
117
  strategy:
99
118
  matrix:
100
119
  ruby: ['head']
@@ -122,7 +141,7 @@ jobs:
122
141
  bundle exec rake build:parser
123
142
  git diff --color --no-ext-diff --ignore-submodules --exit-code lib/lrama/parser.rb
124
143
  steep-check:
125
- runs-on: ubuntu-20.04
144
+ runs-on: ubuntu-22.04
126
145
  strategy:
127
146
  fail-fast: false
128
147
  matrix:
@@ -136,10 +155,19 @@ jobs:
136
155
  ruby-version: ${{ matrix.ruby }}
137
156
  bundler-cache: true
138
157
  - run: bundle install
158
+ - run: bundle exec rbs-inline --output lib/
159
+ - name: Check for uncommitted changes
160
+ run: |
161
+ if [ -n "$(git status --porcelain)" ]; then
162
+ echo "Uncommitted changes detected after running rbs-inline."
163
+ echo "Please run 'bundle rake rbs_inline' and commit the changes generated by rbs-inline." >&2
164
+ exit 1
165
+ fi
166
+ shell: bash
139
167
  - run: bundle exec rbs collection install
140
168
  - run: bundle exec steep check
141
169
  test-ruby:
142
- runs-on: ubuntu-20.04
170
+ runs-on: ubuntu-22.04
143
171
  strategy:
144
172
  fail-fast: false
145
173
  matrix:
@@ -184,6 +212,10 @@ jobs:
184
212
  sudo apt-get install -q -y pkg-config${arch} || :
185
213
  - run: sudo apt-get --purge remove bison
186
214
  - run: ../autogen.sh
187
- - run: ../configure -C --disable-install-doc
215
+ - run: ../configure -C --disable-install-doc --with-parser=parse.y
188
216
  - run: make
189
- - run: make test-all
217
+ - run: make test-all RUN_OPTS="$RUN_OPTS" SPECOPTS="$SPECOPTS"
218
+ env:
219
+ EXCLUDES: '../test/.excludes-parsey'
220
+ RUN_OPTS: ${{ matrix.run_opts || '--parser=parse.y' }}
221
+ SPECOPTS: ${{ matrix.specopts || '-T --parser=parse.y' }}
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  /tmp/
11
11
  /vendor/bundle
12
12
  /.idea/
13
+ _site/
data/.rdoc_options ADDED
@@ -0,0 +1,2 @@
1
+ page_dir: doc
2
+ warn_missing_rdoc_ref: true
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ gemspec
7
7
  gem "pry"
8
8
  gem "racc", "1.8.1"
9
9
  gem "rake"
10
+ gem "rdoc"
10
11
  gem "rspec"
11
12
  gem "simplecov", require: false
12
13
  gem "stackprof", platforms: [:ruby] # stackprof doesn't support Windows
@@ -15,6 +16,7 @@ gem "memory_profiler"
15
16
  # Recent steep requires Ruby >= 3.0.0.
16
17
  # Then skip install on some CI jobs.
17
18
  if !ENV['GITHUB_ACTION'] || ENV['INSTALL_STEEP'] == 'true'
18
- gem "rbs", "3.5.3", require: false
19
- gem "steep", "1.7.1", require: false
19
+ gem "rbs", "3.8.1", require: false
20
+ gem "rbs-inline", require: false
21
+ gem "steep", "1.9.3", require: false
20
22
  end
data/NEWS.md CHANGED
@@ -1,12 +1,107 @@
1
1
  # NEWS for Lrama
2
2
 
3
+ ## Lrama 0.7.0 (2025-01-21)
4
+
5
+ ## [EXPERIMENTAL] Support the generation of the IELR(1) parser described in this paper
6
+
7
+ Support the generation of the IELR(1) parser described in this paper.
8
+ https://www.sciencedirect.com/science/article/pii/S0167642309001191
9
+
10
+ If you use IELR(1) parser, you can write the following directive in your grammar file.
11
+
12
+ ```yacc
13
+ %define lr.type ielr
14
+ ```
15
+
16
+ But, currently IELR(1) parser is experimental feature. If you find any bugs, please report it to us. Thank you.
17
+
18
+ ## Support `-t` option as same as `--debug` option
19
+
20
+ Support to `-t` option as same as `--debug` option.
21
+ These options align with Bison behavior. So same as `--debug` option.
22
+
23
+ ## Trace only explicit rules
24
+
25
+ Support to trace only explicit rules.
26
+ If you use `--trace=rules` option, it shows include mid-rule actions. If you want to show only explicit rules, you can use `--trace=only-explicit-rules` option.
27
+
28
+ Example:
29
+
30
+ ```yacc
31
+ %{
32
+ %}
33
+ %union {
34
+ int i;
35
+ }
36
+ %token <i> number
37
+ %type <i> program
38
+ %%
39
+ program : number { printf("%d", $1); } number { $$ = $1 + $3; }
40
+ ;
41
+ %%
42
+ ```
43
+
44
+ Result of `--trace=rules`:
45
+
46
+ ```console
47
+ $ exe/lrama --trace=rules sample.y
48
+ Grammar rules:
49
+ $accept -> program YYEOF
50
+ $@1 -> ε
51
+ program -> number $@1 number
52
+ ```
53
+
54
+ Result of `--trace=only-explicit-rules`:
55
+
56
+ ```console
57
+ $ exe/lrama --trace=explicit-rules sample.y
58
+ Grammar rules:
59
+ $accept -> program YYEOF
60
+ program -> number number
61
+ ```
62
+
63
+ ## Lrama 0.6.11 (2024-12-23)
64
+
65
+ ### Add support for %type declarations using %nterm in Nonterminal Symbols
66
+
67
+ Allow to use `%nterm` in Nonterminal Symbols for `%type` declarations.
68
+
69
+ ```yacc
70
+ %nterm <type> nonterminal…
71
+ ```
72
+
73
+ 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:
74
+
75
+ ```yacc
76
+ %{
77
+ // Prologue
78
+ %}
79
+
80
+ %token EOI 0 "EOI"
81
+ %nterm EOI
82
+
83
+ %%
84
+
85
+ program: /* empty */
86
+ ;
87
+ ```
88
+
89
+ It show an error message like the following:
90
+
91
+ ```command
92
+ ❯ exe/lrama nterm.y
93
+ nterm.y:6:7: symbol EOI redeclared as a nonterminal
94
+ %nterm EOI
95
+ ^^^
96
+ ```
97
+
3
98
  ## Lrama 0.6.10 (2024-09-11)
4
99
 
5
100
  ### Aliased Named References for actions of RHS in parameterizing rules
6
101
 
7
102
  Allow to use aliased named references for actions of RHS in parameterizing rules.
8
103
 
9
- ```
104
+ ```yacc
10
105
  %rule sum(X, Y): X[summand] '+' Y[addend] { $$ = $summand + $addend }
11
106
  ;
12
107
  ```
@@ -18,7 +113,7 @@ https://github.com/ruby/lrama/pull/410
18
113
 
19
114
  Allow to use named references for actions of RHS in parameterizing rules caller side.
20
115
 
21
- ```
116
+ ```yacc
22
117
  opt_nl: '\n'?[nl] <str> { $$ = $nl; }
23
118
  ;
24
119
  ```
@@ -29,7 +124,7 @@ https://github.com/ruby/lrama/pull/414
29
124
 
30
125
  Allow to define parameterizing rules in the middle of the grammar.
31
126
 
32
- ```
127
+ ```yacc
33
128
  %rule defined_option(X): /* empty */
34
129
  | X
35
130
  ;
@@ -52,8 +147,8 @@ https://github.com/ruby/lrama/pull/420
52
147
  Support to report unused terminal symbols.
53
148
  Run `exe/lrama --report=terms` to show unused terminal symbols.
54
149
 
55
- ```
56
- exe/lrama --report=terms sample/calc.y
150
+ ```console
151
+ $ exe/lrama --report=terms sample/calc.y
57
152
  11 Unused Terms
58
153
  0 YYerror
59
154
  1 YYUNDEF
@@ -74,8 +169,8 @@ https://github.com/ruby/lrama/pull/439
74
169
  Support to report unused rules.
75
170
  Run `exe/lrama --report=rules` to show unused rules.
76
171
 
77
- ```
78
- exe/lrama --report=rules sample/calc.y
172
+ ```console
173
+ $ exe/lrama --report=rules sample/calc.y
79
174
  3 Unused Rules
80
175
  0 unused_option
81
176
  1 unused_list
@@ -96,8 +191,8 @@ https://github.com/ruby/lrama/pull/446
96
191
  Support to warning redefined parameterizing rules.
97
192
  Run `exe/lrama -W` or `exe/lrama --warnings` to show redefined parameterizing rules.
98
193
 
99
- ```
100
- exe/lrama -W sample/calc.y
194
+ ```console
195
+ $ exe/lrama -W sample/calc.y
101
196
  parameterizing rule redefined: redefined_method(X)
102
197
  parameterizing rule redefined: redefined_method(X)
103
198
  ```
@@ -117,7 +212,7 @@ https://github.com/ruby/lrama/pull/457
117
212
 
118
213
  Allow to specify tag on callee side of parameterizing rules.
119
214
 
120
- ```
215
+ ```yacc
121
216
  %union {
122
217
  int i;
123
218
  }
@@ -130,7 +225,7 @@ Allow to specify tag on callee side of parameterizing rules.
130
225
 
131
226
  Allow to use named references for actions of RHS in parameterizing rules.
132
227
 
133
- ```
228
+ ```yacc
134
229
  %rule option(number): /* empty */
135
230
  | number { $$ = $number; }
136
231
  ;
@@ -142,7 +237,7 @@ Allow to use named references for actions of RHS in parameterizing rules.
142
237
 
143
238
  Allow to nested parameterizing rules with tag.
144
239
 
145
- ```
240
+ ```yacc
146
241
  %union {
147
242
  int i;
148
243
  }
@@ -179,8 +274,8 @@ User can use `'symbol'?`, `'symbol'+` and `'symbol'*` in RHS of user defined par
179
274
  Support trace actions for debugging.
180
275
  Run `exe/lrama --trace=actions` to show grammar rules with actions.
181
276
 
182
- ```
183
- exe/lrama --trace=actions sample/calc.y
277
+ ```console
278
+ $ exe/lrama --trace=actions sample/calc.y
184
279
  Grammar rules with actions:
185
280
  $accept -> list, YYEOF {}
186
281
  list -> ε {}
@@ -199,7 +294,7 @@ expr -> '(', expr, ')' { $$ = $2; }
199
294
  Support inlining for rules.
200
295
  The `%inline` directive causes all references to symbols to be replaced with its definition.
201
296
 
202
- ```
297
+ ```yacc
203
298
  %rule %inline op: PLUS { + }
204
299
  | TIMES { * }
205
300
  ;
@@ -213,7 +308,7 @@ expr : number { $$ = $1; }
213
308
 
214
309
  as same as
215
310
 
216
- ```
311
+ ```yacc
217
312
  expr : number { $$ = $1; }
218
313
  | expr '+' expr { $$ = $1 + $3; }
219
314
  | expr '*' expr { $$ = $1 * $3; }
@@ -226,7 +321,7 @@ expr : number { $$ = $1; }
226
321
 
227
322
  User can specify the type of mid rule action by tag (`<bar>`) instead of specifying it with in an action.
228
323
 
229
- ```
324
+ ```yacc
230
325
  primary: k_case expr_value terms?
231
326
  {
232
327
  $<val>$ = p->case_labels;
@@ -241,7 +336,7 @@ primary: k_case expr_value terms?
241
336
 
242
337
  can be written as
243
338
 
244
- ```
339
+ ```yacc
245
340
  primary: k_case expr_value terms?
246
341
  {
247
342
  $$ = p->case_labels;
@@ -266,7 +361,7 @@ Bison supports this feature from 3.1.
266
361
 
267
362
  Support `preceded`, `terminated` and `delimited` rules.
268
363
 
269
- ```
364
+ ```text
270
365
  program: preceded(opening, X)
271
366
 
272
367
  // Expanded to
@@ -302,7 +397,7 @@ In general, these resources are freed by actions or after parsing.
302
397
  However if syntax error happens in parsing, these codes may not be executed.
303
398
  Codes associated to `%destructor` are executed when semantic value is popped from the stack by an error.
304
399
 
305
- ```
400
+ ```yacc
306
401
  %token <val1> NUM
307
402
  %type <val2> expr2
308
403
  %type <val3> expr
@@ -350,7 +445,7 @@ Lrama provides these five callbacks. Registered functions are called when each e
350
445
  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
446
  For example
352
447
 
353
- ```
448
+ ```yacc
354
449
  primary: k_if expr_value then compstmt if_tail k_end
355
450
  {
356
451
  /*% ripper: if!($:2, $:4, $:5) %*/
@@ -375,7 +470,7 @@ https://github.com/ruby/lrama/pull/344
375
470
 
376
471
  Allow to pass an instantiated rule to other parameterizing rules.
377
472
 
378
- ```
473
+ ```yacc
379
474
  %rule constant(X) : X
380
475
  ;
381
476
 
@@ -392,7 +487,7 @@ program : option(constant(number)) // Nested rule
392
487
 
393
488
  Allow to use nested parameterizing rules when define parameterizing rules.
394
489
 
395
- ```
490
+ ```yacc
396
491
  %rule option(x) : /* empty */
397
492
  | X
398
493
  ;
@@ -419,7 +514,7 @@ https://github.com/ruby/lrama/pull/337
419
514
 
420
515
  Allow to define parameterizing rule by `%rule` directive.
421
516
 
422
- ```
517
+ ```yacc
423
518
  %rule pair(X, Y): X Y { $$ = $1 + $2; }
424
519
  ;
425
520
 
@@ -442,7 +537,7 @@ https://github.com/ruby/lrama/pull/285
442
537
  Allow to specify type of rules by specifying tag, `<i>` in below example.
443
538
  Tag is post-modification style.
444
539
 
445
- ```
540
+ ```yacc
446
541
  %union {
447
542
  int i;
448
543
  }
@@ -469,7 +564,7 @@ https://github.com/ruby/lrama/pull/197
469
564
 
470
565
  Support `separated_list` and `separated_nonempty_list` parameterizing rules.
471
566
 
472
- ```
567
+ ```text
473
568
  program: separated_list(',', number)
474
569
 
475
570
  // Expanded to
@@ -500,7 +595,7 @@ https://github.com/ruby/lrama/pull/204
500
595
  Parameterizing rules are template of rules.
501
596
  It's very common pattern to write "list" grammar rule like:
502
597
 
503
- ```
598
+ ```yacc
504
599
  opt_args: /* none */
505
600
  | args
506
601
  ;
@@ -532,7 +627,7 @@ https://github.com/ruby/lrama/pull/62
532
627
 
533
628
  ### Runtime configuration for error recovery
534
629
 
535
- Meke error recovery function configurable on runtime by two new macros.
630
+ Make error recovery function configurable on runtime by two new macros.
536
631
 
537
632
  * `YYMAXREPAIR`: Expected to return max length of repair operations. `%parse-param` is passed to this function.
538
633
  * `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 +650,7 @@ https://github.com/ruby/lrama/pull/44
555
650
  Instead of positional references like `$1` or `$$`,
556
651
  named references allow to access to symbol by name.
557
652
 
558
- ```
653
+ ```yacc
559
654
  primary: k_class cpath superclass bodystmt k_end
560
655
  {
561
656
  $primary = new_class($cpath, $bodystmt, $superclass);
@@ -564,7 +659,7 @@ primary: k_class cpath superclass bodystmt k_end
564
659
 
565
660
  Alias name can be declared.
566
661
 
567
- ```
662
+ ```yacc
568
663
  expr[result]: expr[ex-left] '+' expr[ex.right]
569
664
  {
570
665
  $result = $[ex-left] + $[ex.right];
data/README.md CHANGED
@@ -6,19 +6,32 @@
6
6
 
7
7
  Lrama is LALR (1) parser generator written by Ruby. The first goal of this project is providing error tolerant parser for CRuby with minimal changes on CRuby parse.y file.
8
8
 
9
- * [Features](#features)
10
- * [Installation](#installation)
11
- * [Usage](#usage)
12
- * [Versions and Branches](#versions-and-branches)
13
- * [Supported Ruby version](#supported-ruby-version)
14
- * [Development](#development)
15
- * [How to generate parser.rb](#how-to-generate-parserrb)
16
- * [Test](#test)
17
- * [Call-stack Profiling Lrama](#call-stack-profiling-lrama)
18
- * [Memory Profiling Lrama](#memory-profiling-lrama)
19
- * [Build Ruby](#build-ruby)
20
- * [Release flow](#release-flow)
21
- * [License](#license)
9
+ - [Features](#features)
10
+ - [Installation](#installation)
11
+ - [Usage](#usage)
12
+ - [Documentation](#documentation)
13
+ - [Versions and Branches](#versions-and-branches)
14
+ - [v0\_7 (`master` branch)](#v0_7-master-branch)
15
+ - [v0\_6 (`lrama_0_6` branch)](#v0_6-lrama_0_6-branch)
16
+ - [v0\_5 (`lrama_0_5` branch)](#v0_5-lrama_0_5-branch)
17
+ - [v0\_4 (`lrama_0_4` branch)](#v0_4-lrama_0_4-branch)
18
+ - [Supported Ruby version](#supported-ruby-version)
19
+ - [Development](#development)
20
+ - [How to generate parser.rb](#how-to-generate-parserrb)
21
+ - [How to Write a Type Signature](#how-to-write-a-type-signature)
22
+ - [Test](#test)
23
+ - [Call-stack Profiling Lrama](#call-stack-profiling-lrama)
24
+ - [1. Create parse.tmp.y in ruby/ruby](#1-create-parsetmpy-in-rubyruby)
25
+ - [2. Enable Profiler](#2-enable-profiler)
26
+ - [3. Run Lrama](#3-run-lrama)
27
+ - [4. Generate Flamegraph](#4-generate-flamegraph)
28
+ - [Memory Profiling Lrama](#memory-profiling-lrama)
29
+ - [1. Create parse.tmp.y in ruby/ruby](#1-create-parsetmpy-in-rubyruby-1)
30
+ - [2. Enable Profiler](#2-enable-profiler-1)
31
+ - [3. Run Lrama](#3-run-lrama-1)
32
+ - [Build Ruby](#build-ruby)
33
+ - [Release flow](#release-flow)
34
+ - [License](#license)
22
35
 
23
36
  ## Features
24
37
 
@@ -71,11 +84,19 @@ Enter the formula:
71
84
  => 9
72
85
  ```
73
86
 
87
+ ## Documentation
88
+
89
+ https://ruby.github.io/lrama/ provides a comprehensive guide to Lrama's features and usage.
90
+
74
91
  ## Versions and Branches
75
92
 
76
- ### v0_6 (`master` branch)
93
+ ### v0_7 (`master` branch)
94
+
95
+ This branch is for Ruby 3.5. `lrama_0_7` branch is created from this branch, once Ruby 3.5 is released.
96
+
97
+ ### v0_6 (`lrama_0_6` branch)
77
98
 
78
- This branch is for Ruby 3.4. `lrama_0_6` branch is created from this branch, once Ruby 3.4 is released.
99
+ This branch is for Ruby 3.4.
79
100
 
80
101
  ### v0_5 (`lrama_0_5` branch)
81
102
 
@@ -102,6 +123,14 @@ $ bundle exec rake build:parser
102
123
  `parser.rb` is generated from `parser.y` by Racc.
103
124
  Run the rake command when you update `parser.y` then commit changes of both files.
104
125
 
126
+ ### How to Write a Type Signature
127
+
128
+ We use [Steep](https://github.com/soutaro/steep) for type checking and [rbs-inline](https://github.com/soutaro/rbs-inline) for type declarations.
129
+
130
+ Currently, type signatures are declared in the [sig/lrama](https://github.com/ruby/lrama/blob/master/sig/lrama) directory. However, these files will be replaced with `rbs-inline`. This means type signatures should be written directly in the source code.
131
+
132
+ For guidance on writing type signatures, refer to the [Syntax Guide](https://github.com/soutaro/rbs-inline/wiki/Syntax-guide) in the rbs-inline documentation.
133
+
105
134
  ### Test
106
135
 
107
136
  Running tests:
data/Rakefile CHANGED
@@ -15,9 +15,21 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
15
15
  end
16
16
  task :spec => "build:parser"
17
17
 
18
+ require "rdoc/task"
19
+ RDoc::Task.new do |rdoc|
20
+ rdoc.title = "Lrama Documentation"
21
+ rdoc.main = "Index.md"
22
+ rdoc.rdoc_dir = "_site"
23
+ end
24
+
18
25
  desc "steep check"
19
26
  task :steep do
20
27
  sh "bundle exec steep check"
21
28
  end
22
29
 
23
- task default: %i[spec steep]
30
+ desc "Run rbs-inline"
31
+ task :rbs_inline do
32
+ sh "bundle exec rbs-inline --output lib/"
33
+ end
34
+
35
+ task default: %i[spec rbs_inline steep]
data/Steepfile CHANGED
@@ -7,13 +7,18 @@ 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"
20
+ check "lib/lrama/logger.rb"
17
21
  check "lib/lrama/options.rb"
22
+ check "lib/lrama/trace_reporter.rb"
18
23
  check "lib/lrama/warning.rb"
19
24
  end