Replies: 1 comment 3 replies
-
Let's analyze your parser: let string = just('"')
.ignore_then(any().filter(|c| *c != '"').repeated())
.then_ignore(just('"'))
.map_slice(|s| Token::String(String::from(s))); It will parse a quote then everything that is not a quote and finally a quote again. So for input So a couple of suggestions:
For (2) I personally just used: let str_ = none_of('"')
.ignored()
.repeated()
.slice()
.padded_by(just('"')); You can see that P.S I am learning chumsky myself at the moment so I tried my best to help you but I might not be 100% correct. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello 👋
I just started with the library, and basically in lang dev, so bear with me 🙂
I am trying to just transform a string to a list of tokens with the following parser and types:
My problem is that the string parser includes the quotation marks, so parsing
"hello"
yields aToken::String("\"hello\"")
. What am I missing here?The full code (not much more): https://github.com/viperML/len/blob/9a9737624101575093bb958e93b846b946e3a9d1/src/lib.rs
Beta Was this translation helpful? Give feedback.
All reactions