Commit graph

1205 commits

Author SHA1 Message Date
Nicolas Léveillé
f9d8f1df7f Reactivate examples that can build on windows
This is proof that Hammer can be linked and used in a windows
program!
2016-01-31 18:11:27 +01:00
Nicolas Léveillé
9a7752b9a6 Finish porting hammer's library to windows
We port registry by importing the (public domain) openbsd implementation
of the tfind/tsearch POSIX binary tree search functions.

These are only necessary when building on non-posix platforms
2016-01-31 17:27:19 +01:00
Nicolas Léveillé
206f5044a8 Remove warning about tail "potentially uninitialized"
MSVC was complaining that the `tail` variable was potentially
uninitialized in the while branch. Since the while loop is actually
coupled to the if (head != NULL) that initializes the tail variable,
we move them together, which makes the warning disappear.
2016-01-31 16:55:17 +01:00
Nicolas Léveillé
d6e6911ad1 -y for install lcov 2015-12-20 12:43:34 +01:00
Nicolas Léveillé
2623d1a5f1 Add all remaining parsers that were not compiling on windows
The last file to port for the library is registry.c
2015-12-20 11:51:05 +01:00
Nicolas Léveillé
62d793b939 Remove warning about parser signature being wrong 2015-12-20 11:51:01 +01:00
Nicolas Léveillé
c95b2987b1 Support variable array length instantiation on MSVC
As MSVC doesn't implement C99, variable-length arrays
are not supported. We use _alloca instead.
2015-12-20 11:50:58 +01:00
Nicolas Léveillé
c5ca35c347 Remove c4388 signed/unsigned mismatch
It is the counterpart to c4018 for x64 compilations.
2015-12-20 11:50:54 +01:00
Nicolas Léveillé
b3a8403b8e Remove more useless MSVC warnings 2015-12-20 11:50:40 +01:00
Meredith L. Patterson
efea10417c Merge pull request #157 from moreati/python-examples
Added Python versions of base64 examples
2015-12-13 15:31:51 -08:00
Meredith L. Patterson
f806125ab8 Merge pull request #140 from pesco/fix-wrong_bit_length
Some combinators may report the wrong amount of consumed input
2015-12-13 15:19:02 -08:00
Meredith L. Patterson
68becde6d3 Merge pull request #158 from pesco/fix-dotdot-includes
disable warning on windows about '..' in include paths
2015-12-13 11:32:17 -08:00
Sven M. Hallberg
aa1d9b7d25 disable warning on windows about '..' in include paths 2015-12-08 15:38:35 +01:00
Sven M. Hallberg
50a73f6ab2 Merge remote-tracking branch 'upstream/master' into fix-wrong_bit_length 2015-12-07 11:05:05 +01:00
TQ Hirsch
41b890c74d Merge pull request #155 from pesco/fix-alloc-failures
Handle memory allocation failures gracefully
2015-12-06 08:09:45 -08:00
Sven M. Hallberg
d28f182c4f clear arena exception handler when exiting llk_parse_chunk_ 2015-12-04 13:28:26 +01:00
Alex Willmer
c6280a98bc Added Python versions of base64 examples
These are transliterations of the existing C files.
They're not particularly Pythonic or performant, but they're a start.

Example of usage

```
$ echo '  YW55IGNhcm5hbCBwbGVhcw==' | PYTHONPATH=../build/opt/src/bindings/python/ python base64.py
inputsize=27
input=  YW55IGNhcm5hbCBwbGVhcw==
((((89L, 87L, 53L, 53L), (73L, 71L, 78L, 104L), (99L, 109L, 53L, 104L), (98L, 67L, 66L, 119L), (98L, 71L, 86L, 104L)), (99L, 'w', '=', '=')),)
$ echo '  YW55IGNhcm5hbCBwbGVhcw==' | PYTHONPATH=../build/opt/src/bindings/python/ python base64_sem1.py
inputsize=27
input=  YW55IGNhcm5hbCBwbGVhcw==
(97L, 110L, 121L, 32L, 99L, 97L, 114L, 110L, 97L, 108L, 32L, 112L, 108L, 101L, 97L, 115L)
$ echo '  YW55IGNhcm5hbCBwbGVhcw==' | PYTHONPATH=../build/opt/src/bindings/python/ python base64_sem2.py
inputsize=27
input=  YW55IGNhcm5hbCBwbGVhcw==
(97L, 110L, 121L, 32L, 99L, 97L, 114L, 110L, 97L, 108L, 32L, 112L, 108L, 101L, 97L, 115L)
```
2015-12-04 10:20:25 +00:00
Sven M. Hallberg
9602caf64f test out-of-memory handling with a mock allocator 2015-12-02 14:10:12 +01:00
Sven M. Hallberg
7b13a82851 add __m variants to some check macros 2015-12-02 13:28:24 +01:00
Sven M. Hallberg
db4fd66eaf try it with a smaller alloc 2015-12-01 18:12:21 +01:00
Sven M. Hallberg
e89d9f9134 delete results properly in parser test macros 2015-12-01 17:51:45 +01:00
Sven M. Hallberg
22b5611cdf add oom handling to iterative LR engine 2015-12-01 17:10:47 +01:00
Sven M. Hallberg
384a7b9390 reset arena jmp_bufs at end of h_llk_parse_chunk 2015-12-01 17:07:04 +01:00
Sven M. Hallberg
3ce4f61cf9 add test for out-of-memory handling 2015-12-01 16:56:08 +01:00
Sven M. Hallberg
2309bd6da9 out-of-memory support for iterative LL(k) 2015-12-01 16:48:01 +01:00
Sven M. Hallberg
d5f3e13309 out-of-memory handling in LL(k), LR, and GLR backends 2015-11-30 18:07:33 +01:00
Sven M. Hallberg
5996477a5e out-of-memory handling in packrat backend 2015-11-30 18:01:23 +01:00
Sven M. Hallberg
3fc56a0dc3 add h_alloc() which calls errx() on failure and use it for all basic allocation
Rationale: "Basic allocation" refers to things outside of parsing proper,
mostly initialization. If such allocations fail, the system is globally
emory-starved from which it will likely not recover by returning failure.
In this case, terminating the process is in fact the most robust strategy as
it may mean the difference between a permanent hang and a temporary crash.
2015-11-30 16:37:00 +01:00
Sven M. Hallberg
ca1d8df06c don't allocate a new arena in h_bind, use the existing one
Rationale: If memory allocation fails in the inner parse and we
longjump up the stack, the temporary arena will be missed and leak.

NB: This change means that any allocations done by the continuation
(in the form of new parsers, probably) will persist for the
lifetime of the parse result. Beware of wasting too much memory
this way! The bind continuation should generally keep dynamic
allocations to a minimum.
2015-11-30 14:19:40 +01:00
Sven M. Hallberg
e26a8ff572 add libhammer.pc to gitignore 2015-11-27 17:55:18 +01:00
Sven M. Hallberg
5b3cb46c96 avoid GCC warning about potential longjmp clobbers 2015-11-14 23:26:04 +01:00
Sven M. Hallberg
6aa7db833e Merge remote-tracking branch 'upstream/master' into fix-alloc-failures 2015-11-14 23:24:06 +01:00
Meredith L. Patterson
7017ea6d91 Merge pull request #156 from pesco/fix-libpath-order
fix LIBPATH order for building test_suite
2015-11-14 19:16:24 +01:00
Sven M. Hallberg
9e37fbe513 fix LIBPATH order for building test_suite 2015-11-14 18:44:53 +01:00
Sven M. Hallberg
25acd90a48 allow h_sequence(NULL) as parser for the empty sequence 2015-11-01 17:49:53 +01:00
Sven M. Hallberg
e8b1962005 out of memory handling and leak fixes in regex backend 2015-10-30 21:26:08 +01:00
Sven M. Hallberg
9ef70f2f2d never return if h_arena_malloc fails, call errx() or longjmp() 2015-10-30 21:23:45 +01:00
Sven M. Hallberg
d5e79aa4cb fail an assert on h_sequence(NULL) instead of segfaulting later 2015-10-29 22:03:05 +01:00
Sven M. Hallberg
3765fd64e1 don't pre-allocate all space when parsing an h_length_value 2015-10-29 13:12:16 +01:00
Sven M. Hallberg
d2ade1f5b4 call h_arena_free when resizing in h_carray_append 2015-10-29 13:11:32 +01:00
TQ Hirsch
a3290770e2 Merge pull request #154 from abiggerhammer/master
Don't try to recall() primitive results
2015-10-04 16:28:51 +02:00
TQ Hirsch
2c4c4ce146 Merge pull request #153 from abiggerhammer/master
fix --coverage build option; building with it now creates .gcda files…
2015-10-04 15:54:34 +02:00
Meredith L. Patterson
99ca500d2b Don't try to recall() primitive results 2015-10-04 15:32:32 +02:00
Meredith L. Patterson
9235bf793c Only do coverage with the C builds; otherwise the bindings tests don't work 2015-10-04 03:36:02 +02:00
Meredith L. Patterson
4fed9327a4 now both clang and gcc have coverage without any dumb hacks 2015-10-04 02:53:54 +02:00
Meredith L. Patterson
d809bbd1a9 slightly less ugly 2015-10-04 01:59:20 +02:00
Meredith L. Patterson
d8d106d035 typo 2015-10-04 01:55:11 +02:00
Meredith L. Patterson
2915a8f174 dirty hack continues 2015-10-04 01:52:26 +02:00
Meredith L. Patterson
2b637946fa nope, guess we need -lgcov after all 2015-10-04 01:49:39 +02:00
Meredith L. Patterson
ff65571474 this is a dirty hack, but it solves the Program builder not honoring LDFLAGS 2015-10-04 01:43:44 +02:00