Is there a way to make .padded().repeated() stop when encountering pattern? #636
Unanswered
SergeyKasmy
asked this question in
Q&A
Replies: 1 comment
-
You can do something like |
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
-
Hello.
I'm looking for a way to make a
.padded().repeated()
parser stop at an empty new line, i.e.newline().then(newline())
but sadly I haven't been successful.For example, I have a file formatted like this:
At first, to parse HEADER1, I came up with something like this
Sadly this obviously eats up every other input after HEADER1.
Adding
.then_ignore(empty_line)
at the end doesn't work because.repeated()
is eagerly evaluated.I've tried replacing
.padded()
with.padded_by(empty_line.not().or(whitespace()))
but it screams at me thatempty_line
andwhitespace()
parsers return different values.Just making header1 the last parser in the chain isn't an option because I want to report any unrecognized lines in the file and not interpret them as part of header1, e.g. I want this to error:
Is there anything I can do to make the
.padded().repeated()
parser stop at\n\n
?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions