Allow ubiquitous tokens to also be used in grammar rules
This commit is contained in:
parent
a9dff20658
commit
9686c57e90
22 changed files with 49452 additions and 47887 deletions
|
|
@ -11,6 +11,7 @@ extern "C" {
|
|||
typedef enum {
|
||||
ts_parse_action_type_error,
|
||||
ts_parse_action_type_shift,
|
||||
ts_parse_action_type_shift_extra,
|
||||
ts_parse_action_type_reduce,
|
||||
ts_parse_action_type_accept,
|
||||
} ts_parse_action_type;
|
||||
|
|
@ -29,6 +30,9 @@ typedef struct {
|
|||
#define SHIFT(to_state_value) \
|
||||
{ .type = ts_parse_action_type_shift, .data = { .to_state = to_state_value } }
|
||||
|
||||
#define SHIFT_EXTRA() \
|
||||
{ .type = ts_parse_action_type_shift_extra }
|
||||
|
||||
#define REDUCE(symbol_val, child_count_val) \
|
||||
{ .type = ts_parse_action_type_reduce, .data = { .symbol = symbol_val, .child_count = child_count_val } }
|
||||
|
||||
|
|
@ -43,7 +47,6 @@ typedef struct {
|
|||
struct {
|
||||
size_t symbol_count;
|
||||
const int *hidden_symbol_flags;
|
||||
const int *ubiquitous_symbol_flags;
|
||||
const ts_parse_action *parse_table;
|
||||
const ts_state_id *lex_states;
|
||||
ts_tree * (* lex_fn)(ts_lexer *, ts_state_id);
|
||||
|
|
@ -54,8 +57,7 @@ ts_lr_parser * ts_lr_parser_make(size_t symbol_count,
|
|||
const ts_parse_action *parse_table,
|
||||
const ts_state_id *lex_states,
|
||||
ts_tree * (* lex_fn)(ts_lexer *, ts_state_id),
|
||||
const int *hidden_symbol_flags,
|
||||
const int *ubiquitous_symbol_flags);
|
||||
const int *hidden_symbol_flags);
|
||||
void ts_lr_parser_free(void *data);
|
||||
void ts_lr_parser_initialize(ts_lr_parser *parser, ts_input input, ts_input_edit *edit);
|
||||
ts_tree * ts_lr_parser_parse(ts_lr_parser *parser, const char **symbol_names);
|
||||
|
|
@ -64,4 +66,4 @@ ts_tree * ts_lr_parser_parse(ts_lr_parser *parser, const char **symbol_names);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ typedef struct {
|
|||
struct {
|
||||
ts_tree *node;
|
||||
ts_state_id state;
|
||||
int is_extra;
|
||||
} *entries;
|
||||
} 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);
|
||||
ts_tree * ts_stack_reduce(ts_stack *stack, ts_symbol symbol, size_t immediate_child_count, const int *hidden_symbol_flags, int gather_extras);
|
||||
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);
|
||||
ts_state_id ts_stack_top_state(const ts_stack *stack);
|
||||
|
|
@ -30,4 +31,4 @@ size_t ts_stack_right_position(const ts_stack *stack);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue