Rename type ts_lr_parser -> TSStateMachine

This commit is contained in:
Max Brunsfeld 2014-06-28 19:22:16 -07:00
parent 27f6eb725d
commit 0ec3faba3e
5 changed files with 96 additions and 95 deletions

View file

@ -0,0 +1,70 @@
#ifndef TREE_SITTER_PARSER_LR_PARSER_H_
#define TREE_SITTER_PARSER_LR_PARSER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "tree_sitter/parser/stack.h"
#include "tree_sitter/parser/lexer.h"
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,
} TSParseActionType;
typedef struct {
TSParseActionType type;
union {
TSStateId to_state;
struct {
TSSymbol symbol;
unsigned short child_count;
};
} data;
} TSParseAction;
#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 } }
#define ACCEPT_INPUT() \
{ .type = ts_parse_action_type_accept }
typedef struct {
TSLexer lexer;
TSStack stack;
TSTree *lookahead;
TSTree *next_lookahead;
struct {
size_t symbol_count;
const int *hidden_symbol_flags;
const TSParseAction *parse_table;
const TSStateId *lex_states;
TSTree * (* lex_fn)(TSLexer *, TSStateId);
} config;
} TSStateMachine;
TSStateMachine * ts_state_machine_make(
size_t symbol_count,
const TSParseAction *parse_table,
const TSStateId *lex_states,
TSTree * (* lex_fn)(TSLexer *, TSStateId),
const int *hidden_symbol_flags);
void ts_state_machine_free(void *data);
void ts_state_machine_initialize(TSStateMachine *, TSInput, TSInputEdit *);
TSTree * ts_state_machine_parse(TSStateMachine *, const char **symbol_names);
#ifdef __cplusplus
}
#endif
#endif