ποΈ Parsing in indenter instead of string hacking #5994
Replies: 4 comments
-
In Lark there's a class called Indenter, that is used to parse space relevant languages. Could we use that for Hedy? I was looking into it and seems promising, but I don't know if there's a reason why we don't use it. https://lark-parser.readthedocs.io/en/latest/examples/indented_tree.html |
Beta Was this translation helpful? Give feedback.
-
The reason we don't use it is that when I was looking into it, it did not work with our Earley parser, but maybe by now it does? Feel free to look into it, you might know more that I do! |
Beta Was this translation helpful? Give feedback.
-
Yes, you're right! It does work with Earley, but only using the standard lexer, and I think that is no help for us, which is a boomer. |
Beta Was this translation helpful? Give feedback.
-
Closed by #2892 |
Beta Was this translation helpful? Give feedback.
-
I made a half-assed solution for checking whether a line needs indentation, of course this is not pretty:
https://github.com/Felienne/hedy/blob/30c35fd3f0e6fdd687a9868e748d2e36c7c93f98/hedy.py#L1501-L1510
This could be improved by actually parsing the line with a subset of the grammar that only allows for the first line of the repetition (potentially per level so that in level 9 we do not give an indentation error with a misused
repeat
because that would be confusing.Beta Was this translation helpful? Give feedback.
All reactions