Compare commits

..

No commits in common. "dab6d76f9c05406b8e99eec6f13bec783455012b" and "f13775ea604c9c56eab4e5b0dc4e5120a64dce9a" have entirely different histories.

8 changed files with 1643 additions and 1905 deletions

View File

@ -1,13 +1,12 @@
[package] [package]
name = "tree-sitter-css" name = "tree-sitter-css"
description = "css grammar for the tree-sitter parsing library" description = "css grammar for the tree-sitter parsing library"
version = "0.20.0" version = "0.0.1"
keywords = ["incremental", "parsing", "css"] keywords = ["incremental", "parsing", "css"]
categories = ["parsing", "text-editors"] categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-javascript" repository = "https://github.com/tree-sitter/tree-sitter-javascript"
edition = "2018" edition = "2018"
license = "MIT" license = "MIT"
authors = ["Max Brunsfeld <maxbrunsfeld@gmail.com>"]
build = "bindings/rust/build.rs" build = "bindings/rust/build.rs"
include = [ include = [
@ -21,7 +20,7 @@ include = [
path = "bindings/rust/lib.rs" path = "bindings/rust/lib.rs"
[dependencies] [dependencies]
tree-sitter = "0.20" tree-sitter = "0.17"
[build-dependencies] [build-dependencies]
cc = "1.0" cc = "1.0"

View File

@ -86,7 +86,6 @@ a {
c: 5em; c: 5em;
margin: 10E3px; margin: 10E3px;
margin: -456.8px; margin: -456.8px;
margin: -5px;
margin: -0.0px; margin: -0.0px;
} }
@ -98,7 +97,6 @@ a {
(declaration (property_name) (integer_value (unit))) (declaration (property_name) (integer_value (unit)))
(declaration (property_name) (float_value (unit))) (declaration (property_name) (float_value (unit)))
(declaration (property_name) (float_value (unit))) (declaration (property_name) (float_value (unit)))
(declaration (property_name) (integer_value (unit)))
(declaration (property_name) (float_value (unit)))))) (declaration (property_name) (float_value (unit))))))
============================ ============================
@ -242,28 +240,5 @@ a-property: calc(5px + var(--a-variable));
--- ---
(stylesheet (stylesheet
(declaration (property_name) (integer_value (unit))) (declaration (property_name) (plain_value))
(declaration (property_name) (call_expression (function_name) (arguments (binary_expression (integer_value (unit)) (call_expression (function_name) (arguments (plain_value)))))))) (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)))))

View File

@ -333,7 +333,7 @@ module.exports = grammar({
')' ')'
), ),
identifier: $ => /(--|-?[a-zA-Z_])[a-zA-Z0-9-_]*/, identifier: $ => /[a-zA-Z-_][a-zA-Z0-9-_]*/,
at_keyword: $ => /@[a-zA-Z-_]+/, at_keyword: $ => /@[a-zA-Z-_]+/,

View File

@ -1,23 +1,19 @@
{ {
"name": "tree-sitter-css", "name": "tree-sitter-css",
"version": "0.20.0", "version": "0.16.0",
"description": "CSS grammar for tree-sitter", "description": "CSS grammar for tree-sitter",
"main": "bindings/node", "main": "bindings/node",
"keywords": [ "keywords": [
"parser", "parser",
"lexer" "lexer"
], ],
"repository": {
"type": "git",
"url": "https://github.com/tree-sitter/tree-sitter-css.git"
},
"author": "Max Brunsfeld", "author": "Max Brunsfeld",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"nan": "^2.14.1" "nan": "^2.14.1"
}, },
"devDependencies": { "devDependencies": {
"tree-sitter-cli": "^0.20.0" "tree-sitter-cli": "^0.19.1"
}, },
"scripts": { "scripts": {
"test": "tree-sitter test && tree-sitter parse examples/*.css --quiet --time", "test": "tree-sitter test && tree-sitter parse examples/*.css --quiet --time",

2
src/grammar.json vendored
View File

@ -1642,7 +1642,7 @@
}, },
"identifier": { "identifier": {
"type": "PATTERN", "type": "PATTERN",
"value": "(--|-?[a-zA-Z_])[a-zA-Z0-9-_]*" "value": "[a-zA-Z-_][a-zA-Z0-9-_]*"
}, },
"at_keyword": { "at_keyword": {
"type": "PATTERN", "type": "PATTERN",

3475
src/parser.c vendored

File diff suppressed because it is too large Load Diff

24
src/scanner.c vendored
View File

@ -12,40 +12,24 @@ 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) {} 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) { bool tree_sitter_css_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
if (iswspace(lexer->lookahead) && valid_symbols[DESCENDANT_OP]) { if (iswspace(lexer->lookahead)) {
lexer->result_symbol = DESCENDANT_OP;
lexer->advance(lexer, true); lexer->advance(lexer, true);
while (iswspace(lexer->lookahead)) { while (iswspace(lexer->lookahead)) {
lexer->advance(lexer, true); lexer->advance(lexer, true);
} }
lexer->mark_end(lexer);
if ( if (
lexer->lookahead == '#' || lexer->lookahead == '#' ||
lexer->lookahead == '.' || lexer->lookahead == '.' ||
lexer->lookahead == '[' || lexer->lookahead == '[' ||
lexer->lookahead == ':' ||
lexer->lookahead == '-' || lexer->lookahead == '-' ||
iswalnum(lexer->lookahead) iswalnum(lexer->lookahead)
) { ) {
lexer->result_symbol = DESCENDANT_OP;
return true; 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; return false;

View File

@ -102,8 +102,8 @@ struct TSLanguage {
const uint16_t *small_parse_table; const uint16_t *small_parse_table;
const uint32_t *small_parse_table_map; const uint32_t *small_parse_table_map;
const TSParseActionEntry *parse_actions; const TSParseActionEntry *parse_actions;
const char * const *symbol_names; const char **symbol_names;
const char * const *field_names; const char **field_names;
const TSFieldMapSlice *field_map_slices; const TSFieldMapSlice *field_map_slices;
const TSFieldMapEntry *field_map_entries; const TSFieldMapEntry *field_map_entries;
const TSSymbolMetadata *symbol_metadata; const TSSymbolMetadata *symbol_metadata;
@ -123,7 +123,6 @@ struct TSLanguage {
unsigned (*serialize)(void *, char *); unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned); void (*deserialize)(void *, const char *, unsigned);
} external_scanner; } external_scanner;
const TSStateId *primary_state_ids;
}; };
/* /*