parent
7c39062216
commit
a03f1d2d1d
|
@ -244,3 +244,26 @@ a-property: calc(5px + var(--a-variable));
|
|||
(stylesheet
|
||||
(declaration (property_name) (integer_value (unit)))
|
||||
(declaration (property_name) (call_expression (function_name) (arguments (binary_expression (integer_value (unit)) (call_expression (function_name) (arguments (plain_value))))))))
|
||||
|
||||
=============================================
|
||||
Spaces after colons in property declarations
|
||||
=============================================
|
||||
|
||||
div {
|
||||
margin : 0;
|
||||
padding : 0;
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
(stylesheet
|
||||
(rule_set
|
||||
(selectors
|
||||
(tag_name))
|
||||
(block
|
||||
(declaration
|
||||
(property_name)
|
||||
(integer_value))
|
||||
(declaration
|
||||
(property_name)
|
||||
(integer_value)))))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tree-sitter-css",
|
||||
"version": "0.19.0",
|
||||
"version": "0.20.0",
|
||||
"description": "CSS grammar for tree-sitter",
|
||||
"main": "bindings/node",
|
||||
"keywords": [
|
||||
|
@ -17,7 +17,7 @@
|
|||
"nan": "^2.14.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tree-sitter-cli": "^0.19.1"
|
||||
"tree-sitter-cli": "^0.20.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tree-sitter test && tree-sitter parse examples/*.css --quiet --time",
|
||||
|
|
|
@ -129,7 +129,7 @@ enum {
|
|||
alias_sym_tag_name = 110,
|
||||
};
|
||||
|
||||
static const char *ts_symbol_names[] = {
|
||||
static const char * const ts_symbol_names[] = {
|
||||
[ts_builtin_sym_end] = "end",
|
||||
[anon_sym_ATimport] = "@import",
|
||||
[anon_sym_COMMA] = ",",
|
||||
|
@ -243,7 +243,7 @@ static const char *ts_symbol_names[] = {
|
|||
[alias_sym_tag_name] = "tag_name",
|
||||
};
|
||||
|
||||
static TSSymbol ts_symbol_map[] = {
|
||||
static const TSSymbol ts_symbol_map[] = {
|
||||
[ts_builtin_sym_end] = ts_builtin_sym_end,
|
||||
[anon_sym_ATimport] = anon_sym_ATimport,
|
||||
[anon_sym_COMMA] = anon_sym_COMMA,
|
||||
|
@ -804,7 +804,7 @@ static const TSSymbolMetadata ts_symbol_metadata[] = {
|
|||
},
|
||||
};
|
||||
|
||||
static TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
|
||||
static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = {
|
||||
[0] = {0},
|
||||
[1] = {
|
||||
[0] = alias_sym_tag_name,
|
||||
|
@ -850,7 +850,7 @@ static TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGT
|
|||
},
|
||||
};
|
||||
|
||||
static uint16_t ts_non_terminal_alias_map[] = {
|
||||
static const uint16_t ts_non_terminal_alias_map[] = {
|
||||
0,
|
||||
};
|
||||
|
||||
|
@ -2897,7 +2897,7 @@ static bool ts_lex(TSLexer *lexer, TSStateId state) {
|
|||
}
|
||||
}
|
||||
|
||||
static TSLexMode ts_lex_modes[STATE_COUNT] = {
|
||||
static const TSLexMode ts_lex_modes[STATE_COUNT] = {
|
||||
[0] = {.lex_state = 0, .external_lex_state = 1},
|
||||
[1] = {.lex_state = 72},
|
||||
[2] = {.lex_state = 72},
|
||||
|
@ -3182,17 +3182,17 @@ enum {
|
|||
ts_external_token__descendant_operator = 0,
|
||||
};
|
||||
|
||||
static TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
|
||||
static const TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = {
|
||||
[ts_external_token__descendant_operator] = sym__descendant_operator,
|
||||
};
|
||||
|
||||
static bool ts_external_scanner_states[2][EXTERNAL_TOKEN_COUNT] = {
|
||||
static const bool ts_external_scanner_states[2][EXTERNAL_TOKEN_COUNT] = {
|
||||
[1] = {
|
||||
[ts_external_token__descendant_operator] = true,
|
||||
},
|
||||
};
|
||||
|
||||
static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
||||
static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
||||
[0] = {
|
||||
[ts_builtin_sym_end] = ACTIONS(1),
|
||||
[anon_sym_ATimport] = ACTIONS(1),
|
||||
|
@ -3290,7 +3290,7 @@ static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = {
|
|||
},
|
||||
};
|
||||
|
||||
static uint16_t ts_small_parse_table[] = {
|
||||
static const uint16_t ts_small_parse_table[] = {
|
||||
[0] = 21,
|
||||
ACTIONS(3), 1,
|
||||
sym_comment,
|
||||
|
@ -8597,7 +8597,7 @@ static uint16_t ts_small_parse_table[] = {
|
|||
anon_sym_LPAREN2,
|
||||
};
|
||||
|
||||
static uint32_t ts_small_parse_table_map[] = {
|
||||
static const uint32_t ts_small_parse_table_map[] = {
|
||||
[SMALL_STATE(2)] = 0,
|
||||
[SMALL_STATE(3)] = 85,
|
||||
[SMALL_STATE(4)] = 170,
|
||||
|
@ -8876,7 +8876,7 @@ static uint32_t ts_small_parse_table_map[] = {
|
|||
[SMALL_STATE(277)] = 6792,
|
||||
};
|
||||
|
||||
static TSParseActionEntry ts_parse_actions[] = {
|
||||
static const TSParseActionEntry ts_parse_actions[] = {
|
||||
[0] = {.entry = {.count = 0, .reusable = false}},
|
||||
[1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(),
|
||||
[3] = {.entry = {.count = 1, .reusable = true}}, SHIFT_EXTRA(),
|
||||
|
@ -9321,7 +9321,7 @@ void tree_sitter_css_external_scanner_deserialize(void *, const char *, unsigned
|
|||
#endif
|
||||
|
||||
extern const TSLanguage *tree_sitter_css(void) {
|
||||
static TSLanguage language = {
|
||||
static const TSLanguage language = {
|
||||
.version = LANGUAGE_VERSION,
|
||||
.symbol_count = SYMBOL_COUNT,
|
||||
.alias_count = ALIAS_COUNT,
|
||||
|
@ -9332,19 +9332,19 @@ extern const TSLanguage *tree_sitter_css(void) {
|
|||
.production_id_count = PRODUCTION_ID_COUNT,
|
||||
.field_count = FIELD_COUNT,
|
||||
.max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH,
|
||||
.parse_table = (const uint16_t *)ts_parse_table,
|
||||
.small_parse_table = (const uint16_t *)ts_small_parse_table,
|
||||
.small_parse_table_map = (const uint32_t *)ts_small_parse_table_map,
|
||||
.parse_table = &ts_parse_table[0][0],
|
||||
.small_parse_table = ts_small_parse_table,
|
||||
.small_parse_table_map = ts_small_parse_table_map,
|
||||
.parse_actions = ts_parse_actions,
|
||||
.symbol_names = ts_symbol_names,
|
||||
.symbol_metadata = ts_symbol_metadata,
|
||||
.public_symbol_map = ts_symbol_map,
|
||||
.alias_map = ts_non_terminal_alias_map,
|
||||
.alias_sequences = (const TSSymbol *)ts_alias_sequences,
|
||||
.alias_sequences = &ts_alias_sequences[0][0],
|
||||
.lex_modes = ts_lex_modes,
|
||||
.lex_fn = ts_lex,
|
||||
.external_scanner = {
|
||||
(const bool *)ts_external_scanner_states,
|
||||
&ts_external_scanner_states[0][0],
|
||||
ts_external_scanner_symbol_map,
|
||||
tree_sitter_css_external_scanner_create,
|
||||
tree_sitter_css_external_scanner_destroy,
|
||||
|
|
|
@ -12,24 +12,40 @@ unsigned tree_sitter_css_external_scanner_serialize(void *p, char *buffer) { ret
|
|||
void tree_sitter_css_external_scanner_deserialize(void *p, const char *b, unsigned n) {}
|
||||
|
||||
bool tree_sitter_css_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
|
||||
if (iswspace(lexer->lookahead)) {
|
||||
lexer->advance(lexer, true);
|
||||
if (iswspace(lexer->lookahead) && valid_symbols[DESCENDANT_OP]) {
|
||||
lexer->result_symbol = DESCENDANT_OP;
|
||||
|
||||
lexer->advance(lexer, true);
|
||||
while (iswspace(lexer->lookahead)) {
|
||||
lexer->advance(lexer, true);
|
||||
}
|
||||
lexer->mark_end(lexer);
|
||||
|
||||
if (
|
||||
lexer->lookahead == '#' ||
|
||||
lexer->lookahead == '.' ||
|
||||
lexer->lookahead == '[' ||
|
||||
lexer->lookahead == ':' ||
|
||||
lexer->lookahead == '-' ||
|
||||
iswalnum(lexer->lookahead)
|
||||
) {
|
||||
lexer->result_symbol = DESCENDANT_OP;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (lexer->lookahead == ':') {
|
||||
lexer->advance(lexer, false);
|
||||
if (iswspace(lexer->lookahead)) return false;
|
||||
for (;;) {
|
||||
if (
|
||||
lexer->lookahead == ';' ||
|
||||
lexer->lookahead == '}' ||
|
||||
lexer->eof(lexer)
|
||||
) return false;
|
||||
if (lexer->lookahead == '{') {
|
||||
return true;
|
||||
}
|
||||
lexer->advance(lexer, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -102,8 +102,8 @@ struct TSLanguage {
|
|||
const uint16_t *small_parse_table;
|
||||
const uint32_t *small_parse_table_map;
|
||||
const TSParseActionEntry *parse_actions;
|
||||
const char **symbol_names;
|
||||
const char **field_names;
|
||||
const char * const *symbol_names;
|
||||
const char * const *field_names;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
|
|
Loading…
Reference in New Issue