Rename type ts_lexer, ts_parser -> TSLexer, TSParser
This commit is contained in:
parent
c8797bfa27
commit
9d4fcf75de
10 changed files with 30 additions and 30 deletions
|
|
@ -26,7 +26,7 @@ static TSStateId ts_lex_states[STATE_COUNT]
|
|||
static const ts_parse_action ts_parse_actions[STATE_COUNT][SYMBOL_COUNT]
|
||||
|
||||
#define LEX_FN() \
|
||||
static TSTree * ts_lex(ts_lexer *lexer, TSStateId lex_state)
|
||||
static TSTree * ts_lex(TSLexer *lexer, TSStateId lex_state)
|
||||
|
||||
#ifdef TS_DEBUG_LEX
|
||||
#include <stdio.h>
|
||||
|
|
@ -82,8 +82,8 @@ static const TSTree * ts_parse(void *data, TSInput input, TSInputEdit *edit) {
|
|||
}
|
||||
|
||||
#define EXPORT_PARSER(constructor_name) \
|
||||
ts_parser constructor_name() { \
|
||||
return (ts_parser) { \
|
||||
TSParser constructor_name() { \
|
||||
return (TSParser) { \
|
||||
.parse_fn = ts_parse, \
|
||||
.free_fn = ts_lr_parser_free, \
|
||||
.symbol_names = ts_symbol_names, \
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ typedef struct {
|
|||
size_t token_end_position;
|
||||
size_t token_start_position;
|
||||
int reached_end;
|
||||
} ts_lexer;
|
||||
} TSLexer;
|
||||
|
||||
static inline ts_lexer ts_lexer_make() {
|
||||
ts_lexer result;
|
||||
static inline TSLexer ts_lexer_make() {
|
||||
TSLexer result;
|
||||
result.chunk = NULL;
|
||||
result.chunk_start = 0;
|
||||
result.chunk_size = 0;
|
||||
|
|
@ -28,15 +28,15 @@ static inline ts_lexer ts_lexer_make() {
|
|||
return result;
|
||||
}
|
||||
|
||||
static inline size_t ts_lexer_position(const ts_lexer *lexer) {
|
||||
static inline size_t ts_lexer_position(const TSLexer *lexer) {
|
||||
return lexer->chunk_start + lexer->position_in_chunk;
|
||||
}
|
||||
|
||||
static inline char ts_lexer_lookahead_char(const ts_lexer *lexer) {
|
||||
static inline char ts_lexer_lookahead_char(const TSLexer *lexer) {
|
||||
return lexer->chunk[lexer->position_in_chunk];
|
||||
}
|
||||
|
||||
static inline int ts_lexer_advance(ts_lexer *lexer) {
|
||||
static inline int ts_lexer_advance(TSLexer *lexer) {
|
||||
static const char *empty_chunk = "";
|
||||
if (lexer->position_in_chunk + 1 < lexer->chunk_size) {
|
||||
lexer->position_in_chunk++;
|
||||
|
|
@ -55,11 +55,11 @@ static inline int ts_lexer_advance(ts_lexer *lexer) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static inline void ts_lexer_start_token(ts_lexer *lexer) {
|
||||
static inline void ts_lexer_start_token(TSLexer *lexer) {
|
||||
lexer->token_start_position = ts_lexer_position(lexer);
|
||||
}
|
||||
|
||||
static inline TSTree * ts_lexer_build_node(ts_lexer *lexer, TSSymbol symbol) {
|
||||
static inline TSTree * ts_lexer_build_node(TSLexer *lexer, TSSymbol symbol) {
|
||||
size_t current_position = ts_lexer_position(lexer);
|
||||
size_t size = current_position - lexer->token_start_position;
|
||||
size_t offset = lexer->token_start_position - lexer->token_end_position;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ typedef struct {
|
|||
{ .type = ts_parse_action_type_accept }
|
||||
|
||||
typedef struct {
|
||||
ts_lexer lexer;
|
||||
TSLexer lexer;
|
||||
ts_stack stack;
|
||||
TSTree *lookahead;
|
||||
TSTree *next_lookahead;
|
||||
|
|
@ -49,14 +49,14 @@ typedef struct {
|
|||
const int *hidden_symbol_flags;
|
||||
const ts_parse_action *parse_table;
|
||||
const TSStateId *lex_states;
|
||||
TSTree * (* lex_fn)(ts_lexer *, TSStateId);
|
||||
TSTree * (* lex_fn)(TSLexer *, TSStateId);
|
||||
} config;
|
||||
} ts_lr_parser;
|
||||
|
||||
ts_lr_parser * ts_lr_parser_make(size_t symbol_count,
|
||||
const ts_parse_action *parse_table,
|
||||
const TSStateId *lex_states,
|
||||
TSTree * (* lex_fn)(ts_lexer *, TSStateId),
|
||||
TSTree * (* lex_fn)(TSLexer *, TSStateId),
|
||||
const int *hidden_symbol_flags);
|
||||
void ts_lr_parser_free(void *data);
|
||||
void ts_lr_parser_initialize(ts_lr_parser *parser, TSInput input, TSInputEdit *edit);
|
||||
|
|
|
|||
|
|
@ -46,15 +46,15 @@ typedef struct {
|
|||
void (* free_fn)(void *data);
|
||||
const char **symbol_names;
|
||||
void *data;
|
||||
} ts_parser;
|
||||
} TSParser;
|
||||
|
||||
const TSTree * ts_parser_parse(ts_parser *, TSInput, TSInputEdit *edit);
|
||||
void ts_parser_free(ts_parser *);
|
||||
const TSTree * ts_parser_parse(TSParser *, TSInput, TSInputEdit *edit);
|
||||
void ts_parser_free(TSParser *);
|
||||
|
||||
typedef struct TSDocument TSDocument;
|
||||
TSDocument * ts_document_make();
|
||||
void ts_document_free(TSDocument *doc);
|
||||
void ts_document_set_parser(TSDocument *doc, ts_parser parser);
|
||||
void ts_document_set_parser(TSDocument *doc, TSParser parser);
|
||||
void ts_document_set_input(TSDocument *doc, TSInput input);
|
||||
void ts_document_set_input_string(TSDocument *doc, const char *text);
|
||||
void ts_document_edit(TSDocument *doc, TSInputEdit edit);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue