Merge branch 'python-bindings' of https://github.com/thequux/hammer into python-bindings
Conflicts: src/bindings/python/SConscript src/bindings/python/hammer_tests.py src/bindings/swig/hammer.i src/hammer.h
This commit is contained in:
commit
2ee82f3ac7
33 changed files with 822 additions and 328 deletions
|
|
@ -162,7 +162,7 @@ static void test_middle(gconstpointer backend) {
|
|||
|
||||
#include <ctype.h>
|
||||
|
||||
HParsedToken* upcase(const HParseResult *p) {
|
||||
HParsedToken* upcase(const HParseResult *p, void* user_data) {
|
||||
switch(p->ast->token_type) {
|
||||
case TT_SEQUENCE:
|
||||
{
|
||||
|
|
@ -202,7 +202,8 @@ static void test_action(gconstpointer backend) {
|
|||
h_ch('B'),
|
||||
NULL),
|
||||
NULL),
|
||||
upcase);
|
||||
upcase,
|
||||
NULL);
|
||||
|
||||
g_check_parse_match(action_, (HParserBackend)GPOINTER_TO_INT(backend), "ab", 2, "(u0x41 u0x42)");
|
||||
g_check_parse_match(action_, (HParserBackend)GPOINTER_TO_INT(backend), "AB", 2, "(u0x41 u0x42)");
|
||||
|
|
@ -364,7 +365,7 @@ static void test_epsilon_p(gconstpointer backend) {
|
|||
g_check_parse_match(epsilon_p_3, (HParserBackend)GPOINTER_TO_INT(backend), "a", 1, "(u0x61)");
|
||||
}
|
||||
|
||||
bool validate_test_ab(HParseResult *p) {
|
||||
bool validate_test_ab(HParseResult *p, void* user_data) {
|
||||
if (TT_SEQUENCE != p->ast->token_type)
|
||||
return false;
|
||||
if (TT_UINT != p->ast->seq->elements[0]->token_type)
|
||||
|
|
@ -376,7 +377,8 @@ bool validate_test_ab(HParseResult *p) {
|
|||
|
||||
static void test_attr_bool(gconstpointer backend) {
|
||||
const HParser *ab_ = h_attr_bool(h_many1(h_choice(h_ch('a'), h_ch('b'), NULL)),
|
||||
validate_test_ab);
|
||||
validate_test_ab,
|
||||
NULL);
|
||||
|
||||
g_check_parse_match(ab_, (HParserBackend)GPOINTER_TO_INT(backend), "aa", 2, "(u0x61 u0x61)");
|
||||
g_check_parse_match(ab_, (HParserBackend)GPOINTER_TO_INT(backend), "bb", 2, "(u0x62 u0x62)");
|
||||
|
|
@ -433,7 +435,7 @@ static void test_ambiguous(gconstpointer backend) {
|
|||
HParser *p_ = h_ch('+');
|
||||
HParser *E_ = h_indirect();
|
||||
h_bind_indirect(E_, h_choice(h_sequence(E_, p_, E_, NULL), d_, NULL));
|
||||
HParser *expr_ = h_action(E_, h_act_flatten);
|
||||
HParser *expr_ = h_action(E_, h_act_flatten, NULL);
|
||||
|
||||
g_check_parse_match(expr_, (HParserBackend)GPOINTER_TO_INT(backend), "d", 1, "(u0x64)");
|
||||
g_check_parse_match(expr_, (HParserBackend)GPOINTER_TO_INT(backend), "d+d", 3, "(u0x64 u0x2b u0x64)");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue