Identify fragile reductions at compile time

This commit is contained in:
Max Brunsfeld 2015-02-21 10:41:23 -08:00
parent a92067702d
commit 2d436cf141
13 changed files with 4843 additions and 4790 deletions

View file

@ -212,6 +212,12 @@ static void reduce_extra(TSParser *parser, TSSymbol symbol) {
ts_tree_set_extra(parser->lookahead);
}
static void reduce_fragile(TSParser *parser, TSSymbol symbol, size_t child_count) {
reduce(parser, symbol, child_count);
ts_tree_set_fragile_left(parser->lookahead);
ts_tree_set_fragile_right(parser->lookahead);
}
static int handle_error(TSParser *parser) {
TSTree *error = parser->lookahead;
ts_tree_retain(error);
@ -374,6 +380,12 @@ const TSTree *ts_parser_parse(TSParser *parser, TSInput input,
reduce_extra(parser, action.data.symbol);
break;
case TSParseActionTypeReduceFragile:
reduce_fragile(parser, action.data.symbol, action.data.child_count);
DEBUG("reduce_fragile sym:%s, count:%u, state:%u", SYM_NAME(action.data.symbol),
action.data.child_count, ts_stack_top_state(&parser->stack));
break;
case TSParseActionTypeAccept:
DEBUG("accept");
return finish(parser);