Nom, a byte oriented, streaming, zero copy, parser combinators library in Rust [pdf]
spw15.langsec.org
spw15.langsec.org
I wrote this paper in January 2015, so some things changed in the meantime:
- the benchmarks have been optimized a bit, and someone contributed a cereal parser that beats nom ( https://github.com/Geal/nom_benchmarks ). It's alright, I just wanted to estimate where it stands
- there is better error management: https://github.com/Geal/nom/wiki/Error-management
- the error management types give powerful debugging features: http://dev.unhandledexpression.com/slides/langsec-2015/img/c... (test code: https://github.com/Geal/nom_colored_hexdump )
- It is now easy to embed in C ( https://github.com/Geal/nom_in_c ). I plan to make API compatible versions of some C libs
- there are more example parsers now: https://github.com/Geal/nom/issues/14 feel free to pick one up!
Here are the slides for the conference at the IEEE Langsec workshop: http://dev.unhandledexpression.com/slides/langsec-2015/
Langsec is one of the most interesting approaches to follow in security, and the ideas presented this year were amazing (I'm especially fond of the heap exploitation algebra). I highly recommend watching the videos once they will be available.
Writing parsers with nom is easy and fun, please give it a try ;) https://github.com/Geal/nom
For the streaming part, it is still a work in progress. I need a way to better represent input enabled state machines, otherwise we'll end up with streaming switch based state machines, and they are a security nigtmare.
Any plans for fancier parsing algorithms (GLL? see e.g. http://www.cs.uwm.edu/~dspiewak/papers/generalized-parser-co...)
Many thanks for the heads up!
Far as next project, Leroy's people at INRIA did excellent work in verified, LR parsers [1]. I'm not sure that anyone is building on it at the moment. Implementing that in or integrating with Rust might make for one heck of a parsing system. So long as correspondence was proven, it would be the safest one in a systems language.
[1] http://gallium.inria.fr/~fpottier/publis/jourdan-leroy-potti...
Proving with Coq the soundness of a parser compared to its grammar is a cool approach! The biggest problem one has when writing parsers in "safe" systems like parser generators or parser combinators, is the gaps between the input language intended by the designer, the input language described by the grammar and the input language described by the code. Anything that can reduce those gaps is welcome.
I shoul try at some point to use Coq or some SMT based system to hunt ambiguity in formats. That would make an interesting research ;)
It's named that way because a nom parser takes a byte of data ;)
Nom
NomOm
NomNom
NomOmOm
NomOmNom
...The biggest difference here is the use of a syntax extension to parse the grammar. This is something I would like to do at some point, because it can make the code nicer. Right now, macros are good, because you can use nom directly without Rust 1.0, no need for feature gates.
Anyway, thanks for this great project!
1: Of course, all programming languages have runtimes, but once we got down to C or C++ levels of runtime, that is.
Nom can handle easily regular, context-free and context sensitive grammars (a lot of binary formats are a bit context sensitive, so that was a requirement). I suspect it could do recursively enumerable too.