Added a void* user_data pointer to HAction

This commit is contained in:
Dan Hirsch 2013-11-23 12:53:11 -06:00
parent bba60f5db9
commit e487d5435c
18 changed files with 83 additions and 73 deletions

View file

@ -372,13 +372,13 @@ HParseResult *h_llk_parse(HAllocator* mm__, const HParser* parser, HInputStream*
// perform token reshape if indicated
if(x->reshape)
tok = (HParsedToken *)x->reshape(make_result(arena, tok));
tok = (HParsedToken *)x->reshape(make_result(arena, tok), x->user_data);
// call validation and semantic action, if present
if(x->pred && !x->pred(make_result(tarena, tok)))
goto no_parse; // validation failed -> no parse
if(x->action)
tok = (HParsedToken *)x->action(make_result(arena, tok));
tok = (HParsedToken *)x->action(make_result(arena, tok), x->user_data);
// append to result sequence
h_carray_append(seq, tok);

View file

@ -307,13 +307,13 @@ bool h_lrengine_step(HLREngine *engine, const HLRAction *action)
// perform token reshape if indicated
if(symbol->reshape)
value = (HParsedToken *)symbol->reshape(make_result(arena, value));
value = (HParsedToken *)symbol->reshape(make_result(arena, value), symbol->user_data);
// call validation and semantic action, if present
if(symbol->pred && !symbol->pred(make_result(tarena, value)))
return false; // validation failed -> no parse; terminate
if(symbol->action)
value = (HParsedToken *)symbol->action(make_result(arena, value));
value = (HParsedToken *)symbol->action(make_result(arena, value), symbol->user_data);
// this is LR, building a right-most derivation bottom-up, so no reduce can
// follow a reduce. we can also assume no conflict follows for GLR if we