⬆️ tree-sitter-cli

This commit is contained in:
Max Brunsfeld 2019-12-03 09:10:18 -08:00
parent 827ebad900
commit 4010134341
4 changed files with 5986 additions and 5949 deletions

View File

@ -13,7 +13,7 @@
"nan": "^2.11.1" "nan": "^2.11.1"
}, },
"devDependencies": { "devDependencies": {
"tree-sitter-cli": "^0.15.6" "tree-sitter-cli": "^0.15.14"
}, },
"scripts": { "scripts": {
"test": "tree-sitter test && tree-sitter parse examples/*.css --quiet --time", "test": "tree-sitter test && tree-sitter parse examples/*.css --quiet --time",

400
src/node-types.json vendored
View File

@ -5,7 +5,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -70,6 +70,14 @@
"multiple": true, "multiple": true,
"required": false, "required": false,
"types": [ "types": [
{
"type": "adjacent_sibling_selector",
"named": true
},
{
"type": "attribute_selector",
"named": true
},
{ {
"type": "binary_expression", "type": "binary_expression",
"named": true "named": true
@ -78,18 +86,38 @@
"type": "call_expression", "type": "call_expression",
"named": true "named": true
}, },
{
"type": "child_selector",
"named": true
},
{
"type": "class_selector",
"named": true
},
{ {
"type": "color_value", "type": "color_value",
"named": true "named": true
}, },
{
"type": "descendant_selector",
"named": true
},
{ {
"type": "float_value", "type": "float_value",
"named": true "named": true
}, },
{
"type": "id_selector",
"named": true
},
{ {
"type": "integer_value", "type": "integer_value",
"named": true "named": true
}, },
{
"type": "nesting_selector",
"named": true
},
{ {
"type": "parenthesized_value", "type": "parenthesized_value",
"named": true "named": true
@ -98,9 +126,29 @@
"type": "plain_value", "type": "plain_value",
"named": true "named": true
}, },
{
"type": "pseudo_class_selector",
"named": true
},
{
"type": "pseudo_element_selector",
"named": true
},
{
"type": "sibling_selector",
"named": true
},
{ {
"type": "string_value", "type": "string_value",
"named": true "named": true
},
{
"type": "tag_name",
"named": true
},
{
"type": "universal_selector",
"named": true
} }
] ]
} }
@ -111,7 +159,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "at_keyword", "type": "at_keyword",
@ -154,7 +202,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -249,7 +297,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_expression", "type": "binary_expression",
@ -292,7 +340,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_query", "type": "binary_query",
@ -374,7 +422,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "arguments", "type": "arguments",
@ -392,8 +440,8 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": false,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_expression", "type": "binary_expression",
@ -436,7 +484,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -499,7 +547,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -571,7 +619,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_expression", "type": "binary_expression",
@ -622,7 +670,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -685,7 +733,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_expression", "type": "binary_expression",
@ -731,7 +779,7 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": false,
"required": false, "required": false,
"types": [ "types": [
{ {
@ -747,7 +795,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -814,7 +862,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_expression", "type": "binary_expression",
@ -880,7 +928,7 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": false,
"required": false, "required": false,
"types": [ "types": [
{ {
@ -896,7 +944,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "block", "type": "block",
@ -938,8 +986,12 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{
"type": "at_keyword",
"named": true
},
{ {
"type": "keyframe_block_list", "type": "keyframe_block_list",
"named": true "named": true
@ -957,7 +1009,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_query", "type": "binary_query",
@ -996,7 +1048,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "call_expression", "type": "call_expression",
@ -1018,8 +1070,8 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": false,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_query", "type": "binary_query",
@ -1053,8 +1105,8 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": false,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_expression", "type": "binary_expression",
@ -1097,7 +1149,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -1168,7 +1220,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -1231,7 +1283,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "block", "type": "block",
@ -1249,8 +1301,8 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": false,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -1313,7 +1365,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -1376,7 +1428,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "adjacent_sibling_selector", "type": "adjacent_sibling_selector",
@ -1486,7 +1538,7 @@
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": true,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_query", "type": "binary_query",
@ -1524,8 +1576,8 @@
"named": true, "named": true,
"fields": {}, "fields": {},
"children": { "children": {
"multiple": true, "multiple": false,
"required": false, "required": true,
"types": [ "types": [
{ {
"type": "binary_query", "type": "binary_query",
@ -1559,122 +1611,14 @@
"named": true, "named": true,
"fields": {} "fields": {}
}, },
{
"type": "@import",
"named": false
},
{
"type": ",",
"named": false
},
{
"type": ";",
"named": false
},
{
"type": "@media",
"named": false
},
{
"type": "@charset",
"named": false
},
{
"type": "@namespace",
"named": false
},
{
"type": "@keyframes",
"named": false
},
{
"type": "{",
"named": false
},
{
"type": "}",
"named": false
},
{
"type": "from",
"named": true
},
{
"type": "to",
"named": true
},
{
"type": "@supports",
"named": false
},
{
"type": "nesting_selector",
"named": true
},
{
"type": "*",
"named": false
},
{
"type": ".",
"named": false
},
{
"type": ":",
"named": false
},
{
"type": "::",
"named": false
},
{ {
"type": "#", "type": "#",
"named": false "named": false
}, },
{
"type": "[",
"named": false
},
{
"type": "=",
"named": false
},
{
"type": "~=",
"named": false
},
{
"type": "^=",
"named": false
},
{
"type": "|=",
"named": false
},
{
"type": "*=",
"named": false
},
{ {
"type": "$=", "type": "$=",
"named": false "named": false
}, },
{
"type": "]",
"named": false
},
{
"type": ">",
"named": false
},
{
"type": "~",
"named": false
},
{
"type": "+",
"named": false
},
{ {
"type": "(", "type": "(",
"named": false "named": false
@ -1684,11 +1628,87 @@
"named": false "named": false
}, },
{ {
"type": "important", "type": "*",
"named": true "named": false
}, },
{ {
"type": "(", "type": "*=",
"named": false
},
{
"type": "+",
"named": false
},
{
"type": ",",
"named": false
},
{
"type": "-",
"named": false
},
{
"type": ".",
"named": false
},
{
"type": "/",
"named": false
},
{
"type": ":",
"named": false
},
{
"type": "::",
"named": false
},
{
"type": ";",
"named": false
},
{
"type": "=",
"named": false
},
{
"type": ">",
"named": false
},
{
"type": "@charset",
"named": false
},
{
"type": "@import",
"named": false
},
{
"type": "@keyframes",
"named": false
},
{
"type": "@media",
"named": false
},
{
"type": "@namespace",
"named": false
},
{
"type": "@supports",
"named": false
},
{
"type": "[",
"named": false
},
{
"type": "]",
"named": false
},
{
"type": "^=",
"named": false "named": false
}, },
{ {
@ -1696,8 +1716,52 @@
"named": false "named": false
}, },
{ {
"type": "or", "type": "at_keyword",
"named": false "named": true
},
{
"type": "attribute_name",
"named": true
},
{
"type": "class_name",
"named": true
},
{
"type": "feature_name",
"named": true
},
{
"type": "from",
"named": true
},
{
"type": "function_name",
"named": true
},
{
"type": "id_name",
"named": true
},
{
"type": "important",
"named": true
},
{
"type": "keyframes_name",
"named": true
},
{
"type": "keyword_query",
"named": true
},
{
"type": "namespace_name",
"named": true
},
{
"type": "nesting_selector",
"named": true
}, },
{ {
"type": "not", "type": "not",
@ -1707,6 +1771,18 @@
"type": "only", "type": "only",
"named": false "named": false
}, },
{
"type": "or",
"named": false
},
{
"type": "plain_value",
"named": true
},
{
"type": "property_name",
"named": true
},
{ {
"type": "selector", "type": "selector",
"named": false "named": false
@ -1715,32 +1791,36 @@
"type": "string_value", "type": "string_value",
"named": true "named": true
}, },
{
"type": "tag_name",
"named": true
},
{
"type": "to",
"named": true
},
{ {
"type": "unit", "type": "unit",
"named": true "named": true
}, },
{ {
"type": "-", "type": "{",
"named": false "named": false
}, },
{ {
"type": "/", "type": "|=",
"named": false "named": false
}, },
{ {
"type": "identifier", "type": "}",
"named": true "named": false
}, },
{ {
"type": "at_keyword", "type": "~",
"named": true "named": false
}, },
{ {
"type": "comment", "type": "~=",
"named": true "named": false
},
{
"type": "plain_value",
"named": true
} }
] ]

11529
src/parser.c vendored

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,8 @@ struct TSLexer {
void (*advance)(TSLexer *, bool); void (*advance)(TSLexer *, bool);
void (*mark_end)(TSLexer *); void (*mark_end)(TSLexer *);
uint32_t (*get_column)(TSLexer *); uint32_t (*get_column)(TSLexer *);
bool (*is_at_included_range_start)(TSLexer *); bool (*is_at_included_range_start)(const TSLexer *);
bool (*eof)(const TSLexer *);
}; };
typedef enum { typedef enum {
@ -123,6 +124,7 @@ struct TSLanguage {
#define START_LEXER() \ #define START_LEXER() \
bool result = false; \ bool result = false; \
bool skip = false; \ bool skip = false; \
bool eof = false; \
int32_t lookahead; \ int32_t lookahead; \
goto start; \ goto start; \
next_state: \ next_state: \