abiggerhammer / hammer Goto Github PK
View Code? Open in Web Editor NEWParser combinators for binary formats, in C. Yes, in C. What? Don't look at me like that.
License: GNU General Public License v2.0
Parser combinators for binary formats, in C. Yes, in C. What? Don't look at me like that.
License: GNU General Public License v2.0
LL(k) doesn't handle parses that don't consume all their input. We need to make an executive decision on what to do about that; for the meantime, the test cases that were causing test_many and test_many1 to fail have been modified to ones that don't have trailing input.
parser = Hammer::ParserBuilder.new
NameError: uninitialized constant Hammer::ParserBuilder
If a token is a prefix of another token in a choice, then depending on the order of their listing in the choice influences the results of the parser. an example:
#include <hammer/hammer.h>
#include <stdio.h>
#include <string.h>
// test with
// gcc -DBUG -o prefixbug prefixbug.c $(pkg-config --cflags --libs libhammer)
// echo "asdfv" | ./prefixbug # should return yay, does boo
// c.f.
// gcc -o prefixbug prefixbug.c $(pkg-config --cflags --libs libhammer)
// echo "asdfv" | ./prefixbug # correctly^Was expected returns yay
int main(int argc, char *argv[]) {
uint8_t input[1024];
size_t inputsize;
HParser *eol = h_token("\n",1);
HParser *words = h_choice(
#ifdef BUG
h_token("asdf",strlen("asdf")),
h_token("asdfv",strlen("asdfv")),
#else // no bug
h_token("asdfv",strlen("asdfv")),
h_token("asdf",strlen("asdf")),
#endif
NULL);
HParser *rule = h_sequence(words,eol,NULL);
inputsize = fread(input, 1, sizeof(input), stdin);
HParseResult *result = h_parse(rule, input, inputsize);
if(result) {
printf("yay!\n");
} else {
printf("boo!\n");
}
}
sorry if this is due to my poor understanding and in fact an intended feature.
In the provided examples, H_ALLOC and friends could fail. Provide a way to bail out (we might have to abandon the parse - full recognition is not possible without the memory).
TQ on IRC suggested a longjmp to the beginning of the parse, which I like, however a nicer way to abort the parse might be handy...
Currently, the naming conventions for the action and validation functions are:
act_<rulename>
validate_<rulename>
One is an abbreviated form, one a full form, and the user must remember which case uses which. It's probably more boring, but IMO easier to remember (and hence less likely to get wrong) if both would use either the full, or both the abbreviated form. I.e. either
action_<rulename>
validate_<rulename>
or
act_<rulename>
val_<rulename>
Looking forward to your thoughts.
A couplefew things:
I'm happy to write code for any/all of this, but I don't want to start digging in without some discussion/approval from the powers-that-be. =)
$ make -j1
for dir in src examples; do make -C ${dir} all; done
CC=cc
make[1]: Entering directory `/build/hammer/src'
/build/hammer/src' CC=cc make[1]: Entering directory
/build/hammer/examples'In particular:
$ cd src && make -j1
CC=cc
More information:
$ a show libglib2.0-dev | grep Version
Version: 2.24.2-1
According to [0], the g_test_fail function isn't in glib until 2.29.4, so I don't know how likely this is to ever work, but it should probably be documented if nothing else.
Many thanks,
--frozencemetery
[0] : https://mail.gnome.org/archives/gtk-devel-list/2011-May/msg00012.html
After a successful scons
build, scons test
works if, and only if, I have done a scons install
before building the test target. IMO, this defeats the purpose of the test target, since I should test it before installing, and install only after all tests yielded "ok".
SCons barfs if you don't have pkg-config. Hence, it's not an "optional" dependency.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.