1
0
dust/tree-sitter-dust/src/grammar.json

1349 lines
28 KiB
JSON
Raw Normal View History

{
"name": "dust",
2023-12-11 16:17:37 +00:00
"word": "_identifier_pattern",
"rules": {
"root": {
"type": "PREC",
"value": 1,
"content": {
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "statement"
}
}
},
"_comment": {
"type": "PATTERN",
"value": "[#][^#\\n]*[#|\\n]"
},
"block": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "async"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "statement"
}
},
{
"type": "STRING",
"value": "}"
}
]
},
"statement": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "assignment"
},
{
"type": "SYMBOL",
"name": "block"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "for"
},
{
"type": "SYMBOL",
"name": "if_else"
},
{
"type": "SYMBOL",
"name": "index_assignment"
},
{
"type": "SYMBOL",
"name": "match"
},
{
"type": "SYMBOL",
"name": "return"
},
{
"type": "SYMBOL",
"name": "while"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ";"
},
{
"type": "BLANK"
}
]
}
]
}
},
"expression": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "function_call"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "index"
},
{
"type": "SYMBOL",
"name": "logic"
},
{
"type": "SYMBOL",
"name": "math"
},
{
"type": "SYMBOL",
"name": "value"
},
{
"type": "SYMBOL",
"name": "yield"
}
]
}
},
"_expression_list": {
"type": "REPEAT1",
"content": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
}
},
"identifier": {
2023-12-11 16:17:37 +00:00
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_identifier_pattern"
},
{
"type": "SYMBOL",
"name": "built_in_function"
}
]
},
"_identifier_pattern": {
"type": "PATTERN",
"value": "[_a-zA-Z]+[_a-zA-Z0-9]?"
},
"value": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
2023-12-12 23:21:16 +00:00
"name": "function"
},
{
"type": "SYMBOL",
2023-12-12 23:21:16 +00:00
"name": "integer"
},
2023-12-02 03:54:25 +00:00
{
"type": "SYMBOL",
2023-12-12 23:21:16 +00:00
"name": "float"
2023-12-02 03:54:25 +00:00
},
{
"type": "SYMBOL",
"name": "string"
},
{
"type": "SYMBOL",
"name": "boolean"
},
{
"type": "SYMBOL",
"name": "list"
},
{
"type": "SYMBOL",
"name": "map"
}
]
},
"integer": {
"type": "TOKEN",
"content": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "-"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "1"
},
{
"type": "STRING",
"value": "2"
},
{
"type": "STRING",
"value": "3"
},
{
"type": "STRING",
"value": "4"
},
{
"type": "STRING",
"value": "5"
},
{
"type": "STRING",
"value": "6"
},
{
"type": "STRING",
"value": "7"
},
{
"type": "STRING",
"value": "8"
},
{
"type": "STRING",
"value": "9"
},
{
"type": "STRING",
"value": "0"
}
]
}
}
]
}
}
},
"float": {
"type": "TOKEN",
"content": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "-"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "1"
},
{
"type": "STRING",
"value": "2"
},
{
"type": "STRING",
"value": "3"
},
{
"type": "STRING",
"value": "4"
},
{
"type": "STRING",
"value": "5"
},
{
"type": "STRING",
"value": "6"
},
{
"type": "STRING",
"value": "7"
},
{
"type": "STRING",
"value": "8"
},
{
"type": "STRING",
"value": "9"
},
{
"type": "STRING",
"value": "0"
}
]
}
},
{
"type": "STRING",
"value": "."
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "1"
},
{
"type": "STRING",
"value": "2"
},
{
"type": "STRING",
"value": "3"
},
{
"type": "STRING",
"value": "4"
},
{
"type": "STRING",
"value": "5"
},
{
"type": "STRING",
"value": "6"
},
{
"type": "STRING",
"value": "7"
},
{
"type": "STRING",
"value": "8"
},
{
"type": "STRING",
"value": "9"
},
{
"type": "STRING",
"value": "0"
}
]
}
}
]
}
}
},
"string": {
"type": "PATTERN",
"value": "(\"[^\"]*?\")|('[^']*?')|(`[^`]*?`)"
},
"boolean": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "true"
},
{
"type": "STRING",
"value": "false"
}
]
},
"list": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "REPEAT",
"content": {
2023-11-28 22:54:17 +00:00
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
}
},
{
"type": "STRING",
"value": "]"
}
]
},
"map": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
2023-11-28 22:54:17 +00:00
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "="
},
{
"type": "SYMBOL",
"name": "statement"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "STRING",
"value": "}"
}
]
},
"index": {
"type": "PREC_LEFT",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": ":"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ".."
},
{
"type": "SYMBOL",
"name": "expression"
}
]
},
{
"type": "BLANK"
}
]
}
]
}
},
"math": {
"type": "PREC_LEFT",
"value": 0,
"content": {
2023-11-30 16:05:09 +00:00
"type": "CHOICE",
"members": [
{
2023-11-30 16:05:09 +00:00
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "math_operator"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
},
{
2023-11-30 16:05:09 +00:00
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "math_operator"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": ")"
}
]
}
]
}
},
"math_operator": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "+"
},
{
"type": "STRING",
"value": "-"
},
{
"type": "STRING",
"value": "*"
},
{
"type": "STRING",
"value": "/"
},
{
"type": "STRING",
"value": "%"
}
]
},
"logic": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
2023-11-30 16:05:09 +00:00
"type": "CHOICE",
"members": [
{
2023-11-30 16:05:09 +00:00
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "logic_operator"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
},
{
2023-11-30 16:05:09 +00:00
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "logic_operator"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": ")"
}
]
}
]
}
},
"logic_operator": {
2023-12-02 03:54:25 +00:00
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "=="
},
{
"type": "STRING",
"value": "!="
},
{
"type": "STRING",
"value": "&&"
},
{
"type": "STRING",
"value": "||"
},
{
"type": "STRING",
"value": ">"
},
{
"type": "STRING",
"value": "<"
},
{
"type": "STRING",
"value": ">="
},
{
"type": "STRING",
"value": "<="
}
]
}
},
"assignment": {
"type": "SEQ",
"members": [
{
2023-11-30 14:30:25 +00:00
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "CHOICE",
"members": [
{
2023-11-30 14:30:25 +00:00
"type": "SYMBOL",
"name": "type_definition"
},
{
"type": "BLANK"
}
]
},
{
2023-11-30 14:30:25 +00:00
"type": "SYMBOL",
"name": "assignment_operator"
},
{
2023-11-30 14:30:25 +00:00
"type": "SYMBOL",
"name": "statement"
}
]
},
"index_assignment": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "index"
},
{
"type": "SYMBOL",
"name": "assignment_operator"
},
{
"type": "SYMBOL",
"name": "statement"
}
]
},
"assignment_operator": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "+="
},
{
"type": "STRING",
"value": "-="
}
]
}
},
"if_else": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "if"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "else_if"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "else"
},
{
"type": "BLANK"
}
]
}
]
}
},
"if": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "if"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"else_if": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "else if"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"else": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "else"
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"match": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "match"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT1",
"content": {
"type": "SEQ",
"members": [
{
2023-12-11 15:18:46 +00:00
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "*"
}
]
},
{
"type": "STRING",
"value": "=>"
},
{
"type": "SYMBOL",
"name": "statement"
2023-12-11 15:18:46 +00:00
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "STRING",
"value": "}"
}
]
}
},
"while": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "while"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"for": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "for"
},
{
"type": "STRING",
"value": "async for"
}
]
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "in"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"return": {
2023-12-02 03:54:25 +00:00
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "return"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
}
},
2023-11-30 00:23:42 +00:00
"type_definition": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "<"
},
{
2023-11-30 00:23:42 +00:00
"type": "SYMBOL",
"name": "type"
},
{
"type": "STRING",
"value": ">"
}
]
},
2023-11-30 00:23:42 +00:00
"type": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "any"
},
{
"type": "STRING",
"value": "bool"
},
2023-11-30 14:30:25 +00:00
{
"type": "STRING",
"value": "float"
},
2023-11-30 00:23:42 +00:00
{
"type": "SEQ",
"members": [
{
"type": "STRING",
2023-12-05 21:42:11 +00:00
"value": "("
2023-11-30 00:23:42 +00:00
},
{
"type": "REPEAT",
"content": {
2023-11-30 01:59:58 +00:00
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "type"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
2023-11-30 00:23:42 +00:00
}
},
2023-12-05 21:42:11 +00:00
{
"type": "STRING",
"value": ")"
},
2023-11-30 00:23:42 +00:00
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "->"
},
{
"type": "SYMBOL",
"name": "type"
}
]
},
{
"type": "BLANK"
}
]
}
]
},
{
"type": "STRING",
"value": "int"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
2023-11-30 14:48:56 +00:00
"value": "["
2023-11-30 00:23:42 +00:00
},
{
"type": "SYMBOL",
"name": "type"
2023-11-30 14:48:56 +00:00
},
{
"type": "STRING",
"value": "]"
2023-11-30 00:23:42 +00:00
}
]
},
{
"type": "STRING",
"value": "map"
},
{
"type": "STRING",
"value": "num"
},
{
"type": "STRING",
"value": "str"
}
]
}
},
2023-12-02 03:54:25 +00:00
"function": {
2023-11-30 14:30:25 +00:00
"type": "SEQ",
"members": [
{
2023-12-05 21:42:11 +00:00
"type": "STRING",
2023-12-12 23:21:16 +00:00
"value": "("
2023-11-30 14:30:25 +00:00
},
{
2023-12-05 21:42:11 +00:00
"type": "STRING",
2023-12-12 23:21:16 +00:00
"value": "fn"
2023-12-05 21:42:11 +00:00
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
2023-12-12 23:21:16 +00:00
{
"type": "SYMBOL",
"name": "type_definition"
},
2023-12-05 21:42:11 +00:00
{
"type": "CHOICE",
2023-11-30 00:23:42 +00:00
"members": [
{
2023-12-05 21:42:11 +00:00
"type": "STRING",
"value": ","
2023-11-30 00:23:42 +00:00
},
{
2023-12-05 21:42:11 +00:00
"type": "BLANK"
2023-11-30 00:23:42 +00:00
}
]
}
2023-12-05 21:42:11 +00:00
]
}
},
{
"type": "STRING",
2023-12-12 23:21:16 +00:00
"value": ")"
},
{
"type": "SYMBOL",
"name": "type_definition"
2023-12-05 21:42:11 +00:00
},
{
"type": "SYMBOL",
"name": "block"
}
]
},
"function_call": {
"type": "PREC_RIGHT",
2023-11-30 16:05:09 +00:00
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
2023-12-02 07:34:23 +00:00
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression_list"
},
{
"type": "BLANK"
}
]
},
{
2023-11-28 22:54:17 +00:00
"type": "STRING",
"value": ")"
}
]
}
},
"yield": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "->"
},
{
"type": "STRING",
"value": "("
},
2023-11-28 22:54:17 +00:00
{
"type": "SYMBOL",
2023-12-02 07:34:23 +00:00
"name": "expression"
2023-11-28 22:54:17 +00:00
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
2023-11-28 22:54:17 +00:00
"name": "_expression_list"
},
{
2023-11-28 22:54:17 +00:00
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ")"
}
]
}
2023-12-11 16:17:37 +00:00
},
"built_in_function": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "assert"
},
{
"type": "STRING",
"value": "assert_equal"
},
{
"type": "STRING",
"value": "bash"
},
{
"type": "STRING",
"value": "download"
},
{
"type": "STRING",
"value": "fish"
},
{
"type": "STRING",
"value": "length"
},
{
"type": "STRING",
"value": "metadata"
},
{
"type": "STRING",
"value": "output"
},
{
"type": "STRING",
"value": "output_error"
},
{
"type": "STRING",
"value": "random"
},
{
"type": "STRING",
"value": "random_boolean"
},
{
"type": "STRING",
"value": "random_float"
},
{
"type": "STRING",
"value": "random_integer"
}
]
}
},
"extras": [
{
"type": "PATTERN",
"value": "\\s"
},
{
"type": "SYMBOL",
"name": "_comment"
}
],
"conflicts": [],
"precedences": [],
"externals": [],
"inline": [],
"supertypes": []
}