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

Open
Geal opened this Issue Feb 26, 2015 · 73 comments

Comments

Projects
None yet
@Geal
Owner

Geal commented Feb 26, 2015

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:

@thehydroimpulse

This comment has been minimized.

Show comment
Hide comment
@thehydroimpulse

thehydroimpulse 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).

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).

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Apr 3, 2015

Owner

Nice idea, that will be useful! Please notify me when it is done, I will add a link in this list.

Owner

Geal commented Apr 3, 2015

Nice idea, that will be useful! Please notify me when it is done, I will add a link in this list.

@filipegoncalves

This comment has been minimized.

Show comment
Hide comment
@filipegoncalves

filipegoncalves Apr 27, 2015

Contributor

This looks interesting. Is anyone actively working on any of these parsers? I'd like to work on a few of these.

Contributor

filipegoncalves commented Apr 27, 2015

This looks interesting. Is anyone actively working on any of these parsers? I'd like to work on a few of these.

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Apr 27, 2015

Owner

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.

Owner

Geal commented Apr 27, 2015

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.

@elij

This comment has been minimized.

Show comment
Hide comment
@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal May 5, 2015

Owner

@elij this is a great idea! Was it easy to do?

Owner

Geal commented May 5, 2015

@elij this is a great idea! Was it easy to do?

@elij

This comment has been minimized.

Show comment
Hide comment
@elij

elij 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?

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?

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal May 5, 2015

Owner

yes, eof should be a parser provided by nom, I am just waiting for @filipegoncalves to send a PR 😉

Owner

Geal commented May 5, 2015

yes, eof should be a parser provided by nom, I am just waiting for @filipegoncalves to send a PR 😉

@filipegoncalves

This comment has been minimized.

Show comment
Hide comment
@filipegoncalves

filipegoncalves May 5, 2015

Contributor

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!

Contributor

filipegoncalves commented May 5, 2015

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!

@Keruspe

This comment has been minimized.

Show comment
Hide comment
@Keruspe

Keruspe May 29, 2015

Contributor

I might give tar a try

Contributor

Keruspe commented May 29, 2015

I might give tar a try

@nelsonjchen

This comment has been minimized.

Show comment
Hide comment
@nelsonjchen

nelsonjchen Jun 19, 2015

Contributor

Does this check off PCAP?

https://github.com/richo/pcapng-rs

Contributor

nelsonjchen commented Jun 19, 2015

Does this check off PCAP?

https://github.com/richo/pcapng-rs

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Jun 19, 2015

Owner

pcap-ng and pcap are two different formats, right? It seems the consensus now is to move everything to pcap-ng, though.

Owner

Geal commented Jun 19, 2015

pcap-ng and pcap are two different formats, right? It seems the consensus now is to move everything to pcap-ng, though.

@TechnoMancer

This comment has been minimized.

Show comment
Hide comment
@TechnoMancer

TechnoMancer Jul 17, 2015

I will try a FLAC parser, need to add quite a few things for it though.

TechnoMancer commented Jul 17, 2015

I will try a FLAC parser, need to add quite a few things for it though.

@badboy

This comment has been minimized.

Show comment
Hide comment
@badboy

badboy Jul 17, 2015

Contributor

ISO8601 is done in https://github.com/badboy/iso8601 (I hope it's mostly correct.)

Contributor

badboy commented Jul 17, 2015

ISO8601 is done in https://github.com/badboy/iso8601 (I hope it's mostly correct.)

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Jul 17, 2015

Owner

ok, it should be up to date. More to come 😄

Owner

Geal commented Jul 17, 2015

ok, it should be up to date. More to come 😄

@sbeckeriv

This comment has been minimized.

Show comment
Hide comment
@sbeckeriv

sbeckeriv commented Aug 23, 2015

WARC file format released. https://crates.io/crates/warc_parser

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Aug 24, 2015

Owner

@sbeckeriv great, thanks!

Owner

Geal commented Aug 24, 2015

@sbeckeriv great, thanks!

@porglezomp

This comment has been minimized.

Show comment
Hide comment
@porglezomp

porglezomp 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.

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.

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Sep 15, 2015

Owner

@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?

Owner

Geal commented Sep 15, 2015

@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?

@porglezomp

This comment has been minimized.

Show comment
Hide comment
@porglezomp

porglezomp 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:

  • Programming Languages
    • Rust
    • Lua (I'll do this)
    • Python (or some other whitespace significant language)
    • C

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:

  • Programming Languages
    • Rust
    • Lua (I'll do this)
    • Python (or some other whitespace significant language)
    • C
@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Sep 15, 2015

Owner

ok, I added them to the list :)

Owner

Geal commented Sep 15, 2015

ok, I added them to the list :)

@chriskrycho

This comment has been minimized.

Show comment
Hide comment
@chriskrycho

chriskrycho 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.)

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.)

@badboy

This comment has been minimized.

Show comment
Hide comment
@chriskrycho

This comment has been minimized.

Show comment
Hide comment
@chriskrycho

chriskrycho Nov 16, 2015

Thanks very much, @badboy!

chriskrycho commented Nov 16, 2015

Thanks very much, @badboy!

@fbernier

This comment has been minimized.

Show comment
Hide comment
@fbernier

fbernier Nov 16, 2015

I'll try to make the TOML parser very soon.

fbernier commented Nov 16, 2015

I'll try to make the TOML parser very soon.

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Nov 16, 2015

Owner

Actually, I think I should rewrite that INI parser, now that more convenient combinators are available.
Also, I should really work on that combinator for space separated stuff

Owner

Geal commented Nov 16, 2015

Actually, I think I should rewrite that INI parser, now that more convenient combinators are available.
Also, I should really work on that combinator for space separated stuff

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Nov 16, 2015

Owner

@fbernier great! Please keep me posted!

Owner

Geal commented Nov 16, 2015

@fbernier great! Please keep me posted!

@l0calh05t

This comment has been minimized.

Show comment
Hide comment
@l0calh05t

l0calh05t 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.

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.

@johshoff

This comment has been minimized.

Show comment
Hide comment
@johshoff

johshoff 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

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

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Nov 17, 2015

Owner

@l0calh05t to parse something like [a,b,c,] or [a,b,c] ?
@johshoff fixed, thanks

Owner

Geal commented Nov 17, 2015

@l0calh05t to parse something like [a,b,c,] or [a,b,c] ?
@johshoff fixed, thanks

@l0calh05t

This comment has been minimized.

Show comment
Hide comment
@l0calh05t

l0calh05t commented Nov 17, 2015

@Geal yes, exactly

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Nov 22, 2015

Owner

@l0calh05t for [a,b,c], you can parse with delimited!(char!('['), separated_list!( char!(','), alphabetic), char!(']')).
For [a,b,c,], you can have delimited!(char!('['), terminated!(alphabetic, char!(',')), char!(']')).

A parser that would handle both cases is much trickier.

Owner

Geal commented Nov 22, 2015

@l0calh05t for [a,b,c], you can parse with delimited!(char!('['), separated_list!( char!(','), alphabetic), char!(']')).
For [a,b,c,], you can have delimited!(char!('['), terminated!(alphabetic, char!(',')), char!(']')).

A parser that would handle both cases is much trickier.

@l0calh05t

This comment has been minimized.

Show comment
Hide comment
@l0calh05t

l0calh05t Nov 22, 2015

Both is really the more interesting case. And what is needed for Python for example

l0calh05t commented Nov 22, 2015

Both is really the more interesting case. And what is needed for Python for example

@Keruspe

This comment has been minimized.

Show comment
Hide comment
@Keruspe

Keruspe Nov 22, 2015

Contributor

Could there be something like maybe_char!(',') which would read a char, consume it if it's ',' or backtrack if it isn't?

EDIT: actually that's probably what opt!(char!(',')) would do, so you just have to take the one that parses [a,b,c] and stick that before the ']' or am I missing something?

Contributor

Keruspe commented Nov 22, 2015

Could there be something like maybe_char!(',') which would read a char, consume it if it's ',' or backtrack if it isn't?

EDIT: actually that's probably what opt!(char!(',')) would do, so you just have to take the one that parses [a,b,c] and stick that before the ']' or am I missing something?

@l0calh05t

This comment has been minimized.

Show comment
Hide comment
@l0calh05t

l0calh05t Nov 22, 2015

Problem is that wont work unless a look ahead of more than one character is added automatically

l0calh05t commented Nov 22, 2015

Problem is that wont work unless a look ahead of more than one character is added automatically

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Nov 22, 2015

Owner

In fact, it is easier than I thought, but requires some work:

preceded!(
  char!('['),
  terminated!(
    separated_list!(
      char!(','),
      alphabetic
    ),
    terminated!(
      opt!(char!(',')),
      char!(']')
    )
  )
)

opt! will return an option of the result of its child parser (Some if success, None if failure), so it will accept the trailing comma.

Owner

Geal commented Nov 22, 2015

In fact, it is easier than I thought, but requires some work:

preceded!(
  char!('['),
  terminated!(
    separated_list!(
      char!(','),
      alphabetic
    ),
    terminated!(
      opt!(char!(',')),
      char!(']')
    )
  )
)

opt! will return an option of the result of its child parser (Some if success, None if failure), so it will accept the trailing comma.

@badboy

This comment has been minimized.

Show comment
Hide comment
@badboy

badboy Nov 23, 2015

Contributor

I wrote a simplistic bencode parser: nom-bencode.

Not sure if it covers everything (yet).

Contributor

badboy commented Nov 23, 2015

I wrote a simplistic bencode parser: nom-bencode.

Not sure if it covers everything (yet).

@passcod

This comment has been minimized.

Show comment
Hide comment
@passcod

passcod Nov 28, 2015

I've started a TOML parser as a learning project: https://github.com/passcod/noml

passcod commented Nov 28, 2015

I've started a TOML parser as a learning project: https://github.com/passcod/noml

@sourrust

This comment has been minimized.

Show comment
Hide comment
@sourrust

sourrust Jan 9, 2016

Contributor

At this point I'm ready to share my flac implementation as an example parser.

Contributor

sourrust commented Jan 9, 2016

At this point I'm ready to share my flac implementation as an example parser.

@joeblew99

This comment has been minimized.

Show comment
Hide comment
@joeblew99

joeblew99 Jan 23, 2016

Hey sourrust. Nom looks great way to do this.
I am interested in parsing different video formats with nom. If there is some existing rust kibs in this space that anyone knows then u could start porting some to nom. Worth a crack to see how it goes.

I am very curious about using the streaming capabilities of nom. For my use case I want to stream data between servers, manipulate frames, and then fan it back into the main stream.
I would love to get some feedback on some potential gotchas.
Doing this type of work should ultimately feedback into making nom better.

joeblew99 commented Jan 23, 2016

Hey sourrust. Nom looks great way to do this.
I am interested in parsing different video formats with nom. If there is some existing rust kibs in this space that anyone knows then u could start porting some to nom. Worth a crack to see how it goes.

I am very curious about using the streaming capabilities of nom. For my use case I want to stream data between servers, manipulate frames, and then fan it back into the main stream.
I would love to get some feedback on some potential gotchas.
Doing this type of work should ultimately feedback into making nom better.

@tomjakubowski

This comment has been minimized.

Show comment
Hide comment
@tomjakubowski

tomjakubowski Mar 21, 2016

Correct me if I'm wrong, but the linked Redis project doesn't seem to use nom.

tomjakubowski commented Mar 21, 2016

Correct me if I'm wrong, but the linked Redis project doesn't seem to use nom.

@porglezomp

This comment has been minimized.

Show comment
Hide comment
@porglezomp

porglezomp Mar 21, 2016

I agree, I checked the history of it's Cargo.toml and at no point was nom listed as a dependency. I'm not sure how it ended up on the list, but it looks like it should be taken off.

porglezomp commented Mar 21, 2016

I agree, I checked the history of it's Cargo.toml and at no point was nom listed as a dependency. I'm not sure how it ended up on the list, but it looks like it should be taken off.

@badboy

This comment has been minimized.

Show comment
Hide comment
@badboy

badboy Mar 21, 2016

Contributor

It does in another branch, which is still not merged because time.

Contributor

badboy commented Mar 21, 2016

It does in another branch, which is still not merged because time.

@thehydroimpulse

This comment has been minimized.

Show comment
Hide comment
@thehydroimpulse

thehydroimpulse Apr 4, 2016

@Geal you can remove my Thrift library as an example as I'm no longer using Nom in it.

thehydroimpulse commented Apr 4, 2016

@Geal you can remove my Thrift library as an example as I'm no longer using Nom in it.

@joelself

This comment has been minimized.

Show comment
Hide comment
@joelself

joelself Apr 11, 2016

Contributor

I've released a TOML parser. It doesn't let you modify everything possible in the document or create documents from scratch, but does correctly parse TOML, report errors, allow some modification and then output the document with comments and whitespace intact.

Contributor

joelself commented Apr 11, 2016

I've released a TOML parser. It doesn't let you modify everything possible in the document or create documents from scratch, but does correctly parse TOML, report errors, allow some modification and then output the document with comments and whitespace intact.

@moosingin3space

This comment has been minimized.

Show comment
Hide comment
@moosingin3space

moosingin3space May 17, 2016

I've started working on a parser for IP, TCP, UDP, and Ethernet headers. It is located at https://github.com/moosingin3space/pktparse-rs.
Warning: there is little to no documentation right now!

moosingin3space commented May 17, 2016

I've started working on a parser for IP, TCP, UDP, and Ethernet headers. It is located at https://github.com/moosingin3space/pktparse-rs.
Warning: there is little to no documentation right now!

@lyze

This comment has been minimized.

Show comment
Hide comment
@lyze

lyze Jun 6, 2016

Java class file parser! It is part of a larger class project.

The parser uses helper macros based on #160 to get more backtracking support.

lyze commented Jun 6, 2016

Java class file parser! It is part of a larger class project.

The parser uses helper macros based on #160 to get more backtracking support.

@pwoolcoc

This comment has been minimized.

Show comment
Hide comment
@pwoolcoc

pwoolcoc Jun 17, 2016

Contributor

Not sure if it's worth putting here or not, but I'm using nom to parse strings for the tracery library I am writing for rust: https://github.com/pwoolcoc/tracery-rs

Contributor

pwoolcoc commented Jun 17, 2016

Not sure if it's worth putting here or not, but I'm using nom to parse strings for the tracery library I am writing for rust: https://github.com/pwoolcoc/tracery-rs

@jethrogb

This comment has been minimized.

Show comment
Hide comment
@jethrogb

jethrogb Jul 14, 2016

Contributor

A subset of C, namely C literals and expressions: https://crates.io/crates/cexpr

Contributor

jethrogb commented Jul 14, 2016

A subset of C, namely C literals and expressions: https://crates.io/crates/cexpr

@gz

This comment has been minimized.

Show comment
Hide comment
@gz

gz Sep 7, 2016

FYI I used nom to parse the linux perf data format (https://github.com/gz/rust-perfcnt/blob/master/src/linux/parser.rs) in case you want to add it. In comparison to most examples listed here it parses binary data.

Also, it's roughly 25x faster than an equivalent parser written in python ;)

gz commented Sep 7, 2016

FYI I used nom to parse the linux perf data format (https://github.com/gz/rust-perfcnt/blob/master/src/linux/parser.rs) in case you want to add it. In comparison to most examples listed here it parses binary data.

Also, it's roughly 25x faster than an equivalent parser written in python ;)

@nickbabcock

This comment has been minimized.

Show comment
Hide comment
@nickbabcock

nickbabcock Sep 15, 2016

Contributor

Boxcars is an example of a Rocket League replay parser with serde serialization. Let boxcars be a good example of Rust code using nom, and serde as extensive examples are hard to come by. While lacking user friendly error message -- among other issues, tests and documentation strive to be thorough.

Contributor

nickbabcock commented Sep 15, 2016

Boxcars is an example of a Rocket League replay parser with serde serialization. Let boxcars be a good example of Rust code using nom, and serde as extensive examples are hard to come by. While lacking user friendly error message -- among other issues, tests and documentation strive to be thorough.

@dtolnay

This comment has been minimized.

Show comment
Hide comment
@dtolnay

dtolnay Oct 31, 2016

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.

As of version 0.10.0, syn is now able to parse practically all of Rust syntax. One of my test cases is to parse the entire github.com/rust-lang/rust repo into an AST and print it back out, asserting that the output is identical to the original.

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 match expression:

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),
    })
));

dtolnay commented Oct 31, 2016

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.

As of version 0.10.0, syn is now able to parse practically all of Rust syntax. One of my test cases is to parse the entire github.com/rust-lang/rust repo into an AST and print it back out, asserting that the output is identical to the original.

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 match expression:

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),
    })
));
@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Nov 1, 2016

Owner

@dtolnay syn is an amazing example, thanks for your hard work :)

Owner

Geal commented Nov 1, 2016

@dtolnay syn is an amazing example, thanks for your hard work :)

@Geal

This comment has been minimized.

Show comment
Hide comment
@Geal

Geal Nov 1, 2016

Owner

@dtolnay could I get your input on #356? It might fix your issues with compile times, so I'd like to get your thoughts on this.

Owner

Geal commented Nov 1, 2016

@dtolnay could I get your input on #356? It might fix your issues with compile times, so I'd like to get your thoughts on this.

@J-F-Liu

This comment has been minimized.

Show comment
Hide comment
@J-F-Liu

J-F-Liu Dec 23, 2016

I am writing a PDF library using nom to parse PDF syntax. Released v0.1.0 just now.
https://github.com/J-F-Liu/lopdf

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.
https://github.com/J-F-Liu/lopdf

@valarauca

This comment has been minimized.

Show comment
Hide comment
@valarauca

valarauca Dec 23, 2016

Contributor

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 r8, r8w, r11, and r12d. Ideally I want to map these to an enum. map!() makes this easy, but how can I match those terms in nom?

Contributor

valarauca commented Dec 23, 2016

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 r8, r8w, r11, and r12d. Ideally I want to map these to an enum. map!() makes this easy, but how can I match those terms in nom?

@Keruspe

This comment has been minimized.

Show comment
Hide comment
@Keruspe

Keruspe Dec 24, 2016

Contributor

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

Contributor

Keruspe commented Dec 24, 2016

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

@przygienda

This comment has been minimized.

Show comment
Hide comment
@przygienda

przygienda Mar 9, 2017

is there a way (or it would be great if it's possible) to generate EBNF from this? Great package BTW ...

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 ...

@ithinuel

This comment has been minimized.

Show comment
Hide comment
@ithinuel

ithinuel Apr 14, 2017

Contributor

Hi,
I just pushed a pcap parser : https://github.com/ithinuel/pcap-rs.
It still needs the PR #492 to be merge so it can use official nom crate.

Any feedback is welcome.

Contributor

ithinuel commented Apr 14, 2017

Hi,
I just pushed a pcap parser : https://github.com/ithinuel/pcap-rs.
It still needs the PR #492 to be merge so it can use official nom crate.

Any feedback is welcome.

@bbqsrc

This comment has been minimized.

Show comment
Hide comment
@bbqsrc

bbqsrc Apr 19, 2017

A parser for the Mediawiki format would be quite useful.

bbqsrc commented Apr 19, 2017

A parser for the Mediawiki format would be quite useful.

@dwerner

This comment has been minimized.

Show comment
Hide comment
@dwerner

dwerner Jun 3, 2017

@Geal thanks for an awesome library! I wrote a wavefront obj/mtl 3d mesh parser using it nom-obj, which I published to crates.io

dwerner commented Jun 3, 2017

@Geal thanks for an awesome library! I wrote a wavefront obj/mtl 3d mesh parser using it nom-obj, which I published to crates.io

@olivren

This comment has been minimized.

Show comment
Hide comment
@olivren

olivren Aug 10, 2017

I wrote a parser for the simple key/value text format .properties, which is a standard for Java configuration files. It uses nom 3.1. Can it be added to the list?

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 add_return_error and return_error calls all over the place to no avail (in the branch "error-reporting"). Is there an example of a text parser that reports parsing errors?

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.

olivren commented Aug 10, 2017

I wrote a parser for the simple key/value text format .properties, which is a standard for Java configuration files. It uses nom 3.1. Can it be added to the list?

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 add_return_error and return_error calls all over the place to no avail (in the branch "error-reporting"). Is there an example of a text parser that reports parsing errors?

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.

@santifa

This comment has been minimized.

Show comment
Hide comment
@santifa

santifa Sep 5, 2017

@Geal thanks for this library.
I've implemented a parser for URI's which is
part of a larger side project for RDF (n3, ttl,...) parsers. The full abnf of rfc 3986 is implemented but the pct-encoding is still a bit messy.

santifa commented Sep 5, 2017

@Geal thanks for this library.
I've implemented a parser for URI's which is
part of a larger side project for RDF (n3, ttl,...) parsers. The full abnf of rfc 3986 is implemented but the pct-encoding is still a bit messy.

@dbrgn

This comment has been minimized.

Show comment
Hide comment
@dbrgn

dbrgn Sep 22, 2017

Contributor

Here's a parser for ICE candidates SDP (RFC 5245), used for example in WebRTC: https://github.com/dbrgn/candidateparser

Contributor

dbrgn commented Sep 22, 2017

Here's a parser for ICE candidates SDP (RFC 5245), used for example in WebRTC: https://github.com/dbrgn/candidateparser

@kamarkiewicz

This comment has been minimized.

Show comment
Hide comment
@kamarkiewicz

kamarkiewicz Sep 22, 2017

Contributor

I wrote a Session Initiation Protocol (RFC3261) low-level push parser with API inspired by seanmonstar/httparse (hyper's HTTP parser):
https://github.com/kamarkiewicz/parsip

Contributor

kamarkiewicz commented Sep 22, 2017

I wrote a Session Initiation Protocol (RFC3261) low-level push parser with API inspired by seanmonstar/httparse (hyper's HTTP parser):
https://github.com/kamarkiewicz/parsip

@thejpster

This comment has been minimized.

Show comment
Hide comment
@thejpster

thejpster Jan 11, 2018

I'd be interested in something that could parse SNMP MIB and YANG.

https://en.wikipedia.org/wiki/YANG

thejpster commented Jan 11, 2018

I'd be interested in something that could parse SNMP MIB and YANG.

https://en.wikipedia.org/wiki/YANG

@ctrlcctrlv

This comment has been minimized.

Show comment
Hide comment

ctrlcctrlv commented Jun 2, 2018

@Riduidel

This comment has been minimized.

Show comment
Hide comment
@Riduidel

Riduidel 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) ?

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) ?

@dwerner

This comment has been minimized.

Show comment
Hide comment
@dwerner

dwerner 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.

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.

@porglezomp

This comment has been minimized.

Show comment
Hide comment
@porglezomp

porglezomp 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.

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.

@vandenoever

This comment has been minimized.

Show comment
Hide comment
@ProgVal

This comment has been minimized.

Show comment
Hide comment
@ProgVal

ProgVal Jun 18, 2018

Contributor

I wrote a Python parser: https://docs.rs/python-parser/

Contributor

ProgVal commented Jun 18, 2018

I wrote a Python parser: https://docs.rs/python-parser/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment