Use new alias API
This commit is contained in:
parent
4340002e38
commit
ccc07eab4b
|
@ -299,7 +299,7 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
|
|
||||||
_variable_name: $ => choice(
|
_variable_name: $ => choice(
|
||||||
rename($.simple_variable_name, 'variable_name'),
|
alias($.simple_variable_name, $.variable_name),
|
||||||
$.special_variable_name
|
$.special_variable_name
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"nan": "^2.4.0"
|
"nan": "^2.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tree-sitter-cli": "^0.6.0"
|
"tree-sitter-cli": "^0.6.6-0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tree-sitter generate && node-gyp build",
|
"build": "tree-sitter generate && node-gyp build",
|
||||||
|
|
|
@ -1067,11 +1067,12 @@
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "RENAME",
|
"type": "ALIAS",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "simple_variable_name"
|
"name": "simple_variable_name"
|
||||||
},
|
},
|
||||||
|
"named": true,
|
||||||
"value": "variable_name"
|
"value": "variable_name"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,10 +11,10 @@ extern "C" {
|
||||||
|
|
||||||
typedef uint16_t TSSymbol;
|
typedef uint16_t TSSymbol;
|
||||||
typedef uint16_t TSStateId;
|
typedef uint16_t TSStateId;
|
||||||
typedef uint8_t TSExternalTokenState[16];
|
|
||||||
|
|
||||||
#define ts_builtin_sym_error ((TSSymbol)-1)
|
#define ts_builtin_sym_error ((TSSymbol)-1)
|
||||||
#define ts_builtin_sym_end 0
|
#define ts_builtin_sym_end 0
|
||||||
|
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool visible : 1;
|
bool visible : 1;
|
||||||
|
@ -40,17 +40,17 @@ typedef enum {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
TSStateId to_state;
|
TSStateId state;
|
||||||
bool extra : 1;
|
bool extra : 1;
|
||||||
};
|
};
|
||||||
struct {
|
struct {
|
||||||
TSSymbol symbol;
|
TSSymbol symbol;
|
||||||
int16_t dynamic_precedence;
|
int16_t dynamic_precedence;
|
||||||
uint8_t child_count;
|
uint8_t child_count;
|
||||||
uint8_t rename_sequence_id : 7;
|
uint8_t alias_sequence_id : 7;
|
||||||
bool fragile : 1;
|
bool fragile : 1;
|
||||||
};
|
};
|
||||||
};
|
} params;
|
||||||
TSParseActionType type : 4;
|
TSParseActionType type : 4;
|
||||||
} TSParseAction;
|
} TSParseAction;
|
||||||
|
|
||||||
|
@ -71,6 +71,7 @@ typedef union {
|
||||||
typedef struct TSLanguage {
|
typedef struct TSLanguage {
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
uint32_t symbol_count;
|
uint32_t symbol_count;
|
||||||
|
uint32_t alias_count;
|
||||||
uint32_t token_count;
|
uint32_t token_count;
|
||||||
uint32_t external_token_count;
|
uint32_t external_token_count;
|
||||||
const char **symbol_names;
|
const char **symbol_names;
|
||||||
|
@ -78,18 +79,17 @@ typedef struct TSLanguage {
|
||||||
const uint16_t *parse_table;
|
const uint16_t *parse_table;
|
||||||
const TSParseActionEntry *parse_actions;
|
const TSParseActionEntry *parse_actions;
|
||||||
const TSLexMode *lex_modes;
|
const TSLexMode *lex_modes;
|
||||||
const TSSymbol *rename_sequences;
|
const TSSymbol *alias_sequences;
|
||||||
uint16_t max_rename_sequence_length;
|
uint16_t max_alias_sequence_length;
|
||||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||||
struct {
|
struct {
|
||||||
const bool *states;
|
const bool *states;
|
||||||
const TSSymbol *symbol_map;
|
const TSSymbol *symbol_map;
|
||||||
void *(*create)();
|
void *(*create)();
|
||||||
void (*destroy)(void *);
|
void (*destroy)(void *);
|
||||||
void (*reset)(void *);
|
|
||||||
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
||||||
bool (*serialize)(void *, TSExternalTokenState);
|
unsigned (*serialize)(void *, char *);
|
||||||
void (*deserialize)(void *, const TSExternalTokenState);
|
void (*deserialize)(void *, const char *, unsigned);
|
||||||
} external_scanner;
|
} external_scanner;
|
||||||
} TSLanguage;
|
} TSLanguage;
|
||||||
|
|
||||||
|
@ -131,19 +131,19 @@ typedef struct TSLanguage {
|
||||||
#define STATE(id) id
|
#define STATE(id) id
|
||||||
#define ACTIONS(id) id
|
#define ACTIONS(id) id
|
||||||
|
|
||||||
#define SHIFT(to_state_value) \
|
#define SHIFT(state_value) \
|
||||||
{ \
|
{ \
|
||||||
{ \
|
{ \
|
||||||
.type = TSParseActionTypeShift, \
|
.type = TSParseActionTypeShift, \
|
||||||
.to_state = to_state_value, \
|
.params = {.state = state_value}, \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define RECOVER(to_state_value) \
|
#define RECOVER(state_value) \
|
||||||
{ \
|
{ \
|
||||||
{ \
|
{ \
|
||||||
.type = TSParseActionTypeRecover, \
|
.type = TSParseActionTypeRecover, \
|
||||||
.to_state = to_state_value \
|
.params = {.state = state_value} \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ typedef struct TSLanguage {
|
||||||
{ \
|
{ \
|
||||||
{ \
|
{ \
|
||||||
.type = TSParseActionTypeShift, \
|
.type = TSParseActionTypeShift, \
|
||||||
.extra = true \
|
.params = {.extra = true} \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,10 +159,12 @@ typedef struct TSLanguage {
|
||||||
{ \
|
{ \
|
||||||
{ \
|
{ \
|
||||||
.type = TSParseActionTypeReduce, \
|
.type = TSParseActionTypeReduce, \
|
||||||
|
.params = { \
|
||||||
.symbol = symbol_val, \
|
.symbol = symbol_val, \
|
||||||
.child_count = child_count_val, \
|
.child_count = child_count_val, \
|
||||||
__VA_ARGS__ \
|
__VA_ARGS__ \
|
||||||
} \
|
} \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ACCEPT_INPUT() \
|
#define ACCEPT_INPUT() \
|
||||||
|
@ -174,14 +176,15 @@ typedef struct TSLanguage {
|
||||||
static TSLanguage language = { \
|
static TSLanguage language = { \
|
||||||
.version = LANGUAGE_VERSION, \
|
.version = LANGUAGE_VERSION, \
|
||||||
.symbol_count = SYMBOL_COUNT, \
|
.symbol_count = SYMBOL_COUNT, \
|
||||||
|
.alias_count = ALIAS_COUNT, \
|
||||||
.token_count = TOKEN_COUNT, \
|
.token_count = TOKEN_COUNT, \
|
||||||
.symbol_metadata = ts_symbol_metadata, \
|
.symbol_metadata = ts_symbol_metadata, \
|
||||||
.parse_table = (const unsigned short *)ts_parse_table, \
|
.parse_table = (const unsigned short *)ts_parse_table, \
|
||||||
.parse_actions = ts_parse_actions, \
|
.parse_actions = ts_parse_actions, \
|
||||||
.lex_modes = ts_lex_modes, \
|
.lex_modes = ts_lex_modes, \
|
||||||
.symbol_names = ts_symbol_names, \
|
.symbol_names = ts_symbol_names, \
|
||||||
.rename_sequences = (const TSSymbol *)ts_rename_sequences, \
|
.alias_sequences = (const TSSymbol *)ts_alias_sequences, \
|
||||||
.max_rename_sequence_length = MAX_RENAME_SEQUENCE_LENGTH, \
|
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, \
|
||||||
.lex_fn = ts_lex, \
|
.lex_fn = ts_lex, \
|
||||||
.external_token_count = EXTERNAL_TOKEN_COUNT, \
|
.external_token_count = EXTERNAL_TOKEN_COUNT, \
|
||||||
.external_scanner = {__VA_ARGS__} \
|
.external_scanner = {__VA_ARGS__} \
|
||||||
|
|
Loading…
Reference in New Issue