Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upExample parsers #14
Comments
This comment has been minimized.
This comment has been minimized.
thehydroimpulse
commented
Apr 3, 2015
|
I'm writing a Thrift library for Rust that'll use Nom for both their IDL and the network protocol, so that can be another example (although in a different repo). |
This comment has been minimized.
This comment has been minimized.
|
Nice idea, that will be useful! Please notify me when it is done, I will add a link in this list. |
This comment has been minimized.
This comment has been minimized.
|
This looks interesting. Is anyone actively working on any of these parsers? I'd like to work on a few of these. |
This comment has been minimized.
This comment has been minimized.
|
I have some code for a GIF one at https://github.com/Geal/gif.rs but it is hard to test, since the graphical tools in Piston change a lot. You can pick any of them. Network packets may be the easiest, since they don't require a decompression phase. I am using the gif example to see what kind of API can be built over nom. Most of the parsing example are done as one pass over the data, but often there is some logic on the side, and it is not easy to encode correctly. |
This comment has been minimized.
This comment has been minimized.
elij
commented
May 1, 2015
|
I've started a fastq (http://en.wikipedia.org/wiki/FASTQ_format) parser https://github.com/elij/fastq.rs |
This comment has been minimized.
This comment has been minimized.
|
@elij this is a great idea! Was it easy to do? |
This comment has been minimized.
This comment has been minimized.
elij
commented
May 5, 2015
|
yup it's a great framework -- though I struggled a bit with eof so I borrowed some code from rust-config (https://github.com/elij/fastq.rs/blob/master/src/parser.rs#L69) -- is there a better solution? |
This comment has been minimized.
This comment has been minimized.
|
yes, eof should be a parser provided by nom, I am just waiting for @filipegoncalves to send a PR |
This comment has been minimized.
This comment has been minimized.
|
Hah, sorry for my silence. I've been busy lately. I just sent a PR (#31). I will be working on one of these example parsers as soon as I get some spare time. There are some great ideas in here! |
This comment has been minimized.
This comment has been minimized.
|
I might give tar a try |
This comment has been minimized.
This comment has been minimized.
|
Does this check off PCAP? |
This comment has been minimized.
This comment has been minimized.
|
pcap-ng and pcap are two different formats, right? It seems the consensus now is to move everything to pcap-ng, though. |
This comment has been minimized.
This comment has been minimized.
TechnoMancer
commented
Jul 17, 2015
|
I will try a FLAC parser, need to add quite a few things for it though. |
This comment has been minimized.
This comment has been minimized.
|
ISO8601 is done in https://github.com/badboy/iso8601 (I hope it's mostly correct.) |
This comment has been minimized.
This comment has been minimized.
|
ok, it should be up to date. More to come |
This comment has been minimized.
This comment has been minimized.
sbeckeriv
commented
Aug 23, 2015
|
WARC file format released. https://crates.io/crates/warc_parser |
This comment has been minimized.
This comment has been minimized.
|
@sbeckeriv great, thanks! |
Geal
referenced this issue
Aug 25, 2015
Merged
Implement seeking to the end of the content in a MemProducer #73
This comment has been minimized.
This comment has been minimized.
porglezomp
commented
Sep 14, 2015
|
It might be informative to try parsing the rust grammar with nom, if nobody has yet. In any case, I'd like to see a few programming languages on that list, since that's my use case. |
This comment has been minimized.
This comment has been minimized.
|
@porglezomp programming languages examples would definitely be useful, but the Rust grammar might be a bit too much for the first attempt. Which other languages would you like to handle? |
This comment has been minimized.
This comment has been minimized.
porglezomp
commented
Sep 15, 2015
|
Yeah, I'm aware of the scale problem of Rust. I don't want to write that one, but I think it's a good holy grail for any parser library written in Rust. I'd like to try parsing the Lua grammar first, I think. I recommend adding to the list:
|
This comment has been minimized.
This comment has been minimized.
|
ok, I added them to the list :) |
This comment has been minimized.
This comment has been minimized.
chriskrycho
commented
Nov 16, 2015
|
You have INI marked as done; do you have a link to it? (I'd love to use this for some tooling I'm hoping to build in 2016; need a good non-trivial example for it, though.) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
chriskrycho
commented
Nov 16, 2015
|
Thanks very much, @badboy! |
This comment has been minimized.
This comment has been minimized.
fbernier
commented
Nov 16, 2015
|
I'll try to make the TOML parser very soon. |
This comment has been minimized.
This comment has been minimized.
|
Actually, I think I should rewrite that INI parser, now that more convenient combinators are available. |
This comment has been minimized.
This comment has been minimized.
|
@fbernier great! Please keep me posted! |
This comment has been minimized.
This comment has been minimized.
l0calh05t
commented
Nov 16, 2015
|
Maybe add a simple example for trailing commas in lists? Python has those, but is quite complex. Can't think of a simple example though. |
This comment has been minimized.
This comment has been minimized.
johshoff
commented
Nov 17, 2015
|
That IRC example is no longer using nom. The parser was moved into its own repository: https://github.com/Detegr/RBot-parser |
This comment has been minimized.
This comment has been minimized.
dtolnay
commented
Oct 31, 2016
•
As of version 0.10.0, I am technically not using nom but instead a fork which removes the IResult::Incomplete variant. I found that the extra macro code generated to handle Incomplete was more than doubling the compile time for something that I didn't even want. Nevertheless, the code is enough like nom that I think we can check off the box. Example snippet to parse one arm of a named!(match_arm -> Arm, do_parse!(
attrs: many0!(outer_attr) >>
pats: separated_nonempty_list!(punct!("|"), pat) >>
guard: option!(preceded!(keyword!("if"), expr)) >>
punct!("=>") >>
body: alt!(
map!(block, |blk| ExprKind::Block(BlockCheckMode::Default, blk).into())
|
expr
) >>
(Arm {
attrs: attrs,
pats: pats,
guard: guard.map(Box::new),
body: Box::new(body),
})
)); |
This comment has been minimized.
This comment has been minimized.
|
@dtolnay syn is an amazing example, thanks for your hard work :) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
J-F-Liu
commented
Dec 23, 2016
|
I am writing a PDF library using nom to parse PDF syntax. Released v0.1.0 just now. |
This comment has been minimized.
This comment has been minimized.
|
So I've implemented a EDI parser for the ANS standard EDI for work with this. Awesome library really useful. Sadly that's owned by my employer. I've started implementing an x64 assembler with nom. I'm really struggling with writing the parser. The main reason is register names have a lot of overlap, and are very short. For example |
This comment has been minimized.
This comment has been minimized.
|
I converted several "keys" to enum values in my brainfuck parser, might or might not be relevant to your needs. See the first parsers defined with "named!" https://github.com/Keruspe/brainfuck.rs/blob/master/src/parser.rs |
This comment has been minimized.
This comment has been minimized.
przygienda
commented
Mar 9, 2017
|
is there a way (or it would be great if it's possible) to generate EBNF from this? Great package BTW ... |
This comment has been minimized.
This comment has been minimized.
|
Hi, Any feedback is welcome. |
This comment has been minimized.
This comment has been minimized.
bbqsrc
commented
Apr 19, 2017
|
A parser for the Mediawiki format would be quite useful. |
This comment has been minimized.
This comment has been minimized.
dwerner
commented
Jun 3, 2017
budziq
referenced this issue
Aug 1, 2017
Closed
Removed `self.logger.clone()` in filesink/filesrc #8
This comment has been minimized.
This comment has been minimized.
olivren
commented
Aug 10, 2017
•
|
I wrote a parser for the simple key/value text format This is the first parser I wrote using a Parser Combinator library. If anyone can review my code I would be delighted. Also, I tried to add error reporting to my code, but I gave up after I tried to insert Edit: I rewrote my library using Pest instead of Nom, as I find it more suited to parsing a text format. I will definitely use nom if I need to parse a binary format, though. |
This comment has been minimized.
This comment has been minimized.
santifa
commented
Sep 5, 2017
This comment has been minimized.
This comment has been minimized.
|
Here's a parser for ICE candidates SDP (RFC 5245), used for example in WebRTC: https://github.com/dbrgn/candidateparser |
This comment has been minimized.
This comment has been minimized.
|
I wrote a Session Initiation Protocol (RFC3261) low-level push parser with API inspired by seanmonstar/httparse (hyper's HTTP parser): |
This comment has been minimized.
This comment has been minimized.
thejpster
commented
Jan 11, 2018
|
I'd be interested in something that could parse SNMP MIB and YANG. |
ithinuel
referenced this issue
May 19, 2018
Merged
Add pcap parser to the "network protocol formats" list #774
This comment has been minimized.
This comment has been minimized.
ctrlcctrlv
commented
Jun 2, 2018
|
The BitTorrent example has been deleted, it seems. |
This comment has been minimized.
This comment has been minimized.
Riduidel
commented
Jun 6, 2018
|
As a beginner in Rust world, I'm quite sure I will say something horribly wrong, but is there any planned support for some XML dialects ? (typically RSS/ATOM) ? |
This comment has been minimized.
This comment has been minimized.
dwerner
commented
Jun 6, 2018
|
Nothing at all wrong with asking, and I'm sure someone might want to implement one at some point, but this is a list of example parsers written using nom, rather than a list of formats "supported" by nom. An xml parser would be an excellent idea for learning nom, imo. |
This comment has been minimized.
This comment has been minimized.
porglezomp
commented
Jun 7, 2018
|
@Riduidel if you're specifically interested in just having parsers for those formats, look at https://github.com/rust-syndication. I don't think there's any nom involved there though. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
vandenoever
commented
Jun 13, 2018
|
A parser for Turtle. It passes the test suite in 15ms. https://github.com/vandenoever/rome/tree/master/src/io/turtle |
This comment has been minimized.
This comment has been minimized.
|
I wrote a Python parser: https://docs.rs/python-parser/ |
This comment has been minimized.
This comment has been minimized.
idursun
commented
Jan 4, 2019
|
I think Redis database file format parser is not using nom at all. I couldn't find any reference to nom anywhere. |
This comment has been minimized.
This comment has been minimized.
|
@idursun Maybe it refers to this old branch from a year before the last update to master. https://github.com/badboy/rdb-rs/tree/nom-parser |
Geal commentedFeb 26, 2015
•
edited
We currently have a few example parsers. In order to test the project and make it useful, other formats can be implemented. Here is a list, if anyone wants to try it: