⬆️ 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"
},
"devDependencies": {
"tree-sitter-cli": "^0.15.6"
"tree-sitter-cli": "^0.15.14"
},
"scripts": {
"test": "tree-sitter test && tree-sitter parse examples/*.css --quiet --time",

400
src/node-types.json vendored
View File

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

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 (*mark_end)(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 {
@ -123,6 +124,7 @@ struct TSLanguage {
#define START_LEXER() \
bool result = false; \
bool skip = false; \
bool eof = false; \
int32_t lookahead; \
goto start; \
next_state: \