Remove generated parsers' dependency on the runtime library
Generated parsers no longer export a parser constructor function. They now export an opaque Language object which can be set on Documents directly. This way, the logic for constructing parsers lives entirely in the runtime. The Languages are just structs which have no load-time dependency on the runtime
This commit is contained in:
parent
048a479b5f
commit
eecbcccee0
21 changed files with 219 additions and 173 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#include "runtime/helpers/dummy_parser.h"
|
||||
#include "runtime/helpers/dummy_language.h"
|
||||
#include "tree_sitter/parser.h"
|
||||
|
||||
const TSParseAction parse_table[3][5] = {
|
||||
|
|
@ -30,9 +30,11 @@ const int hidden_symbols[5] = {
|
|||
[dummy_sym3] = 1,
|
||||
};
|
||||
|
||||
TSParserConfig dummy_parser = {
|
||||
static TSLanguage language = {
|
||||
.symbol_count = 5,
|
||||
.parse_table = (const TSParseAction *)parse_table,
|
||||
.lex_states = lex_states,
|
||||
.hidden_symbol_flags = hidden_symbols,
|
||||
};
|
||||
|
||||
TSLanguage *dummy_language = &language;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef HELPERS_DUMMY_PARSER_H_
|
||||
#define HELPERS_DUMMY_PARSER_H_
|
||||
#ifndef HELPERS_DUMMY_LANGUAGE_H_
|
||||
#define HELPERS_DUMMY_LANGUAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -14,10 +14,10 @@ enum {
|
|||
dummy_sym3 = 4,
|
||||
};
|
||||
|
||||
extern TSParserConfig dummy_parser;
|
||||
extern TSLanguage *dummy_language;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HELPERS_DUMMY_PARSER_H_
|
||||
#endif // HELPERS_DUMMY_LANGUAGE_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue