Home

Awesome

Hammer is a parsing library. Like many modern parsing libraries, it provides a parser combinator interface for writing grammars as inline domain-specific languages, but Hammer also provides a variety of parsing backends. It's also bit-oriented rather than character-oriented, making it ideal for parsing binary data such as images, network packets, audio, and executables.

Hammer is written in C, but will provide bindings for other languages. If you don't see a language you're interested in on the list, just ask.

Hammer currently builds under Linux and OS X. (Windows is coming.)

Build Status Features

Installing

Prerequisites

Optional Dependencies

To build, type scons. To run the built-in test suite, type scons test. For a debug build, add --variant=debug.

To build bindings, pass a "bindings" argument to scons, e.g. scons bindings=python. scons bindings=python test will build Python bindings and run tests for both C and Python. --variant=debug is valid here too. You can build more than one set of bindings at a time; just separate them with commas, e.g. scons bindings=python,perl.

For Java, if jni.h and jni_md.h aren't already somewhere on your include path, prepend C_INCLUDE_PATH=/path/to/jdk/include to that.

To make Hammer available system-wide, use scons install. This places include files in /usr/local/include/hammer and library files in /usr/local/lib by default; to install elsewhere, add a prefix=<destination> argument, e.g. scons install prefix=$HOME. A suitable bindings= argument will install bindings in whatever place your system thinks is appropriate.

Usage

Just #include <hammer/hammer.h> (also #include <hammer/glue.h> if you plan to use any of the convenience macros) and link with -lhammer.

If you've installed Hammer system-wide, you can use pkg-config in the usual way.

To learn about hammer check

Examples

The examples/ directory contains some simple examples, currently including:

Known Issues

The Python bindings work with Python 2.7, and Python 3.5+.

The requirement for SWIG >= 2.0.8 for Perl bindings is due to a known bug in SWIG. ppa:dns/irc has backports of SWIG 2.0.8 for Ubuntu versions 10.04-12.10; you can also build SWIG from source.

The .NET bindings are for Mono 3.0.6 and greater. If you're on a Debian-based distro that only provides Mono 2 (e.g., Ubuntu 12.04), there are backports for 3.0.x, and a 3.2.x PPA maintained by the Mono team.

Community

Please join us at #hammer on irc.upstandinghackers.com if you have any questions or just want to talk about parsing.

Contact

You can also email us at hammer@upstandinghackers.com.