Handle multiple ubiquitous in a row
This commit is contained in:
parent
a75686b017
commit
85d8c9df5c
4 changed files with 144 additions and 39 deletions
|
|
@ -7,14 +7,15 @@ extern "C" {
|
|||
|
||||
#include "tree_sitter/parser.h"
|
||||
|
||||
typedef struct {
|
||||
TSTree *node;
|
||||
TSStateId state;
|
||||
} TSStackEntry;
|
||||
|
||||
typedef struct {
|
||||
size_t size;
|
||||
size_t capacity;
|
||||
struct {
|
||||
TSTree *node;
|
||||
TSStateId state;
|
||||
int is_extra;
|
||||
} *entries;
|
||||
TSStackEntry *entries;
|
||||
} TSStack;
|
||||
|
||||
TSStack ts_stack_make();
|
||||
|
|
@ -25,6 +26,11 @@ TSStateId ts_stack_top_state(const TSStack *stack);
|
|||
TSTree *ts_stack_top_node(const TSStack *stack);
|
||||
size_t ts_stack_right_position(const TSStack *stack);
|
||||
|
||||
#define TS_STACK_FROM_TOP(stack, entry, index) \
|
||||
size_t index = stack.size - 1; \
|
||||
for (TSStackEntry *entry = stack.entries + stack.size - 1; \
|
||||
entry >= stack.entries; entry-- && index--)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue