2014-07-30 23:40:02 -07:00
|
|
|
#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"
|
2016-10-05 14:02:49 -07:00
|
|
|
#include "runtime/lexer.h"
|
2017-01-05 10:06:43 -08:00
|
|
|
#include "runtime/reusable_node.h"
|
2016-05-09 14:31:44 -07:00
|
|
|
#include "runtime/reduce_action.h"
|
2016-02-17 14:45:00 -08:00
|
|
|
|
2017-08-30 17:35:12 -07:00
|
|
|
typedef struct {
|
|
|
|
|
Tree *token;
|
|
|
|
|
Tree *last_external_token;
|
|
|
|
|
uint32_t byte_index;
|
|
|
|
|
} TokenCache;
|
|
|
|
|
|
2014-07-30 23:40:02 -07:00
|
|
|
typedef struct {
|
2016-10-05 14:02:49 -07:00
|
|
|
Lexer lexer;
|
2015-09-18 18:04:52 -07:00
|
|
|
Stack *stack;
|
2014-07-30 23:40:02 -07:00
|
|
|
const TSLanguage *language;
|
2016-05-09 14:31:44 -07:00
|
|
|
ReduceActionSet reduce_actions;
|
2016-11-09 20:59:05 -08:00
|
|
|
Tree *finished_tree;
|
|
|
|
|
Tree scratch_tree;
|
2017-08-30 17:35:12 -07:00
|
|
|
TokenCache token_cache;
|
2016-07-01 15:08:19 -07:00
|
|
|
ReusableNode reusable_node;
|
2016-09-22 18:02:11 -07:00
|
|
|
TreePath tree_path1;
|
|
|
|
|
TreePath tree_path2;
|
2016-12-02 22:03:48 -08:00
|
|
|
void *external_scanner_payload;
|
2017-08-31 12:50:10 -07:00
|
|
|
bool in_ambiguity;
|
|
|
|
|
bool print_debugging_graphs;
|
2016-08-29 12:08:58 -07:00
|
|
|
} Parser;
|
2014-07-30 23:40:02 -07:00
|
|
|
|
2016-08-29 12:08:58 -07:00
|
|
|
bool parser_init(Parser *);
|
|
|
|
|
void parser_destroy(Parser *);
|
2017-05-01 13:04:06 -07:00
|
|
|
Tree *parser_parse(Parser *, TSInput, Tree *, bool halt_on_error);
|
2016-12-02 22:03:48 -08:00
|
|
|
void parser_set_language(Parser *, const TSLanguage *);
|
2014-07-30 23:40:02 -07:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif // RUNTIME_PARSER_H_
|