Replies: 1 comment 2 replies
-
This is a tough one! It looks like your syntax is straying surprisingly close to ambiguity. Part of me wonders whether it might be easier to have the section between the braces be parsed from right to left, although I don't think this is quite necessary. That said, Chumsky is inherently a left-to-right parser, so potential solutions might not be efficient in pessimistic cases (a single extra character after the tags would suddenly require that the parser backtracks through all of the tags again!). You might be interested in this PR that added a I'm interested to hear how you get on with it: if nothing else, this might make for a good doc example that I can add for the next release! |
Beta Was this translation helpful? Give feedback.
-
My input looks like this:
{ some free-form text that might contain hashes #tag1,#tag2 }
. The first element is some unknown text that can contain basically anything besides the closing bracket. The last part is a list of tags. I was wondering if this is possible to parse with chumsky. I'd say yes, since it should still be LL(k), k being the number of characters of the tag list. But I can't make a parser that parses it.Having the
#
be a special character would make it easier, as I can use filter in that case.This is what I have right now (the parser for the input is the
attributed_string
function):However, this does not allow hashtags to be part of the text.
Beta Was this translation helpful? Give feedback.
All reactions