tree-sitter-d2/src/grammar.json

1013 lines
23 KiB
JSON
Raw Normal View History

2022-12-04 00:07:26 +03:00
{
"name": "d2",
"word": "_identifier",
2022-12-04 00:07:26 +03:00
"rules": {
"source_file": {
"type": "REPEAT",
"content": {
"type": "SYMBOL",
2022-12-07 23:14:25 +03:00
"name": "_root_definition"
2022-12-04 00:07:26 +03:00
}
},
2022-12-07 23:14:25 +03:00
"_root_definition": {
2022-12-04 00:07:26 +03:00
"type": "CHOICE",
"members": [
2022-12-06 00:53:06 +03:00
{
2022-12-06 12:40:18 +03:00
"type": "SYMBOL",
"name": "_eol"
2022-12-06 00:53:06 +03:00
},
2022-12-04 18:35:50 +03:00
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_root_attribute"
},
"named": true,
"value": "attribute"
},
{
"type": "SYMBOL",
"name": "shape"
},
{
"type": "SYMBOL",
"name": "container"
},
{
"type": "SYMBOL",
"name": "connection"
}
]
},
{
"type": "SYMBOL",
"name": "_end"
}
]
2022-12-04 00:07:26 +03:00
}
]
},
"connection": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_connection_path"
2022-12-04 00:07:26 +03:00
},
2022-12-05 10:33:49 +03:00
{
"type": "REPEAT1",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "arrow"
2022-12-05 10:33:49 +03:00
},
{
"type": "SYMBOL",
"name": "_connection_path"
2022-12-05 10:33:49 +03:00
}
]
}
},
2022-12-04 00:07:26 +03:00
{
2022-12-04 03:25:38 +03:00
"type": "CHOICE",
"members": [
{
"type": "SEQ",
2022-12-04 03:25:38 +03:00
"members": [
{
"type": "SYMBOL",
"name": "_colon"
2022-12-05 10:33:49 +03:00
},
{
"type": "SYMBOL",
"name": "label"
2022-12-04 03:25:38 +03:00
}
]
},
{
2022-12-05 10:33:49 +03:00
"type": "BLANK"
2022-12-04 03:25:38 +03:00
}
]
2022-12-04 00:07:26 +03:00
}
]
},
"_connection_path": {
2022-12-04 03:13:40 +03:00
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "PREC",
"value": 2,
"content": {
"type": "SEQ",
2022-12-04 03:13:40 +03:00
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "shape_key"
},
"named": true,
"value": "container_key"
2022-12-04 03:13:40 +03:00
},
2022-12-05 00:26:24 +03:00
{
"type": "SYMBOL",
"name": "dot"
2022-12-05 00:26:24 +03:00
}
]
2022-12-04 00:07:26 +03:00
}
}
2022-12-04 03:13:40 +03:00
},
{
"type": "SYMBOL",
"name": "shape_key"
2022-12-04 03:13:40 +03:00
}
]
2022-12-04 00:07:26 +03:00
},
"container": {
"type": "PREC",
"value": 2,
"content": {
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "shape_key"
},
"named": true,
"value": "container_key"
},
{
2022-12-08 01:15:09 +03:00
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "dot"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "shape"
},
{
"type": "SYMBOL",
"name": "container"
}
]
}
]
2022-12-08 01:15:09 +03:00
},
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_colon"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "label"
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_container_block"
},
"named": true,
"value": "block"
}
]
},
{
"type": "BLANK"
}
]
}
]
}
]
2022-12-08 01:15:09 +03:00
}
]
}
]
}
},
"_container_block": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
2022-12-08 01:15:09 +03:00
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_container_block_definition"
2022-12-08 01:15:09 +03:00
}
},
{
"type": "STRING",
"value": "}"
2022-12-08 01:15:09 +03:00
}
]
},
"_container_block_definition": {
2022-12-07 23:14:25 +03:00
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_eol"
2022-12-07 23:14:25 +03:00
},
{
"type": "SEQ",
"members": [
{
2022-12-08 01:15:09 +03:00
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "shape"
2022-12-08 01:15:09 +03:00
},
{
"type": "SYMBOL",
"name": "container"
},
2022-12-08 01:15:09 +03:00
{
"type": "SYMBOL",
"name": "connection"
2022-12-08 01:15:09 +03:00
},
{
"type": "SYMBOL",
"name": "_shape_attribute"
}
]
},
{
"type": "SYMBOL",
"name": "_end"
}
]
}
]
},
"shape": {
"type": "PREC",
"value": 3,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "shape_key"
},
{
"type": "CHOICE",
"members": [
{
"type": "CHOICE",
"members": [
{
2022-12-08 01:15:09 +03:00
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "dot"
2022-12-08 01:15:09 +03:00
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_style_attribute"
},
"named": true,
"value": "attribute"
}
]
},
{
"type": "SEQ",
"members": [
2022-12-08 01:15:09 +03:00
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_colon"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "label"
},
{
"type": "BLANK"
}
]
}
]
2022-12-08 01:15:09 +03:00
},
{
"type": "BLANK"
2022-12-08 01:15:09 +03:00
}
]
}
]
2022-12-07 23:14:25 +03:00
}
]
},
{
"type": "BLANK"
}
]
}
]
}
},
"shape_key": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "string"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_identifier"
2022-12-08 01:15:09 +03:00
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_dash"
},
{
"type": "BLANK"
}
]
2022-12-07 23:14:25 +03:00
}
]
}
]
},
"_identifier": {
"type": "TOKEN",
2022-12-08 01:37:35 +03:00
"content": {
"type": "PREC",
"value": 0,
"content": {
"type": "PATTERN",
"value": "\\-?([\\w\\d]+|([\\w\\d]+( +|\\-)[\\w\\d]+)+)"
}
2022-12-08 01:37:35 +03:00
}
},
"_root_attribute": {
"type": "SEQ",
2022-12-04 00:07:26 +03:00
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_root_attr_key"
},
"named": true,
"value": "attr_key"
},
2022-12-04 00:07:26 +03:00
{
"type": "SYMBOL",
"name": "_colon"
2022-12-04 00:07:26 +03:00
},
{
2022-12-04 03:36:46 +03:00
"type": "SYMBOL",
"name": "attr_value"
2022-12-04 00:07:26 +03:00
}
]
},
"_root_attr_key": {
"type": "CHOICE",
2022-12-04 18:35:50 +03:00
"members": [
2022-12-04 23:45:53 +03:00
{
"type": "STRING",
"value": "direction"
},
{
"type": "ALIAS",
2022-12-06 11:57:59 +03:00
"content": {
2022-12-07 18:52:19 +03:00
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "shape"
2022-12-07 18:52:19 +03:00
},
{
"type": "STRING",
"value": "label"
2022-12-07 18:52:19 +03:00
},
{
"type": "STRING",
"value": "constraint"
2022-12-07 18:52:19 +03:00
},
{
"type": "STRING",
"value": "icon"
2022-12-07 18:52:19 +03:00
},
{
"type": "STRING",
"value": "style"
2022-12-06 12:32:50 +03:00
},
{
"type": "SYMBOL",
"name": "_common_style_attr_key"
2022-12-07 18:52:19 +03:00
},
{
"type": "SYMBOL",
"name": "_text_attr_key"
2022-12-07 18:52:19 +03:00
}
]
},
"named": true,
"value": "reserved"
2022-12-06 12:32:50 +03:00
}
]
},
2022-12-06 11:57:59 +03:00
"_shape_attribute": {
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_base_shape_attribute"
},
"named": true,
"value": "attribute"
2022-12-06 11:57:59 +03:00
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_style_attribute"
},
"named": true,
"value": "attribute"
2022-12-06 11:57:59 +03:00
}
]
},
"_base_shape_attribute": {
2022-12-04 23:45:53 +03:00
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_shape_attr_key"
2022-12-04 23:45:53 +03:00
},
"named": true,
"value": "attr_key"
},
{
"type": "SYMBOL",
"name": "_colon"
},
{
"type": "SYMBOL",
"name": "attr_value"
2022-12-06 11:57:59 +03:00
}
]
},
"_shape_attr_key": {
"type": "PREC",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "shape"
},
{
"type": "STRING",
"value": "label"
},
{
"type": "STRING",
"value": "constraint"
},
{
"type": "STRING",
"value": "icon"
},
{
"type": "STRING",
"value": "width"
},
{
"type": "STRING",
"value": "height"
2022-12-06 11:57:59 +03:00
}
]
}
},
"_style_attribute": {
"type": "PREC",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "style"
},
"named": true,
"value": "attr_key"
},
{
2022-12-06 11:57:59 +03:00
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "dot"
2022-12-06 11:57:59 +03:00
},
{
"type": "ALIAS",
"content": {
2022-12-06 11:57:59 +03:00
"type": "SYMBOL",
"name": "_inner_style_attribute"
2022-12-06 11:57:59 +03:00
},
"named": true,
"value": "attribute"
}
]
2022-12-07 18:52:19 +03:00
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_colon"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_style_attribute_block"
},
"named": true,
"value": "block"
}
]
2022-12-07 18:52:19 +03:00
}
]
2022-12-06 11:57:59 +03:00
}
]
}
2022-12-06 11:57:59 +03:00
},
"_style_attribute_block": {
2022-12-06 11:57:59 +03:00
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
2022-12-06 11:57:59 +03:00
{
"type": "REPEAT",
"content": {
2022-12-07 18:52:19 +03:00
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_eol"
2022-12-07 18:52:19 +03:00
},
{
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_inner_style_attribute"
},
"named": true,
"value": "attribute"
},
{
"type": "SYMBOL",
"name": "_end"
}
]
2022-12-07 18:52:19 +03:00
}
]
2022-12-06 11:57:59 +03:00
}
},
{
"type": "STRING",
"value": "}"
2022-12-04 23:45:53 +03:00
}
]
},
"_inner_style_attribute": {
"type": "PREC",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_style_attr_key"
},
"named": true,
"value": "attr_key"
},
{
2022-12-05 10:37:04 +03:00
"type": "SYMBOL",
"name": "_colon"
2022-12-05 10:37:04 +03:00
},
{
"type": "SYMBOL",
"name": "attr_value"
}
]
}
2022-12-05 10:37:04 +03:00
},
"_style_attr_key": {
2022-12-04 23:45:53 +03:00
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_common_style_attr_key"
2022-12-04 23:45:53 +03:00
},
{
"type": "STRING",
"value": "3d"
2022-12-04 23:45:53 +03:00
}
]
},
"_common_style_attr_key": {
2022-12-04 23:45:53 +03:00
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "opacity"
},
{
"type": "STRING",
"value": "fill"
},
{
"type": "STRING",
"value": "stroke"
},
{
"type": "STRING",
"value": "stroke-width"
},
{
"type": "STRING",
"value": "stroke-dash"
},
{
"type": "STRING",
"value": "border-radius"
},
{
"type": "STRING",
"value": "font-color"
},
{
"type": "STRING",
"value": "shadow"
},
{
"type": "STRING",
"value": "multiple"
},
{
"type": "STRING",
"value": "animated"
},
{
"type": "STRING",
"value": "link"
}
]
},
"_text_attr_key": {
"type": "STRING",
"value": "near"
},
"_connection_attr_key": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "source-arrowhead"
},
{
"type": "STRING",
"value": "target-arrowhead"
2022-12-04 18:35:50 +03:00
}
]
},
"label": {
"type": "CHOICE",
2022-12-05 00:26:24 +03:00
"members": [
{
"type": "SYMBOL",
"name": "string"
2022-12-05 00:26:24 +03:00
},
{
"type": "SYMBOL",
"name": "_unquoted_string"
2022-12-05 00:26:24 +03:00
}
]
},
"attr_value": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "string"
},
{
"type": "SYMBOL",
"name": "_unquoted_string"
}
]
}
]
2022-12-04 18:35:37 +03:00
},
"_dash": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": "-"
}
},
"_colon": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ":"
}
]
2022-12-04 00:07:26 +03:00
},
"arrow": {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "PATTERN",
"value": "-+>"
},
{
"type": "PATTERN",
"value": "--+"
},
{
"type": "PATTERN",
"value": "<-+"
},
{
"type": "PATTERN",
"value": "<-+>"
}
]
}
}
},
"dot": {
"type": "TOKEN",
"content": {
"type": "STRING",
"value": "."
}
},
2022-12-04 03:36:46 +03:00
"_unquoted_string": {
"type": "TOKEN",
2022-12-05 00:26:24 +03:00
"content": {
"type": "PREC",
"value": 0,
"content": {
"type": "PATTERN",
"value": "[\\w\\-?!]([^'\"`\\n;{}]*[\\w\\-?!])?"
}
2022-12-05 00:26:24 +03:00
}
2022-12-04 03:36:46 +03:00
},
2022-12-04 00:07:26 +03:00
"string": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "'"
},
{
"type": "REPEAT",
"content": {
2022-12-05 00:26:24 +03:00
"type": "IMMEDIATE_TOKEN",
2022-12-04 00:07:26 +03:00
"content": {
"type": "PATTERN",
"value": "[^'\\n]+"
}
}
},
{
"type": "STRING",
"value": "'"
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\""
},
{
"type": "REPEAT",
"content": {
2022-12-05 00:26:24 +03:00
"type": "IMMEDIATE_TOKEN",
2022-12-04 00:07:26 +03:00
"content": {
"type": "PATTERN",
2022-12-05 00:26:24 +03:00
"value": "[^\"\\n]+"
2022-12-04 00:07:26 +03:00
}
}
},
{
"type": "STRING",
"value": "\""
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "`"
},
{
"type": "REPEAT",
"content": {
2022-12-05 00:26:24 +03:00
"type": "IMMEDIATE_TOKEN",
2022-12-04 00:07:26 +03:00
"content": {
"type": "PATTERN",
2022-12-05 00:26:24 +03:00
"value": "[^`\\n]+"
2022-12-04 00:07:26 +03:00
}
}
},
{
"type": "STRING",
"value": "`"
}
]
}
]
2022-12-04 23:45:53 +03:00
},
2022-12-07 12:09:27 +03:00
"line_comment": {
"type": "TOKEN",
"content": {
2022-12-08 02:04:36 +03:00
"type": "PREC",
"value": -2,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "#"
},
{
"type": "PATTERN",
"value": ".*"
}
]
}
2022-12-07 12:09:27 +03:00
}
},
"_eol": {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": -1,
"content": {
2022-12-04 23:45:53 +03:00
"type": "STRING",
"value": "\n"
}
}
2022-12-04 23:45:53 +03:00
},
2022-12-06 00:34:41 +03:00
"_end": {
2022-12-06 00:53:06 +03:00
"type": "SEQ",
2022-12-06 00:34:41 +03:00
"members": [
{
2022-12-06 00:53:06 +03:00
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ";"
},
{
"type": "SYMBOL",
"name": "_eol"
2022-12-06 00:53:06 +03:00
}
]
2022-12-06 00:34:41 +03:00
}
]
2022-12-04 00:07:26 +03:00
}
},
2022-12-07 12:09:27 +03:00
"extras": [
{
"type": "PATTERN",
"value": "[ \\f\\t\\v\\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000\\ufeff]"
},
2022-12-07 12:09:27 +03:00
{
"type": "SYMBOL",
"name": "line_comment"
}
],
"conflicts": [
[
"_connection_path",
"container"
]
],
2022-12-04 00:07:26 +03:00
"precedences": [],
2022-12-04 18:35:37 +03:00
"externals": [],
2022-12-04 00:07:26 +03:00
"inline": [],
"supertypes": []
}