TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Parsing bitstreams with Nom

105 点作者 adamch大约 3 年前

9 条评论

woodruffw大约 3 年前
This is very clever, and a great demonstration of how flexible and generic Nom is!<p>It&#x27;s not quite as inspired, but I wrote a minimal bitstream cursor&#x2F;parser from scratch in Rust a few months ago[1]. It&#x27;s developed with LLVM bitstreams in mind, but the API itself is suitable for just about any bitstream.<p>[1]: <a href="https:&#x2F;&#x2F;docs.rs&#x2F;llvm-bitcursor&#x2F;latest&#x2F;llvm_bitcursor&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;llvm-bitcursor&#x2F;latest&#x2F;llvm_bitcursor&#x2F;index.h...</a>
评论 #30541057 未加载
minhajuddin大约 3 年前
I have started fiddling with rust, and one thing that I miss from the Elixir world is binary pattern parsing&#x2F;matching. The elixir model is so much nicer, I&#x27;ve used byteorder to convert a datetime to a byte array and then the reverse and it is not the most elegant code, nom looks much nicer. I wish rust had Elixir&#x2F;Erlang like binary pattern matching.
评论 #30537097 未加载
faitswulff大约 3 年前
Nom is a fantastic library. I&#x27;ve never implemented a parser before and I found it relatively easy to pick up. Some of that is due to parser combinators in general, no doubt, but it was very satisfying to be able to compose a parser with nom.
评论 #30538051 未加载
评论 #30537281 未加载
评论 #30537812 未加载
jstanley大约 3 年前
If you want some practice, you could try solving Advent of Code 2021 day 16: <a href="https:&#x2F;&#x2F;adventofcode.com&#x2F;2021&#x2F;day&#x2F;16" rel="nofollow">https:&#x2F;&#x2F;adventofcode.com&#x2F;2021&#x2F;day&#x2F;16</a>
评论 #30539237 未加载
评论 #30540783 未加载
vasilakisfil大约 3 年前
Nom is a fantastic library. I have built a SIP library [1] on top of Nom, no way I would have built that without Nom&#x27;s help, and even if I did, it would be a heck of a mess and under-optimized code.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;vasilakisfil&#x2F;rsip" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vasilakisfil&#x2F;rsip</a>
thelema314大约 3 年前
I have to note ocaml-bitmatch&#x2F;bitstring. Example code: <a href="https:&#x2F;&#x2F;bitstring.software&#x2F;documentation&#x2F;#matching-bitstrings-with-patterns" rel="nofollow">https:&#x2F;&#x2F;bitstring.software&#x2F;documentation&#x2F;#matching-bitstring...</a><p>This was extremely convenient for me in the past.
loeg大约 3 年前
In the past (also Advent of Code 2021), I found the bitvec crate’s BitSlice pretty convenient for parsing bitstreams.
评论 #30538749 未加载
评论 #30537095 未加载
评论 #30540200 未加载
jhoechtl大约 3 年前
When I see rust code I have the feeling that as a developer you are in a constant battle with the compiler to fulfill its type system.<p>I wonder if some unit test &#x2F; fuzz tests in a less strict language could lead to the same amount of code quality yet at a higher level of work satisfaction while writing the code.
评论 #30539104 未加载
评论 #30539381 未加载
评论 #30539126 未加载
pjc50大约 3 年前
Does anyone have a good &quot;how to parser combinator&quot; introduction? I&#x27;ve been looking at C# to dismantle various binary formats and this may be a good approach.
评论 #30540807 未加载
评论 #30539519 未加载