-
I've been struggling with a corner case in my DSL built using Lark. It has significant indentation like Python. The corner case is when the program text happens not to end with a newline. I kept trying to massage my rules and terminals to handle this case cleanly, until I took a look at Lark's implementation of the Python grammar for inspiration and came across this: lark/examples/advanced/python_parser.py Line 59 in 87bb8ef Is this basically the "correct" way to cover this case in Lark? I noticed that in CPython they have something called |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I consider it correct, as it's the simplest, and is equivalent to EOF without requiring a special marker. There is an open PR I made long ago that tried to implement support for EOF, but it had subtle issues, and I decided not to merge it in. |
Beta Was this translation helpful? Give feedback.
I consider it correct, as it's the simplest, and is equivalent to EOF without requiring a special marker.
There is an open PR I made long ago that tried to implement support for EOF, but it had subtle issues, and I decided not to merge it in.