No description
Find a file
2013-12-13 09:54:36 +01:00
docs Finshed up the regex backend 2013-04-26 20:36:54 -07:00
examples Added a void* user_data pointer to HPredicate 2013-11-23 13:01:55 -06:00
jni Switched sequence and choice in JNI to varargs 2013-05-16 11:32:37 +02:00
lib Fixed a bug in hush 2012-05-26 13:13:56 +02:00
src decrufting 2013-12-06 09:41:08 +01:00
tools Remove pyc file 2013-11-20 13:25:09 -08:00
.gitignore Allow in-place build via scons --in-place 2013-11-22 19:44:30 -06:00
.travis.yml should version numbers be strings? 2013-12-06 09:36:10 +01:00
common.mk Added new build system 2013-07-10 21:32:05 +02:00
config.mk Refactored tests; make just builds library, make test builds/runs tests 2012-11-13 22:29:25 -05:00
Doxyfile Remove absolute paths from Doxyfile 2013-12-13 09:54:36 +01:00
HACKING Refactored all of the desugaring code to no longer depend on memory being initialized to 0. Everything is about 12% faster now. 2013-05-25 03:35:42 +02:00
libhammer.pc.in Fix include path 2013-12-02 11:56:20 -08:00
LICENSE Licensing under GPL v2. 2012-04-23 00:02:42 +01:00
Makefile Added new build system 2013-07-10 21:32:05 +02:00
NOTES Added benchmark skeleton, and at least stubs for all of the necessary functions 2012-11-02 17:16:53 -04:00
README.md update README.md with perl info 2013-12-06 10:19:56 +01:00
SConstruct Merge pull request #82 from thequux/perl-bindings 2013-12-05 01:06:15 -08:00
TODO Added benchmark skeleton, and at least stubs for all of the necessary functions 2012-11-02 17:16:53 -04:00

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

  • Bit-oriented -- grammars can include single-bit flags or multi-bit constructs that span character boundaries, with no hassle
  • Thread-safe, reentrant
  • Benchmarking for parsing backends -- determine empirically which backend will be most time-efficient for your grammar
  • Parsing backends:
    • Packrat parsing
    • LL(k)
    • GLR
    • LALR
    • Regular expressions
  • Language bindings:
    • C++ (not yet implemented)
    • Java (not currently building; give us a few days)
    • Python
    • Ruby (not yet implemented)
    • Perl
    • Go
    • PHP (not yet implemented)
    • .NET (not yet implemented)

Installing

Prerequisites

  • SCons

Optional Dependencies

  • pkg-config (for scons test)
  • glib-2.0 (>= 2.29) (for scons test)
  • glib-2.0-dev (for scons test)
  • swig (for Python/Perl bindings; Perl requires >= 2.0.8)
  • python2.7-dev (for Python bindings)
  • a JDK (for Java bindings)

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.

Examples

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

  • base64
  • DNS

Known Issues

The Python bindings only work with Python 2.7. SCons doesn't work with Python 3, and PyCapsule isn't available in 2.6 and below, so 2.7 is all you get. Sorry about that.

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.

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.