Compare commits

...

5 Commits

Author SHA1 Message Date
Shadowfacts dab6d76f9c tree-sitter 0.20, --abi=14 2022-05-28 10:47:57 -04:00
Max Brunsfeld a03f1d2d1d Allow spaces before colons in declarations
Closes #20
2021-09-15 14:32:51 -07:00
Microsoft Provenance Contributions 7c39062216
Update package.json to include the repository key (#19)
With the rise in supply chain attacks and OSS dependencies being used as a attack vector, Microsoft is working with our ecosystem partners, such as the Linux Foundation's OpenSSF, to enable OSS consumers to track packages back to their public sources.
We've identified that the following packages published to NPM do not report where sources can be found, typically accomplished by including a link to your GitHub repository in your `package.json` REPOSITORY field. This PR was created to add this value, ensuring future releases will include this provenance information.
Published NPM packages with repository information:
* tree-sitter-css
2021-08-17 11:20:41 -07:00
Ryan Tsao 94e1023093
Fix parsing of negative numbers (#12)
* Add failing test for negative numbers

* Fix parsing of negative numbers

* Rearrange assertion to avoid extra diff noise
2021-03-04 15:25:23 -08:00
Max Brunsfeld 9668e88916 0.19.0 2021-03-04 14:45:38 -08:00
8 changed files with 1871 additions and 1609 deletions

View File

@ -1,12 +1,13 @@
[package]
name = "tree-sitter-css"
description = "css grammar for the tree-sitter parsing library"
version = "0.0.1"
version = "0.20.0"
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 = [
@ -20,7 +21,7 @@ include = [
path = "bindings/rust/lib.rs"
[dependencies]
tree-sitter = "0.17"
tree-sitter = "0.20"
[build-dependencies]
cc = "1.0"

View File

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

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,19 +1,23 @@
{
"name": "tree-sitter-css",
"version": "0.16.0",
"version": "0.20.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.19.1"
"tree-sitter-cli": "^0.20.0"
},
"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",

3407
src/parser.c vendored

File diff suppressed because it is too large Load Diff

24
src/scanner.c vendored
View File

@ -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;

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 **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;
@ -123,6 +123,7 @@ struct TSLanguage {
unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned);
} external_scanner;
const TSStateId *primary_state_ids;
};
/*