Adding a Not
operator
#88
Replies: 2 comments 11 replies
-
A related thing I was thinking about is, is it possible to have let notDocLines = PrefixUpTo {
"\n"
oneOrMoreSpaces
"/// "
} |
Beta Was this translation helpful? Give feedback.
-
I think I think we could start by getting a parser into place: struct Not<Upstream>: Parser where Upstream: Parser {
} We'll need to hold onto that upstream parser: let upstream: Upstream And we'll need a builder-friendly initializer: init(@ParserBuilder _ build: () -> Upstream) {
self.upstream = build()
} Now all we need to do is implement func parse(_ input: inout Upstream.Input) -> Void? {
let original = input
if self.upstream.parse(&input) {
input = original
return nil
}
return ()
} I've only sketched this out in this GitHub text field, so there may be bugs or compiler errors to work through, but hopefully it's enough to get you started 😄 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So, in my current context, I'm parsing source code, pulling out documentation comments, which are lines prefixed with
///
(vs//
or////
). I'd like to be able to do something like (simplified):I'm not quite sure how to build a
Not
operator. Thoughts?Beta Was this translation helpful? Give feedback.
All reactions