-
Notifications
You must be signed in to change notification settings - Fork 806
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
Example parsers #14
Comments
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). |
Nice idea, that will be useful! Please notify me when it is done, I will add a link in this list. |
This looks interesting. Is anyone actively working on any of these parsers? I'd like to work on a few of these. |
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. |
I've started a fastq (http://en.wikipedia.org/wiki/FASTQ_format) parser https://github.com/elij/fastq.rs |
@elij this is a great idea! Was it easy to do? |
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? |
yes, eof should be a parser provided by nom, I am just waiting for @filipegoncalves to send a PR 😉 |
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! |
I might give tar a try |
Does this check off PCAP? |
pcap-ng and pcap are two different formats, right? It seems the consensus now is to move everything to pcap-ng, though. |
I will try a FLAC parser, need to add quite a few things for it though. |
ISO8601 is done in https://github.com/badboy/iso8601 (I hope it's mostly correct.) |
ok, it should be up to date. More to come 😄 |
WARC file format released. https://crates.io/crates/warc_parser |
@sbeckeriv great, thanks! |
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. |
@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? |
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:
|
ok, I added them to the list :) |
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.) |
Thanks very much, @badboy! |
I'll try to make the TOML parser very soon. |
Actually, I think I should rewrite that INI parser, now that more convenient combinators are available. |
@fbernier great! Please keep me posted! |
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. |
That IRC example is no longer using nom. The parser was moved into its own repository: https://github.com/Detegr/RBot-parser |
A parser for Turtle. It passes the test suite in 15ms. https://github.com/vandenoever/rome/tree/master/src/io/turtle |
I wrote a Python parser: https://docs.rs/python-parser/ |
I think Redis database file format parser is not using nom at all. I couldn't find any reference to nom anywhere. |
@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 |
is there any SQL parser? |
it'd seem better to me to import it to an sql engine and interact with that data using Diesel. parsing flat sql files seems very limited. instead of writing a one-off Rust app to do this, you could add diesel bindings to Torchbear, see jazzdotdev/jazz#85 , then make a Speakeasy library for transporting data from your schema using content model in ContentDB. then, you could develop a lot further beyond. |
@naturallymitchell maybe @saggit was simply looking for something to extract some data from a raw sql dump. Like a one-off log analysis tool. :D |
I made a GameBoy ROM parser with nom5! It's extremely simple and doesn't do much, but the crate provides a useful abstraction over the metadata of GameBoy ROMs. I'll add more optional validation functions to it and refactor my emulator's ROM code to use it soon. edit: |
@MarkMcCaskey It could even make sense to refactor it then into a generalized library with config files (like, TOML and YAML, and now SANE). Do you think that'd be too much more work? |
@Geal - I wanted to post my public suffix domain list parser that I wrote a few months back. I couldn't find a performant library that did what I needed, so I grabbed nom and went to work. https://github.com/dwerner/nom-psl |
Do you mean specifying the layout of the bytes as data and creating a dynamic data structure from it? That's an interesting idea, but I don't think it'd be too helpful for my use case -- as I see it, the primary value-add of the gameboy rom parser is the data layer that it exposes, which lets the user get things like the game's title as as string or the exact cartridge type and how much ROM and RAM it has as well-named, plain Rust values. The parser may be implementable with serde deserialize on a |
Just got a 0.0.1 version of an NMEA-0183 parser using nom 5 https://github.com/YellowInnovation/nmea-0183 . I need to have a look at the docs and guidelines (the code is ugly for now) and refactor it :) I hope to submit a pull request adding a clean version of it to the parsers list soon ! :) |
This is SIP parser Torture test: kurotych/sipcore@32040e5 ( https://tools.ietf.org/html/rfc4475#section-3.1.1.1 ) |
@armatusmiles thanks, i added it to the list in 2e58a2c |
Please add OpenCypher to the list... a nice way to parse Graph DB queries could enable a wave of innovation in databases. There are zero legit serverless / autoscaling or decentralized graph databases (like you'd get with a CRDT/ORDT backend for an OpenCypher parser). GunJS is fairly close but JavaScript is not ideal for storage IMHO |
Wrote a UBJSON parser w/ nom |
There is a PDF parser here: https://github.com/J-F-Liu/lopdf (it requires using the FWIW, with |
I wrote a tool with its own programming language using nom. here is source repo. |
The gds2-parser released at https://crates.io/crates/gds2_io. BTW, my pull request tag is #1497 |
would it be feasible to write an ecmascript/typescript parser with nom as well? Or would the scope be too big for that? |
I have written 2 (public) parsers using nom which may be used as examples:
|
I made a bencode parser (the format used by .torrent files), https://github.com/edg-l/nom-bencode/ |
Hey there! I was wondering why the Rust parser on this list is Since this is a list of examples of parsers built with |
You're absolutely correct that it should be removed though. |
|
|
I am a bit surprised that no one mentioned HTML!? I saw nom_html_parser, but it was long left unmaintained. |
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:
The text was updated successfully, but these errors were encountered: