Reorganize runtime header files

This commit is contained in:
Max Brunsfeld 2014-02-15 17:00:33 -08:00
parent fb1ef60f7d
commit dbbb446082
12 changed files with 77 additions and 103 deletions

View file

@ -1,21 +0,0 @@
#ifndef __tree_sitter_document_h__
#define __tree_sitter_document_h__
#ifdef __cplusplus
extern "C" {
#endif
#include "./tree.h"
#include "./parse_config.h"
typedef struct TSDocument TSDocument;
TSDocument * TSDocumentMake();
void TSDocumentSetUp(TSDocument *document, TSParseConfig config);
void TSDocumentSetText(TSDocument *document, const char *text);
TSTree * TSDocumentTree(const TSDocument *document);
const char * TSDocumentToString(const TSDocument *document);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,33 +0,0 @@
#ifndef __tree_sitter_parse_config_h__
#define __tree_sitter_parse_config_h__
#ifdef __cplusplus
extern "C" {
#endif
#include "tree.h"
typedef struct {
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

View file

@ -1,11 +1,11 @@
#ifndef __tree_sitter_parser_h__
#define __tree_sitter_parser_h__
#ifndef tree_sitter_parser_h
#define tree_sitter_parser_h
#ifdef __cplusplus
extern "C" {
#endif
#include "tree.h"
#include "parse_config.h"
#include "runtime.h"
#include <stdio.h>
#include <string.h>
@ -23,7 +23,7 @@ extern "C" {
#else
#define DEBUG_PARSE(...)
#endif
static int INITIAL_STACK_SIZE = 100;
static const char *ts_symbol_names[];
@ -220,4 +220,5 @@ done:
#ifdef __cplusplus
}
#endif
#endif

59
include/runtime.h Normal file
View file

@ -0,0 +1,59 @@
#ifndef tree_sitter_runtime_h
#define tree_sitter_runtime_h
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
typedef struct {
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 size_t TSSymbol;
typedef struct TSTree {
TSSymbol value;
struct TSTree **children;
size_t child_count;
size_t ref_count;
} TSTree;
TSTree * TSTreeMake(TSSymbol value, size_t child_count, TSTree **children);
void TSTreeRetain(TSTree *tree);
void TSTreeRelease(TSTree *tree);
int TSTreeEquals(const TSTree *tree1, const TSTree *tree2);
char * TSTreeToString(const TSTree *tree, const char **names);
typedef struct {
TSParseError error;
TSTree *tree;
} TSParseResult;
typedef TSParseResult TSParseFn(const char *);
typedef struct {
TSParseFn *parse_fn;
const char **symbol_names;
} TSParseConfig;
typedef struct TSDocument TSDocument;
TSDocument * TSDocumentMake();
void TSDocumentSetUp(TSDocument *document, TSParseConfig config);
void TSDocumentSetText(TSDocument *document, const char *text);
TSTree * TSDocumentTree(const TSDocument *document);
const char * TSDocumentToString(const TSDocument *document);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -1,28 +0,0 @@
#ifndef __tree_sitter_tree_h__
#define __tree_sitter_tree_h__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
typedef size_t TSSymbol;
typedef struct TSTree {
TSSymbol value;
struct TSTree **children;
size_t child_count;
size_t ref_count;
} TSTree;
TSTree * TSTreeMake(TSSymbol value, size_t child_count, TSTree **children);
void TSTreeRetain(TSTree *tree);
void TSTreeRelease(TSTree *tree);
int TSTreeEquals(const TSTree *tree1, const TSTree *tree2);
char * TSTreeToString(const TSTree *tree, const char **names);
#ifdef __cplusplus
}
#endif
#endif