|
1 | 1 | # NEWS for Lrama |
2 | 2 |
|
3 | | -## Lrama 0.7.1 (2025-xx-xx) |
| 3 | +## Lrama 0.7.1 (2025-12-24) |
4 | 4 |
|
5 | 5 | ### Optimize IELR |
6 | 6 |
|
| 7 | +Optimized performance to a level that allows for IELR testing in practical applications. |
| 8 | + |
7 | 9 | https://github.com/ruby/lrama/pull/595 |
8 | 10 | https://github.com/ruby/lrama/pull/605 |
9 | 11 | https://github.com/ruby/lrama/pull/685 |
10 | 12 | https://github.com/ruby/lrama/pull/700 |
11 | 13 |
|
12 | 14 | ### Introduce counterexamples timeout |
13 | 15 |
|
| 16 | +Counterexample searches can sometimes take a long time, so we've added a timeout to abort the process after a set period. The current limits are: |
| 17 | + |
| 18 | +* 10 seconds per case |
| 19 | +* 120 seconds total (cumulative) |
| 20 | + |
| 21 | +Please note that these are hard-coded and cannot be modified by the user in the current version. |
| 22 | + |
14 | 23 | https://github.com/ruby/lrama/pull/623 |
15 | 24 |
|
16 | 25 | ### Optimize Counterexamples |
17 | 26 |
|
| 27 | +Optimized counterexample search performance. |
| 28 | + |
18 | 29 | https://github.com/ruby/lrama/pull/607 |
19 | 30 | https://github.com/ruby/lrama/pull/610 |
20 | 31 | https://github.com/ruby/lrama/pull/614 |
@@ -47,18 +58,128 @@ operation : /* empty */ |
47 | 58 |
|
48 | 59 | https://github.com/ruby/lrama/pull/637 |
49 | 60 |
|
50 | | -### Print conflicts of each state on output file |
| 61 | +### Render conflicts of each state on output file |
| 62 | + |
| 63 | +Added token information for conflicts in the output file. |
| 64 | +These information are useful when a state has many actions. |
51 | 65 |
|
52 | 66 | ``` |
53 | | -TODO example |
| 67 | +State 1 |
| 68 | +
|
| 69 | + 4 class: keyword_class • tSTRING "end" |
| 70 | + 5 $@1: ε • [tSTRING] |
| 71 | + 7 class: keyword_class • $@1 tSTRING '!' "end" $@2 |
| 72 | + 8 $@3: ε • [tSTRING] |
| 73 | + 10 class: keyword_class • $@3 tSTRING '?' "end" $@4 |
| 74 | +
|
| 75 | + Conflict on tSTRING. shift/reduce($@1) |
| 76 | + Conflict on tSTRING. shift/reduce($@3) |
| 77 | + Conflict on tSTRING. reduce($@1)/reduce($@3) |
| 78 | +
|
| 79 | + tSTRING shift, and go to state 6 |
| 80 | +
|
| 81 | + tSTRING reduce using rule 5 ($@1) |
| 82 | + tSTRING reduce using rule 8 ($@3) |
| 83 | +
|
| 84 | + $@1 go to state 7 |
| 85 | + $@3 go to state 8 |
54 | 86 | ``` |
55 | 87 |
|
56 | 88 | https://github.com/ruby/lrama/pull/541 |
57 | 89 |
|
58 | | -### Print the origin of conflicted tokens on output file |
| 90 | +### Render the origin of conflicted tokens on output file |
| 91 | + |
| 92 | +For example, for the grammar file like below: |
| 93 | + |
| 94 | +``` |
| 95 | +%% |
| 96 | +
|
| 97 | +program: expr |
| 98 | + ; |
| 99 | +
|
| 100 | +expr: expr '+' expr |
| 101 | + | tNUMBER |
| 102 | + ; |
| 103 | +
|
| 104 | +%% |
| 105 | +``` |
| 106 | + |
| 107 | +Lrama generates output file which describes where `"plus"` (`'+'`) look ahead tokens come from: |
| 108 | + |
| 109 | +``` |
| 110 | +State 6 |
| 111 | +
|
| 112 | + 2 expr: expr • "plus" expr |
| 113 | + 2 | expr "plus" expr • ["end of file", "plus"] |
| 114 | +
|
| 115 | + Conflict on "plus". shift/reduce(expr) |
| 116 | + "plus" comes from state 0 goto by expr |
| 117 | + "plus" comes from state 5 goto by expr |
| 118 | +``` |
| 119 | + |
| 120 | +state 0 and state 5 look like below: |
| 121 | + |
| 122 | +``` |
| 123 | +State 0 |
| 124 | +
|
| 125 | + 0 $accept: • program "end of file" |
| 126 | + 1 program: • expr |
| 127 | + 2 expr: • expr "plus" expr |
| 128 | + 3 | • tNUMBER |
| 129 | +
|
| 130 | + tNUMBER shift, and go to state 1 |
| 131 | +
|
| 132 | + program go to state 2 |
| 133 | + expr go to state 3 |
| 134 | +
|
| 135 | +State 5 |
| 136 | +
|
| 137 | + 2 expr: • expr "plus" expr |
| 138 | + 2 | expr "plus" • expr |
| 139 | + 3 | • tNUMBER |
| 140 | +
|
| 141 | + tNUMBER shift, and go to state 1 |
| 142 | +
|
| 143 | + expr go to state 6 |
| 144 | +``` |
59 | 145 |
|
60 | 146 | https://github.com/ruby/lrama/pull/726 |
61 | 147 |
|
| 148 | +### Render precedences usage information on output file |
| 149 | + |
| 150 | +For example, for the grammar file like below: |
| 151 | + |
| 152 | +``` |
| 153 | +%left tPLUS |
| 154 | +%right tUPLUS |
| 155 | +
|
| 156 | +%% |
| 157 | +
|
| 158 | +program: expr ; |
| 159 | +
|
| 160 | +expr: tUPLUS expr |
| 161 | + | expr tPLUS expr |
| 162 | + | tNUMBER |
| 163 | + ; |
| 164 | +
|
| 165 | +%% |
| 166 | +``` |
| 167 | + |
| 168 | +Lrama generates output file which describes where these precedences are used to resolve conflicts: |
| 169 | + |
| 170 | +``` |
| 171 | +Precedences |
| 172 | + precedence on "unary+" is used to resolve conflict on |
| 173 | + LALR |
| 174 | + state 5. Conflict between reduce by "expr -> tUPLUS expr" and shift "+" resolved as reduce ("+" < "unary+"). |
| 175 | + precedence on "+" is used to resolve conflict on |
| 176 | + LALR |
| 177 | + state 5. Conflict between reduce by "expr -> tUPLUS expr" and shift "+" resolved as reduce ("+" < "unary+"). |
| 178 | + state 8. Conflict between reduce by "expr -> expr tPLUS expr" and shift "+" resolved as reduce (%left "+"). |
| 179 | +``` |
| 180 | + |
| 181 | +https://github.com/ruby/lrama/pull/741 |
| 182 | + |
62 | 183 | ### Add support for reporting Rule Usage Frequency |
63 | 184 |
|
64 | 185 | Support to report rule usage frequency statistics for analyzing grammar characteristics. |
@@ -100,6 +221,54 @@ https://github.com/ruby/lrama/pull/677 |
100 | 221 |
|
101 | 222 | ### Render Split States information on output file |
102 | 223 |
|
| 224 | +For example, for the grammar file like below: |
| 225 | + |
| 226 | +``` |
| 227 | +%token a |
| 228 | +%token b |
| 229 | +%token c |
| 230 | +%define lr.type ielr |
| 231 | +
|
| 232 | +%precedence tLOWEST |
| 233 | +%precedence a |
| 234 | +%precedence tHIGHEST |
| 235 | +
|
| 236 | +%% |
| 237 | +
|
| 238 | +S: a A B a |
| 239 | + | b A B b |
| 240 | + ; |
| 241 | +
|
| 242 | +A: a C D E |
| 243 | + ; |
| 244 | +
|
| 245 | +B: c |
| 246 | + | // empty |
| 247 | + ; |
| 248 | +
|
| 249 | +C: D |
| 250 | + ; |
| 251 | +
|
| 252 | +D: a |
| 253 | + ; |
| 254 | +
|
| 255 | +E: a |
| 256 | + | %prec tHIGHEST // empty |
| 257 | + ; |
| 258 | +
|
| 259 | +%% |
| 260 | +``` |
| 261 | + |
| 262 | +Lrama generates output file which describes where which new states are created when IELR is enabled: |
| 263 | + |
| 264 | +``` |
| 265 | +Split States |
| 266 | +
|
| 267 | + State 19 is split from state 4 |
| 268 | + State 20 is split from state 9 |
| 269 | + State 21 is split from state 14 |
| 270 | +``` |
| 271 | + |
103 | 272 | https://github.com/ruby/lrama/pull/624 |
104 | 273 |
|
105 | 274 | ### Add ioption support to the Standard library |
|
0 commit comments