Sfoglia il codice sorgente

Remove accidentally commited header files

pull/2/head
Max Brunsfeld 10 anni fa
parent
commit
2ff3723bdd
3 ha cambiato i file con 0 aggiunte e 329 eliminazioni
  1. +0
    -67
      include/tree_sitter/compiler.h
  2. +0
    -175
      include/tree_sitter/parser.h
  3. +0
    -87
      include/tree_sitter/runtime.h

+ 0
- 67
include/tree_sitter/compiler.h Vedi File

@ -1,67 +0,0 @@
#ifndef TREE_SITTER_COMPILER_H_
#define TREE_SITTER_COMPILER_H_
#include <memory>
#include <string>
#include <utility>
#include <vector>
namespace tree_sitter {
class Rule;
typedef std::shared_ptr<Rule> rule_ptr;
enum Associativity {
AssociativityNone,
AssociativityLeft,
AssociativityRight,
};
rule_ptr blank();
rule_ptr choice(const std::vector<rule_ptr> &);
rule_ptr repeat(const rule_ptr &);
rule_ptr seq(const std::vector<rule_ptr> &);
rule_ptr sym(const std::string &);
rule_ptr pattern(const std::string &);
rule_ptr str(const std::string &);
rule_ptr err(const rule_ptr &);
rule_ptr prec(int precedence, const rule_ptr &);
rule_ptr prec(int precedence, const rule_ptr &, Associativity);
rule_ptr token(const rule_ptr &rule);
class Grammar {
const std::vector<std::pair<std::string, rule_ptr>> rules_;
std::vector<rule_ptr> ubiquitous_tokens_;
std::vector<std::vector<std::string>> expected_conflicts_;
public:
explicit Grammar(const std::vector<std::pair<std::string, rule_ptr>> &);
Grammar &ubiquitous_tokens(const std::vector<rule_ptr> &);
Grammar &expected_conflicts(const std::vector<std::vector<std::string>> &);
const std::vector<std::pair<std::string, rule_ptr>> &rules() const;
const std::vector<rule_ptr> &ubiquitous_tokens() const;
const std::vector<std::vector<std::string>> &expected_conflicts() const;
};
enum GrammarErrorType {
GrammarErrorTypeRegex,
GrammarErrorTypeUndefinedSymbol,
GrammarErrorTypeInvalidUbiquitousToken,
GrammarErrorTypeLexConflict,
GrammarErrorTypeParseConflict,
};
class GrammarError {
public:
GrammarError(GrammarErrorType type, std::string message);
bool operator==(const GrammarError &other) const;
GrammarErrorType type;
std::string message;
};
std::pair<std::string, const GrammarError *> compile(const Grammar &,
std::string);
} // namespace tree_sitter
#endif // TREE_SITTER_COMPILER_H_

+ 0
- 175
include/tree_sitter/parser.h Vedi File

@ -1,175 +0,0 @@
#ifndef TREE_SITTER_PARSER_H_
#define TREE_SITTER_PARSER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include "tree_sitter/runtime.h"
#define ts_lex_state_error 0
#define TS_DEBUG_BUFFER_SIZE 512
typedef struct TSTree TSTree;
typedef unsigned short TSStateId;
typedef enum {
TSNodeTypeHidden,
TSNodeTypeAnonymous,
TSNodeTypeNamed,
} TSNodeType;
typedef struct TSLexer {
// Public
void (*start_fn)(struct TSLexer *, TSStateId);
void (*start_token_fn)(struct TSLexer *);
bool (*advance_fn)(struct TSLexer *, TSStateId);
TSTree *(*accept_fn)(struct TSLexer *, TSSymbol, TSNodeType, const char *);
// Private
const char *chunk;
size_t chunk_start;
size_t chunk_size;
TSLength current_position;
TSLength token_end_position;
TSLength token_start_position;
size_t lookahead_size;
int32_t lookahead;
TSInput input;
TSDebugger debugger;
char debug_buffer[TS_DEBUG_BUFFER_SIZE];
} TSLexer;
typedef enum {
TSParseActionTypeError = 1,
TSParseActionTypeShift,
TSParseActionTypeShiftExtra,
TSParseActionTypeReduce,
TSParseActionTypeReduceExtra,
TSParseActionTypeReduceFragile,
TSParseActionTypeAccept,
} TSParseActionType;
typedef struct {
TSParseActionType type;
union {
TSStateId to_state;
struct {
TSSymbol symbol;
unsigned short child_count;
};
} data;
} TSParseAction;
struct TSLanguage {
size_t symbol_count;
const char **symbol_names;
const TSNodeType *node_types;
const TSParseAction **parse_table;
const TSStateId *lex_states;
TSTree *(*lex_fn)(TSLexer *, TSStateId);
};
/*
* Lexer Macros
*/
#define START_LEXER() \
const bool error_mode = (lex_state == ts_lex_state_error); \
lexer->start_fn(lexer, lex_state); \
int32_t lookahead; \
next_state: \
lookahead = lexer->lookahead;
#define START_TOKEN() lexer->start_token_fn(lexer);
#define GO_TO_STATE(state_index) \
{ \
lex_state = state_index; \
goto next_state; \
}
#define ADVANCE(state_index) \
{ \
lexer->advance_fn(lexer, state_index); \
GO_TO_STATE(state_index); \
}
#define ACCEPT_TOKEN(symbol) \
return lexer->accept_fn(lexer, symbol, ts_node_types[symbol], \
ts_symbol_names[symbol]);
#define LEX_ERROR() \
if (error_mode) { \
if (lex_state == ts_lex_state_error) \
ADVANCE(ts_lex_state_error) \
else \
GO_TO_STATE(ts_lex_state_error) \
} else { \
ACCEPT_TOKEN(ts_builtin_sym_error) \
}
/*
* Parse Table Macros
*/
#define ACTIONS(...) \
(TSParseAction[]) { \
__VA_ARGS__, { \
.type = 0 \
} \
}
#define SHIFT(to_state_value) \
{ \
.type = TSParseActionTypeShift, .data = {.to_state = to_state_value } \
}
#define SHIFT_EXTRA() \
{ .type = TSParseActionTypeShiftExtra }
#define REDUCE_EXTRA(symbol_val) \
{ \
.type = TSParseActionTypeReduceExtra, .data = {.symbol = symbol_val } \
}
#define REDUCE(symbol_val, child_count_val) \
{ \
.type = TSParseActionTypeReduce, \
.data = {.symbol = symbol_val, .child_count = child_count_val } \
}
#define REDUCE_FRAGILE(symbol_val, child_count_val) \
{ \
.type = TSParseActionTypeReduceFragile, \
.data = {.symbol = symbol_val, .child_count = child_count_val } \
}
#define ACCEPT_INPUT() \
{ .type = TSParseActionTypeAccept }
#define EXPORT_LANGUAGE(language_name) \
static TSLanguage language = { \
.symbol_count = SYMBOL_COUNT, \
.node_types = ts_node_types, \
.parse_table = (const TSParseAction **)ts_parse_actions, \
.lex_states = ts_lex_states, \
.symbol_names = ts_symbol_names, \
.lex_fn = ts_lex, \
}; \
\
const TSLanguage *language_name() { \
return &language; \
}
#ifdef __cplusplus
}
#endif
#endif // TREE_SITTER_PARSER_H_

+ 0
- 87
include/tree_sitter/runtime.h Vedi File

@ -1,87 +0,0 @@
#ifndef TREE_SITTER_RUNTIME_H_
#define TREE_SITTER_RUNTIME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdbool.h>
typedef struct {
size_t bytes;
size_t chars;
} TSLength;
typedef struct {
void *payload;
const char *(*read_fn)(void *payload, size_t *bytes_read);
int (*seek_fn)(void *payload, TSLength position);
} TSInput;
typedef enum {
TSDebugTypeParse,
TSDebugTypeLex,
} TSDebugType;
typedef struct {
void *payload;
void (*debug_fn)(void *payload, TSDebugType, const char *);
} TSDebugger;
typedef struct {
size_t position;
size_t chars_inserted;
size_t chars_removed;
} TSInputEdit;
typedef struct {
const void *data;
TSLength offset;
} TSNode;
typedef unsigned short TSSymbol;
typedef struct TSLanguage TSLanguage;
typedef struct TSDocument TSDocument;
TSLength ts_node_pos(TSNode);
TSLength ts_node_size(TSNode);
TSSymbol ts_node_symbol(TSNode);
const char *ts_node_name(TSNode, const TSDocument *);
const char *ts_node_string(TSNode, const TSDocument *);
bool ts_node_eq(TSNode, TSNode);
bool ts_node_is_named(TSNode);
TSNode ts_node_parent(TSNode);
TSNode ts_node_child(TSNode, size_t);
TSNode ts_node_named_child(TSNode, size_t);
size_t ts_node_child_count(TSNode);
size_t ts_node_named_child_count(TSNode);
TSNode ts_node_next_sibling(TSNode);
TSNode ts_node_next_named_sibling(TSNode);
TSNode ts_node_prev_sibling(TSNode);
TSNode ts_node_prev_named_sibling(TSNode);
TSNode ts_node_descendent_for_range(TSNode, size_t, size_t);
TSNode ts_node_named_descendent_for_range(TSNode, size_t, size_t);
TSDocument *ts_document_make();
void ts_document_free(TSDocument *);
const TSLanguage * ts_document_language(TSDocument *);
void ts_document_set_language(TSDocument *, const TSLanguage *);
TSInput ts_document_input(TSDocument *);
void ts_document_set_input(TSDocument *, TSInput);
void ts_document_set_input_string(TSDocument *, const char *);
void ts_document_edit(TSDocument *, TSInputEdit);
TSDebugger ts_document_debugger(const TSDocument *);
void ts_document_set_debugger(TSDocument *, TSDebugger);
TSNode ts_document_root_node(const TSDocument *);
size_t ts_document_parse_count(const TSDocument *);
#define ts_builtin_sym_error 0
#define ts_builtin_sym_end 1
#define ts_builtin_sym_start 2
#ifdef __cplusplus
}
#endif
#endif // TREE_SITTER_RUNTIME_H_

Caricamento…
Annulla
Salva