- move message generation to TSParseError, so that Parser doesn’t need to import <string>, and can be compiled as plain C.
41 lines
800 B
C
41 lines
800 B
C
#ifndef __tree_sitter_parse_config_h__
|
|
#define __tree_sitter_parse_config_h__
|
|
|
|
#include "tree.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef enum {
|
|
TSParseErrorTypeNone,
|
|
TSParseErrorTypeLexical,
|
|
TSParseErrorTypeSyntactic,
|
|
} TSParseErrorType;
|
|
|
|
typedef struct {
|
|
TSParseErrorType type;
|
|
const char **expected_inputs;
|
|
size_t expected_input_count;
|
|
size_t position;
|
|
long lookahead_sym;
|
|
} TSParseError;
|
|
|
|
const char * TSParseErrorToString(const TSParseError *error, const char *input_string, const char **symbol_names);
|
|
|
|
typedef struct {
|
|
TSParseError error;
|
|
TSTree *tree;
|
|
} TSParseResult;
|
|
|
|
typedef TSParseResult TSParseFn(const char *);
|
|
|
|
typedef struct {
|
|
TSParseFn *parse_fn;
|
|
const char **symbol_names;
|
|
} TSParseConfig;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|