Skip to content

Achieving Zero-Copy with Escape Transformations in Chumsky - Is It Possible? #717

Closed Answered by zesterer
Oyelowo asked this question in Q&A
Discussion options

You must be logged in to vote

Chumsky is not, in general, set up to modify an input's memory during parsing and, in fact, the library relies on being able to backtrack to observe input multiple times.

Turning \ + n into an ASCII newline character would leave the string with an unoccupied byte. By convention one might replace the unoccupied byte with a DEL, but this seems like a silly solution and unlikely to be meaningful for most text systems, and only works with ASCII.

Going back to chumsky, one pattern I've seen is to have two parsers: one for strings with no escape characters - which does not allocate - and another for strings with escape characters, which does allocate, to perform character replacement. They can …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Oyelowo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants