Permalink
Browse files

Added new build system

  • Loading branch information...
2 parents e9a7c0b + aed1de5 commit b0f567c090b8e09518f2a06f9849812ccc00fcbb @thequux thequux committed Jul 10, 2013
View
@@ -6,6 +6,8 @@
SUBDIRS = src examples jni
include config.mk
+TOPLEVEL=.
+include common.mk
CONFIG_VARS= INCLUDE_TESTS
View
@@ -12,8 +12,8 @@ Features
* Parsing backends:
* Packrat parsing
* LL(k)
- * GLR (not yet implemented)
- * LALR(8) (not yet implemented)
+ * GLR
+ * LALR
* Regular expressions
* Language bindings:
* C++ (not yet implemented)
@@ -28,19 +28,23 @@ Features
Installing
==========
### Prerequisites
-* make
+* SCons
* a JDK
### Optional Dependencies
* pkg-config (for `make test`)
* glib-2.0 (>= 2.29) (for `make test`)
* glib-2.0-dev (for `make test`)
-To install, type `make`. To run the built-in test suite, type `make test`.
+To build, type `scons`. To run the built-in test suite, type `scons test`. For a debug build, add `--variant=debug`
-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.
+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.
-There is not currently a `make install` target; to make Hammer available system-wide, copy `libhammer.a` to `/usr/lib/` (or `/usr/local/lib/`, or wherever ld will find it) and `hammer.h` to `/usr/include/`.
+There is currently no `install` target; to make Hammer available system-wide,
+copy `libhammer.a` and `libhammer.so` from `build/opt/src` to `/usr/lib/` (or
+`/usr/local/lib/`, or wherever ld will find it) and `hammer.h` to
+`/usr/include/`.
Usage
=====
View
@@ -8,7 +8,7 @@ AddOption("--variant",
dest="variant",
nargs=1, type="choice",
choices=["debug", "opt"],
- default="debug",
+ default="opt",
action="store",
help="Build variant (debug or opt)")
@@ -28,3 +28,5 @@ Export('env')
env.SConscript(["src/SConscript"], variant_dir='build/$VARIANT/src')
env.SConscript(["examples/SConscript"], variant_dir='build/$VARIANT/examples')
+
+env.Command('test', 'build/$VARIANT/src/test_suite', 'env LD_LIBRARY_PATH=build/$VARIANT/src $SOURCE')
View
@@ -1,3 +1,7 @@
+ifneq ($(REALLY_USE_OBSOLETE_BUILD_SYSTEM),yes)
+$(error This is the old build system. Use "scons" to build, or use $(MAKE) REALLY_USE_OBSOLETE_BUILD_SYSTEM=yes)
+endif
+
# Check to make sure variables are properly set
ifeq ($(TOPLEVEL),)
$(error $$TOPLEVEL is unset)
View
@@ -181,7 +181,7 @@ HParser* init_rdata(uint16_t type) {
parsers[16] = txt;
// All parsers must consume their input exactly.
- for(uint16_t i; i<sizeof(parsers); i++) {
+ for(uint16_t i = 0; i<RDATA_TYPE_MAX+1; i++) {
if(parsers[i]) {
parsers[i] = h_action(h_sequence(parsers[i], h_end_p(), NULL),
act_index0);
View
@@ -27,8 +27,10 @@ PARSERS := \
BACKENDS := \
packrat \
+ regex \
llk \
- regex
+ lalr \
+ glr
HAMMER_PARTS := \
bitreader.o \
@@ -42,6 +44,8 @@ HAMMER_PARTS := \
benchmark.o \
cfgrammar.o \
glue.o \
+ backends/lr.o \
+ backends/lr0.o \
$(PARSERS:%=parsers/%.o) \
$(BACKENDS:%=backends/%.o)
View
@@ -1,3 +1,4 @@
+# -*- python -*-
Import('env')
parsers = ['parsers/%s.c'%s for s in
@@ -27,7 +28,7 @@ parsers = ['parsers/%s.c'%s for s in
'xor']]
backends = ['backends/%s.c' % s for s in
- ['packrat', 'llk', 'regex']]
+ ['packrat', 'llk', 'regex', 'glr', 'lalr', 'lr', 'lr0']]
misc_hammer_parts = [
'allocator.c',
View
@@ -65,10 +65,10 @@ void* h_arena_malloc(HArena *arena, size_t size) {
if (size <= arena->head->free) {
// fast path..
void* ret = arena->head->rest + arena->head->used;
- arena->used += size + 1;
+ arena->used += size;
arena->wasted -= size;
- arena->head->used += size + 1;
- arena->head->free -= size + 1;
+ arena->head->used += size;
+ arena->head->free -= size;
return ret;
} else if (size > arena->block_size) {
// We need a new, dedicated block for it, because it won't fit in a standard sized one.
@@ -11,6 +11,8 @@ struct HCFStack_ {
int count;
int cap;
HCFChoice *last_completed; // Last completed choice.
+ // XXX is last_completed still needed?
+ HCFChoice *prealloc; // If not NULL, will be used for the outermost choice.
};
#ifndef UNUSED
@@ -25,11 +27,13 @@ static HCFStack* h_cfstack_new(HAllocator *mm__) {
stack->count = 0;
stack->cap = 4;
stack->stack = h_new(HCFChoice*, stack->cap);
+ stack->prealloc = NULL;
return stack;
}
static void h_cfstack_free(HAllocator *mm__, HCFStack *stk__) UNUSED;
static void h_cfstack_free(HAllocator *mm__, HCFStack *stk__) {
+ h_free(stk__->prealloc);
h_free(stk__->stack);
h_free(stk__);
}
@@ -56,7 +60,9 @@ static inline void h_cfstack_add_to_seq(HAllocator *mm__, HCFStack *stk__, HCFCh
}
static inline HCFChoice* h_cfstack_new_choice_raw(HAllocator *mm__, HCFStack *stk__) {
- HCFChoice *ret = h_new(HCFChoice, 1);
+ HCFChoice *ret = stk__->prealloc? stk__->prealloc : h_new(HCFChoice, 1);
+ stk__->prealloc = NULL;
+
ret->reshape = NULL;
ret->action = NULL;
ret->pred = NULL;
Oops, something went wrong.

0 comments on commit b0f567c

Please sign in to comment.