tree-sitter/src/runtime/parser.h

46 lines
914 B
C
Raw Normal View History

#ifndef RUNTIME_PARSER_H_
#define RUNTIME_PARSER_H_
#ifdef __cplusplus
extern "C" {
#endif
2015-09-18 18:04:52 -07:00
#include "runtime/stack.h"
2016-02-17 20:41:29 -08:00
#include "runtime/array.h"
#include "runtime/lexer.h"
#include "runtime/reduce_action.h"
2016-02-17 14:45:00 -08:00
typedef struct {
Tree *tree;
uint32_t byte_index;
} ReusableNode;
typedef struct {
Lexer lexer;
2015-09-18 18:04:52 -07:00
Stack *stack;
const TSLanguage *language;
ReduceActionSet reduce_actions;
Tree *finished_tree;
bool is_split;
bool print_debugging_graphs;
Tree scratch_tree;
Tree *cached_token;
uint32_t cached_token_byte_index;
ReusableNode reusable_node;
TreePath tree_path1;
TreePath tree_path2;
void *external_scanner_payload;
Tree *last_external_token;
2016-08-29 12:08:58 -07:00
} Parser;
2016-08-29 12:08:58 -07:00
bool parser_init(Parser *);
void parser_destroy(Parser *);
Tree *parser_parse(Parser *, TSInput, Tree *);
void parser_set_language(Parser *, const TSLanguage *);
#ifdef __cplusplus
}
#endif
#endif // RUNTIME_PARSER_H_