PipeEnd Printer #226
-
Hi! Was wondering if PipeEnd can be made a printer in some (maybe all?) cases. let testParser = ParsePrint {
Prefix(1...) { $0 != .init(ascii: ">") }.pipe {
PrefixUpTo("_".utf8)
"_".utf8
PrefixUpTo("_".utf8)
"_".utf8
PrefixUpTo("/".utf8)
"/".utf8
}
} It can be fixed with the following workaround: let testParser = ParsePrint {
Prefix(1...) { $0 != .init(ascii: ">") }.map(.substring).pipe {
From(.utf8) {
PrefixUpTo("_".utf8)
"_".utf8
PrefixUpTo("/".utf8)
"/".utf8
}
}
} However I don't immediately see why PipeEnd can't be a printer. A (perhaps naive) extension Parsers.PipeEnd: ParserPrinter
{
@inlinable
public func print(_ output: (), into input: inout Input) throws { }
} I might be missing a more subtle case where this fails however. Otherwise I'd be glad to make a PR. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
@JaapWijnen I think this is an oversight (we've found we reach for |
Beta Was this translation helpful? Give feedback.
@JaapWijnen I think this is an oversight (we've found we reach for
map
with conversions more often thanpipe
). If you'd like to PR, the implementation should probably be the exact same asEnd
's printer conformance.