Handle multiple ubiquitous in a row

This commit is contained in:
Max Brunsfeld 2014-08-31 12:10:31 -07:00
parent a75686b017
commit 85d8c9df5c
4 changed files with 144 additions and 39 deletions

View file

@ -6,10 +6,10 @@ static size_t INITIAL_STACK_SIZE = 100;
static TSStateId INITIAL_STATE = 0;
TSStack ts_stack_make() {
TSStack result = {
.entries = calloc(INITIAL_STACK_SIZE, sizeof(*result.entries)), .size = 0,
.capacity = INITIAL_STACK_SIZE,
};
TSStack result = { .size = 0,
.capacity = INITIAL_STACK_SIZE,
.entries =
calloc(INITIAL_STACK_SIZE, sizeof(*result.entries)), };
return result;
}
@ -33,7 +33,8 @@ TSTree *ts_stack_top_node(const TSStack *stack) {
void ts_stack_push(TSStack *stack, TSStateId state, TSTree *node) {
if (stack->size == stack->capacity) {
stack->capacity *= 2;
stack->entries = realloc(stack->entries, stack->capacity * sizeof(*stack->entries));
stack->entries =
realloc(stack->entries, stack->capacity * sizeof(*stack->entries));
}
stack->entries[stack->size].state = state;
stack->entries[stack->size].node = node;