New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Polish and documentation work for fastparse.byte #125
Conversation
c1c8972
to
01a474a
Compare
This is basically ready now the build is green; when #122 lands I'll squash everything and clean this up for review |
It's getting complicated :) There are 2 PRs and you pushed new commit here. |
Oops, yeah lemme push to the other one |
Ok, time to clean this up and now that #122 has landed |
…leanup and tweaks and docs to help polish the API - Optimize `[U]Int{8, 16, 32, 64}` to avoid allocating temporary arrays and byte buffers - Add `Float32` and `Float64` parsers - Swap the order of arguments in `repeatWithLength`, so it matches the order of parsing - Make `hexBytes` more forgiving to whitespace, so it works with multi-line strings - Remove `ByteSeq` alias since we already have `BS` - Re-arrange the `ElemsX`/`ByteX`/`CharX` parsers; give the `ByteX`/`CharX` parsers toStrings that match their ByteX/CharX names - Move `prettyBytes` into the main `fastparse.byte` API, document it - Add `AnyElems`/`AnyBytes`/`AnyChars` parser, for quickly chomping arbitrary fixed-length input. - Update existing parsers to make heavy use of `AnyBytes`, `WordN`, and `IntN` parsers - Add a ton of minimal-example docs for all the byte specific parsers - Add a new faux-struct parser to be the intro example for byte parsers, move UDP parser down into "example byte parsers" section
s"Cannot show indices $markers outside input bounds 0 -> ${bytes.length}" | ||
) | ||
|
||
val maxIndexWidth = math.floor(math.max(0, math.log10(99))).toInt + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It equals to 2 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol nice catch, yeah that should be bytes.length
@lihaoyi New tests are wrong, and there is also some big debug output for new midi parser that distracts a little. |
Oh wat, I thought I had things running green before pushing. Lemme take a look |
Looks like it was a JS/JVM incompatibility; I only tested it on JVM locally. Will fix |
Turns out |
@@ -21,7 +21,7 @@ object ByteUtils{ | |||
s"Cannot show indices $markers outside input bounds 0 -> ${bytes.length}" | |||
) | |||
|
|||
val maxIndexWidth = math.floor(math.max(0, math.log10(bytes.length))).toInt + 1 | |||
val maxIndexWidth = bytes.length.toString.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, nice solution :D
This is a bit of a big/messy diff, that basically includes a lot of cleanup and tweaks and docs to help polish the API
[U]Int{8, 16, 32, 64}
to avoid allocating temporary arrays and byte buffersFloat32
andFloat64
parsersrepeatWithLength
, so it matches the order of parsinghexBytes
more forgiving to whitespace, so it works with multi-line stringsByteSeq
alias since we already haveBS
ElemsX
/ByteX
/CharX
parsers; give theByteX
/CharX
parsers toStringsthat match their ByteX/CharX names
prettyBytes
into the mainfastparse.byte
API, document itAnyElems
/AnyBytes
/AnyChars
parser, for quickly chomping arbitraryfixed-length input.
AnyBytes
,WordN
, andIntN
parsersdown into "example byte parsers" section