| author | |
| committer | |
| log | e5230c5e8aa95c03e62554ba31bd2f2c7ff86ed9 |
| tree | abe3bc32fa6123f2d99059ec12d2d9fdc825630c |
| parent | fb04e50659ca2dcee38b35196a2efe5ca9c3453d |
| signature |
This is a case in which the grammar is currently not LL(k) and needs a
negative lookahead to prevent backtracking.
The new grammar is consistent with the Parse.zig implementation.
See the new test case for an example.2 files changed, 7 insertions(+), 2 deletions(-)
doc/langref/grammar.peg+1-1| ... | @@ -77,7 +77,7 @@ BlockStatement | ... | @@ -77,7 +77,7 @@ BlockStatement |
| 77 | <- Statement | 77 | <- Statement |
| 78 | / KEYWORD_defer BlockExprStatement | 78 | / KEYWORD_defer BlockExprStatement |
| 79 | / KEYWORD_errdefer BlockExprStatement | 79 | / KEYWORD_errdefer BlockExprStatement |
| 80 | / (KEYWORD_comptime !BlockExprPrefix)? VarAssignStatement | 80 | / !KEYWORD_nosuspend (KEYWORD_comptime !BlockExprPrefix)? VarAssignStatement |
| 81 | 81 | ||
| 82 | Statement | 82 | Statement |
| 83 | <- IfStatement | 83 | <- IfStatement |
lib/std/zig/parser_generated_oracle.zig+6-1| ... | @@ -267,7 +267,12 @@ const Parser = struct { | ... | @@ -267,7 +267,12 @@ const Parser = struct { |
| 267 | p.i = pos_0; | 267 | p.i = pos_0; |
| 268 | if (try p.parseKEYWORD_errdefer() and try p.parseBlockExprStatement()) break :blk_0 true; | 268 | if (try p.parseKEYWORD_errdefer() and try p.parseBlockExprStatement()) break :blk_0 true; |
| 269 | p.i = pos_0; | 269 | p.i = pos_0; |
| 270 | if ((blk_3: { | 270 | if (blk_1: { |
| 271 | const pos_1 = p.i; | ||
| 272 | const match_1 = try p.parseKEYWORD_nosuspend(); | ||
| 273 | p.i = pos_1; | ||
| 274 | break :blk_1 !match_1; | ||
| 275 | } and (blk_3: { | ||
| 271 | const pos_3 = p.i; | 276 | const pos_3 = p.i; |
| 272 | if (try p.parseKEYWORD_comptime() and blk_4: { | 277 | if (try p.parseKEYWORD_comptime() and blk_4: { |
| 273 | const pos_4 = p.i; | 278 | const pos_4 = p.i; |