Identify fragile reductions at compile time
This commit is contained in:
parent
a92067702d
commit
2d436cf141
13 changed files with 4843 additions and 4790 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue