Make separate header files for stack and lexer

This commit is contained in:
Max Brunsfeld 2014-05-09 13:32:12 -07:00
parent e4be585c43
commit ccc1b41f2a
4 changed files with 96 additions and 99 deletions

View file

@ -1,18 +1,9 @@
#include "tree_sitter/runtime.h"
#include "tree_sitter/parser/stack.h"
#include <string.h>
typedef int state_id;
typedef struct {
size_t size;
struct {
ts_tree *node;
state_id state;
} *entries;
} ts_stack;
static int INITIAL_STACK_SIZE = 100;
static int INITIAL_STATE = 0;
static size_t INITIAL_STACK_SIZE = 100;
static ts_state_id INITIAL_STATE = 0;
ts_stack ts_stack_make() {
ts_stack result = {
@ -22,7 +13,7 @@ ts_stack ts_stack_make() {
return result;
}
state_id ts_stack_top_state(const ts_stack *stack) {
ts_state_id ts_stack_top_state(const ts_stack *stack) {
if (stack->size == 0) return INITIAL_STATE;
return stack->entries[stack->size - 1].state;
}
@ -32,7 +23,7 @@ ts_tree * ts_stack_top_node(const ts_stack *stack) {
return stack->entries[stack->size - 1].node;
}
void ts_stack_push(ts_stack *stack, state_id state, ts_tree *node) {
void ts_stack_push(ts_stack *stack, ts_state_id state, ts_tree *node) {
stack->entries[stack->size].state = state;
stack->entries[stack->size].node = node;
stack->size++;