Update indent.rs in order to have a proper Pratt parser#808
Update indent.rs in order to have a proper Pratt parser#808Germ210 wants to merge 1 commit intozesterer:mainfrom
Conversation
|
Hi, looks like you need to enable the My feeling is that we should keep the pratt parser here simple, simpler than this example (perhaps just |
| *1 + -2 * 3! | ||
| loop: | ||
| 10 | ||
|
|
There was a problem hiding this comment.
It's important to also show that trailing expressions work here too (i.e: expressions that appear after a nested block). I'd suggest something like the following example:
loop:
1 + 2 * 3
loop:
10 + 3
42 * 3
3 + 2 * 9
There was a problem hiding this comment.
Alright, I can add that later, but in the original parser (and presumably this one), when given the input:
expr
expr
loop:
expr
It will output the tree:
Some(
[
Expr,
Expr,
Loop(
[
Expr,
],
),
],
)
Is this the intended behavior? I would assume that in order to be nested, it would need to have the corresponding indentation? Or is this intentional?
0f2b61a to
e350fc6
Compare
This rewrites indent.rs to use a real Pratt parser. Previously, the file had a TODO noting that it should eventually use expression parsing, but in the meantime it didn’t actually implement any precedence rules—it just matched the text "expr" directly. This change introduces proper precedence handling using a Pratt parser, making the indentation-sensitive parser more accurate and extensible, while keeping the overall behavior consistent.