tree-sitter-css/src/grammar.json

1709 lines
36 KiB
JSON

{
"name": "css",
"rules": {
"stylesheet": {
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_top_level_item"
}
},
"_top_level_item": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "rule_set"
},
{
"type": "SYMBOL",
"name": "import_statement"
},
{
"type": "SYMBOL",
"name": "media_statement"
},
{
"type": "SYMBOL",
"name": "charset_statement"
},
{
"type": "SYMBOL",
"name": "namespace_statement"
},
{
"type": "SYMBOL",
"name": "keyframes_statement"
},
{
"type": "SYMBOL",
"name": "supports_statement"
},
{
"type": "SYMBOL",
"name": "at_rule"
}
]
},
"import_statement": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@import"
},
{
"type": "SYMBOL",
"name": "_value"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_query"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_query"
}
]
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ";"
}
]
},
"media_statement": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@media"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_query"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_query"
}
]
}
}
]
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"charset_statement": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@charset"
},
{
"type": "SYMBOL",
"name": "_value"
},
{
"type": "STRING",
"value": ";"
}
]
},
"namespace_statement": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@namespace"
},
{
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "namespace_name"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "string_value"
},
{
"type": "SYMBOL",
"name": "call_expression"
}
]
},
{
"type": "STRING",
"value": ";"
}
]
},
"keyframes_statement": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "@keyframes"
},
{
"type": "ALIAS",
"content": {
"type": "PATTERN",
"value": "@[-a-z]+keyframes"
},
"named": true,
"value": "at_keyword"
}
]
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "keyframes_name"
},
{
"type": "SYMBOL",
"name": "keyframe_block_list"
}
]
},
"keyframe_block_list": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "keyframe_block"
}
},
{
"type": "STRING",
"value": "}"
}
]
},
"keyframe_block": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "from"
},
{
"type": "SYMBOL",
"name": "to"
},
{
"type": "SYMBOL",
"name": "integer_value"
}
]
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"from": {
"type": "STRING",
"value": "from"
},
"to": {
"type": "STRING",
"value": "to"
},
"supports_statement": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "@supports"
},
{
"type": "SYMBOL",
"name": "_query"
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"at_rule": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "at_keyword"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_query"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_query"
}
]
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ";"
},
{
"type": "SYMBOL",
"name": "block"
}
]
}
]
},
"rule_set": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "selectors"
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"selectors": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "_selector"
}
]
}
}
]
},
"block": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_block_item"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "last_declaration"
},
"named": true,
"value": "declaration"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "}"
}
]
},
"_block_item": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "declaration"
},
{
"type": "SYMBOL",
"name": "_top_level_item"
}
]
},
"_selector": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "universal_selector"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "tag_name"
},
{
"type": "SYMBOL",
"name": "class_selector"
},
{
"type": "SYMBOL",
"name": "nesting_selector"
},
{
"type": "SYMBOL",
"name": "pseudo_class_selector"
},
{
"type": "SYMBOL",
"name": "pseudo_element_selector"
},
{
"type": "SYMBOL",
"name": "id_selector"
},
{
"type": "SYMBOL",
"name": "attribute_selector"
},
{
"type": "SYMBOL",
"name": "string_value"
},
{
"type": "SYMBOL",
"name": "child_selector"
},
{
"type": "SYMBOL",
"name": "descendant_selector"
},
{
"type": "SYMBOL",
"name": "sibling_selector"
},
{
"type": "SYMBOL",
"name": "adjacent_sibling_selector"
}
]
},
"nesting_selector": {
"type": "STRING",
"value": "&"
},
"universal_selector": {
"type": "STRING",
"value": "*"
},
"class_selector": {
"type": "PREC",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "."
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "class_name"
}
]
}
},
"pseudo_class_selector": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ":"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "class_name"
},
{
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "pseudo_class_arguments"
},
"named": true,
"value": "arguments"
},
{
"type": "BLANK"
}
]
}
]
},
"pseudo_element_selector": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "::"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "tag_name"
}
]
},
"id_selector": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "#"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "id_name"
}
]
},
"attribute_selector": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "["
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "attribute_name"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "~="
},
{
"type": "STRING",
"value": "^="
},
{
"type": "STRING",
"value": "|="
},
{
"type": "STRING",
"value": "*="
},
{
"type": "STRING",
"value": "$="
}
]
},
{
"type": "SYMBOL",
"name": "_value"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "]"
}
]
},
"child_selector": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "STRING",
"value": ">"
},
{
"type": "SYMBOL",
"name": "_selector"
}
]
}
},
"descendant_selector": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "SYMBOL",
"name": "_descendant_operator"
},
{
"type": "SYMBOL",
"name": "_selector"
}
]
}
},
"sibling_selector": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "STRING",
"value": "~"
},
{
"type": "SYMBOL",
"name": "_selector"
}
]
}
},
"adjacent_sibling_selector": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "STRING",
"value": "+"
},
{
"type": "SYMBOL",
"name": "_selector"
}
]
}
},
"pseudo_class_arguments": {
"type": "SEQ",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "("
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_value"
}
}
]
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_value"
}
}
]
}
]
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ")"
}
]
},
"declaration": {
"type": "PREC",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "property_name"
},
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "_value"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_value"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "important"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ";"
}
]
}
},
"last_declaration": {
"type": "PREC",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "property_name"
},
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "_value"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_value"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "important"
},
{
"type": "BLANK"
}
]
}
]
}
},
"important": {
"type": "STRING",
"value": "!important"
},
"_query": {
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "keyword_query"
},
{
"type": "SYMBOL",
"name": "feature_query"
},
{
"type": "SYMBOL",
"name": "binary_query"
},
{
"type": "SYMBOL",
"name": "unary_query"
},
{
"type": "SYMBOL",
"name": "selector_query"
},
{
"type": "SYMBOL",
"name": "parenthesized_query"
}
]
},
"feature_query": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "feature_name"
},
{
"type": "STRING",
"value": ":"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_value"
}
},
{
"type": "STRING",
"value": ")"
}
]
},
"parenthesized_query": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "_query"
},
{
"type": "STRING",
"value": ")"
}
]
},
"binary_query": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_query"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "and"
},
{
"type": "STRING",
"value": "or"
}
]
},
{
"type": "SYMBOL",
"name": "_query"
}
]
}
},
"unary_query": {
"type": "PREC",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "not"
},
{
"type": "STRING",
"value": "only"
}
]
},
{
"type": "SYMBOL",
"name": "_query"
}
]
}
},
"selector_query": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "selector"
},
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "_selector"
},
{
"type": "STRING",
"value": ")"
}
]
},
"_value": {
"type": "PREC",
"value": -1,
"content": {
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "plain_value"
},
{
"type": "SYMBOL",
"name": "plain_value"
},
{
"type": "SYMBOL",
"name": "color_value"
},
{
"type": "SYMBOL",
"name": "integer_value"
},
{
"type": "SYMBOL",
"name": "float_value"
},
{
"type": "SYMBOL",
"name": "string_value"
},
{
"type": "SYMBOL",
"name": "binary_expression"
},
{
"type": "SYMBOL",
"name": "parenthesized_value"
},
{
"type": "SYMBOL",
"name": "call_expression"
}
]
}
},
"parenthesized_value": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "_value"
},
{
"type": "STRING",
"value": ")"
}
]
},
"color_value": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "#"
},
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "[0-9a-fA-F]{3,8}"
}
}
]
},
"string_value": {
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "'"
},
{
"type": "PATTERN",
"value": "([^'\\n]|\\\\(.|\\n))*"
},
{
"type": "STRING",
"value": "'"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\""
},
{
"type": "PATTERN",
"value": "([^\"\\n]|\\\\(.|\\n))*"
},
{
"type": "STRING",
"value": "\""
}
]
}
]
}
},
"integer_value": {
"type": "SEQ",
"members": [
{
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "+"
},
{
"type": "STRING",
"value": "-"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "PATTERN",
"value": "\\d+"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "unit"
},
{
"type": "BLANK"
}
]
}
]
},
"float_value": {
"type": "SEQ",
"members": [
{
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "+"
},
{
"type": "STRING",
"value": "-"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "PATTERN",
"value": "\\d*"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "PATTERN",
"value": "\\d+"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "[eE]"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "-"
},
{
"type": "BLANK"
}
]
},
{
"type": "PATTERN",
"value": "\\d+"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "."
},
{
"type": "PATTERN",
"value": "\\d+"
},
{
"type": "PATTERN",
"value": "[eE]"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "-"
},
{
"type": "BLANK"
}
]
},
{
"type": "PATTERN",
"value": "\\d+"
}
]
}
]
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "unit"
},
{
"type": "BLANK"
}
]
}
]
},
"unit": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "[a-zA-Z%]+"
}
},
"call_expression": {
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "identifier"
},
"named": true,
"value": "function_name"
},
{
"type": "SYMBOL",
"name": "arguments"
}
]
},
"binary_expression": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_value"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "+"
},
{
"type": "STRING",
"value": "-"
},
{
"type": "STRING",
"value": "*"
},
{
"type": "STRING",
"value": "/"
}
]
},
{
"type": "SYMBOL",
"name": "_value"
}
]
}
},
"arguments": {
"type": "SEQ",
"members": [
{
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "("
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_value"
}
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "STRING",
"value": ";"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "_value"
}
}
]
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ")"
}
]
},
"identifier": {
"type": "PATTERN",
"value": "[a-zA-Z-_][a-zA-Z0-9-_]*"
},
"at_keyword": {
"type": "PATTERN",
"value": "@[a-zA-Z-_]+"
},
"comment": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "/*"
},
{
"type": "PATTERN",
"value": "[^*]*\\*+([^\\/*][^*]*\\*+)*"
},
{
"type": "STRING",
"value": "/"
}
]
}
},
"plain_value": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[-_]"
},
{
"type": "PATTERN",
"value": "\\/[^\\*\\s,;!{}()\\[\\]]"
}
]
}
},
{
"type": "PATTERN",
"value": "[a-zA-Z]"
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "[^\\/\\s,;!{}()\\[\\]]"
},
{
"type": "PATTERN",
"value": "\\/[^\\*\\s,;!{}()\\[\\]]"
}
]
}
}
]
}
}
},
"extras": [
{
"type": "PATTERN",
"value": "\\s"
},
{
"type": "SYMBOL",
"name": "comment"
}
],
"conflicts": [],
"externals": [
{
"type": "SYMBOL",
"name": "_descendant_operator"
}
],
"inline": [
"_top_level_item",
"_block_item"
]
}