Tweak debugging output

This commit is contained in:
Max Brunsfeld 2014-10-05 16:56:29 -07:00
parent e5ea4efb0b
commit 6d37877e49
3 changed files with 10 additions and 11 deletions

View file

@ -96,7 +96,9 @@ struct TSLanguage {
DEBUG_LEX((0 < lookahead &&lookahead <= 255 ? "CHAR '%c'" : "CHAR %d"), \
lookahead);
#define START_TOKEN() ts_lexer_start_token(lexer);
#define START_TOKEN() \
DEBUG_LEX("START TOKEN %lu", lexer->current_position.chars); \
ts_lexer_start_token(lexer);
#define ADVANCE(state_index) \
{ \

View file

@ -37,29 +37,26 @@ static TSLength breakdown_stack(TSParser *parser, TSInputEdit *edit) {
if (position.chars < edit->position && !children)
break;
DEBUG_PARSE("POP %s", parser->language->symbol_names[node->symbol]);
stack->size--;
position = ts_length_sub(position, ts_tree_total_size(node));
DEBUG_PARSE("POP %s %u", parser->language->symbol_names[node->symbol],
ts_stack_top_state(stack));
for (size_t i = 0; i < child_count && position.chars < edit->position; i++) {
TSTree *child = children[i];
TSStateId state = ts_stack_top_state(stack);
TSParseAction action = action_for(parser->language, state, child->symbol);
TSStateId next_state =
action.type == TSParseActionTypeShift ? action.data.to_state : state;
DEBUG_PARSE("PUT BACK %s", parser->language->symbol_names[child->symbol]);
ts_stack_push(stack, next_state, child);
position = ts_length_add(position, ts_tree_total_size(child));
DEBUG_PARSE("PUT BACK %s %u",
parser->language->symbol_names[child->symbol], next_state);
}
ts_tree_release(node);
}
DEBUG_PARSE("RESUME %lu", position.bytes);
DEBUG_PARSE("RESUME %lu", position.chars);
return position;
}

View file

@ -26,9 +26,9 @@ TSStateId ts_stack_top_state(const TSStack *stack);
TSTree *ts_stack_top_node(const TSStack *stack);
TSLength ts_stack_right_position(const TSStack *stack);
#define TS_STACK_FROM_TOP(stack, entry) \
for (TSStackEntry *entry = stack.entries + stack.size - 1; \
entry >= stack.entries; entry--)
#define TS_STACK_FROM_TOP(stack, entry) \
for (TSStackEntry *entry = (stack).entries + (stack).size - 1; \
entry >= (stack).entries; entry--)
#ifdef __cplusplus
}