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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Parsing Text with Nom

52 点作者 adamch超过 3 年前

3 条评论

Ciantic超过 3 年前
I wanted to parse log files with Rust, and found Nom, however before that I found someone elses attempt at it:<p><a href="https:&#x2F;&#x2F;www.cloudcity.io&#x2F;blog&#x2F;2018&#x2F;11&#x2F;08&#x2F;parsing-logs-230x-faster-with-rust&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.cloudcity.io&#x2F;blog&#x2F;2018&#x2F;11&#x2F;08&#x2F;parsing-logs-230x-f...</a><p>In the end I didn&#x27;t use Nom for the time being, as the author said:<p>&gt; While wondering if there was a way to make it faster, I started re-reading the nom docs carefully, and that’s when I noticed that “sometimes, nom can be almost as fast as regex”. Feeling pretty silly, I went and rewrote my rust program to use the regex crate, and sure enough it got 3x faster.<p>Nom parser library is slower than regex crate? In simple cases it might not be worth it unfortunately.
评论 #29905687 未加载
评论 #29905455 未加载
jynelson超过 3 年前
&gt; &quot;Parsing&quot; is turning a stream of raw text or binary into some structured data types, i.e. a Rust type that your code can understand and use.<p>This is a similar take to <a href="https:&#x2F;&#x2F;lexi-lambda.github.io&#x2F;blog&#x2F;2019&#x2F;11&#x2F;05&#x2F;parse-don-t-validate" rel="nofollow">https:&#x2F;&#x2F;lexi-lambda.github.io&#x2F;blog&#x2F;2019&#x2F;11&#x2F;05&#x2F;parse-don-t-va...</a>, which goes into more detail on why &quot;structured&quot; is a requirement.<p>(Hi Adam!)
评论 #29905506 未加载
评论 #29905745 未加载
mirekrusin超过 3 年前
Parser combinators are great, we&#x27;re using parser combinators in production, they are great ie. if somebody wants to play from typescript [0] – they create very readable code that is easy to compose&#x2F;extend.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;preludejs&#x2F;parser" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;preludejs&#x2F;parser</a>