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

View File

@ -86,7 +86,6 @@ a {
c: 5em;
margin: 10E3px;
margin: -456.8px;
margin: -5px;
margin: -0.0px;
}
@ -98,7 +97,6 @@ a {
(declaration (property_name) (integer_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))))))
============================
@ -242,28 +240,5 @@ a-property: calc(5px + var(--a-variable));
---
(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))))))))
=============================================
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-_]+/,

View File

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

2
src/grammar.json vendored
View File

@ -1642,7 +1642,7 @@
},
"identifier": {
"type": "PATTERN",
"value": "(--|-?[a-zA-Z_])[a-zA-Z0-9-_]*"
"value": "[a-zA-Z-_][a-zA-Z0-9-_]*"
},
"at_keyword": {
"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) {}
bool tree_sitter_css_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) {
if (iswspace(lexer->lookahead) && valid_symbols[DESCENDANT_OP]) {
lexer->result_symbol = DESCENDANT_OP;
if (iswspace(lexer->lookahead)) {
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;

View File

@ -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 * const *symbol_names;
const char * const *field_names;
const char **symbol_names;
const char **field_names;
const TSFieldMapSlice *field_map_slices;
const TSFieldMapEntry *field_map_entries;
const TSSymbolMetadata *symbol_metadata;
@ -123,7 +123,6 @@ struct TSLanguage {
unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned);
} external_scanner;
const TSStateId *primary_state_ids;
};
/*