Replies: 1 comment
-
Yes, capturing the spans during normal error paths is a weakness. The challenge is dealing with the wide variety of different needs, e.g. #180 and #231. These can be worked around by using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm experimenting with writing a custom DSL for a toy project. Initially I started working with Chumsky, but then discovered winnow, and after playing around with it a bit I prefer its "toolbox" approach, and some of the usability features (ranges of chars as token sets, etc).
However, one feature I really like about Chumsky is its
validate
function, which can be used to add additional checks that can emit error messages. Combine that with ariadne for really nice error messages. While I could defer these checks until after the parse, having them be part of the parser makes it easy for me to save location/span info and then output nicely formatted contextual error messages.For example, I'm trying to rewrite the following Chumsky parser in winnow:
(where
ident()
is equivalent to '[a-zA-Z_][a-zA-Z0-9_]*')Outputs (via ariadne):
And here's my winnow version so far:
However,
verify
doesn't offer any way to return/emit errors.I had a quick look at
try_map
, and think that might be the right path. However, this is where I paused to open this discussion thread to ask a few questions.with_span()
and store that in my ast nodes?For example, I'd love to be able to print messages like this:
Beta Was this translation helpful? Give feedback.
All reactions