Add unit test for stack

- Also, fix bug where trees pushed onto the stack were not retained
This commit is contained in:
Max Brunsfeld 2014-06-03 13:19:49 -07:00
parent baec9f2c9a
commit 63cde3967c
7 changed files with 188 additions and 7 deletions

View file

@ -1,6 +1,10 @@
#ifndef TREE_SITTER_PARSER_STACK_H_
#define TREE_SITTER_PARSER_STACK_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "tree_sitter/runtime.h"
typedef unsigned short ts_state_id;
@ -14,6 +18,7 @@ typedef struct {
} ts_stack;
ts_stack ts_stack_make();
void ts_stack_delete(ts_stack *);
ts_tree * ts_stack_reduce(ts_stack *stack, ts_symbol symbol, size_t immediate_child_count, const int *hidden_symbol_flags, const int *ubiquitous_symbol_flags);
void ts_stack_shrink(ts_stack *stack, size_t new_size);
void ts_stack_push(ts_stack *stack, ts_state_id state, ts_tree *node);
@ -21,4 +26,8 @@ ts_state_id ts_stack_top_state(const ts_stack *stack);
ts_tree * ts_stack_top_node(const ts_stack *stack);
size_t ts_stack_right_position(const ts_stack *stack);
#ifdef __cplusplus
}
#endif
#endif