You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I frequently find myself wanting/needing to parse complex fields of a fixed size, which is currently rather tricky using attoparsec. For example a 20 byte field consisting of a zero padded ASCII string. This field can be easily described as manyTill anyWord8 (word8 0) <* many (word8 0), but taking care of the size limiting is non-trivial.
I would like to have a combinator as the one proposed in the issue name, with the semantics that it tries to match it's argument parser completely against the next N bytes. An example implementation (although probably rather inefficient) would be:
fixed::Int->Parsera->Parsera
fixed i p =do
intermediate <-take i
case parseOnly (p <* endOfInput) intermediate ofLeft _ -> empty
Right x ->return x
The text was updated successfully, but these errors were encountered:
Your implementation seems reasonable, but I haven't seen any other requests for this, so I'm not inclined to add it in response to a once-off request. I'll reconsider if someone else shows up. Thanks.
I frequently find myself wanting/needing to parse complex fields of a fixed size, which is currently rather tricky using attoparsec. For example a 20 byte field consisting of a zero padded ASCII string. This field can be easily described as
manyTill anyWord8 (word8 0) <* many (word8 0)
, but taking care of the size limiting is non-trivial.I would like to have a combinator as the one proposed in the issue name, with the semantics that it tries to match it's argument parser completely against the next N bytes. An example implementation (although probably rather inefficient) would be:
The text was updated successfully, but these errors were encountered: