1
0
dust/tree-sitter-dust/src/grammar.json
2023-10-21 16:38:20 -04:00

1193 lines
23 KiB
JSON

{
"name": "dust",
"word": "identifier",
"rules": {
"root": {
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "item"
}
},
"item": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "statement"
}
}
},
"statement": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "SYMBOL",
"name": "assignment"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "if_else"
},
{
"type": "SYMBOL",
"name": "insert"
},
{
"type": "SYMBOL",
"name": "select"
},
{
"type": "SYMBOL",
"name": "while"
},
{
"type": "SYMBOL",
"name": "async"
},
{
"type": "SYMBOL",
"name": "for"
},
{
"type": "SYMBOL",
"name": "transform"
},
{
"type": "SYMBOL",
"name": "filter"
},
{
"type": "SYMBOL",
"name": "find"
},
{
"type": "SYMBOL",
"name": "remove"
}
]
},
"comment": {
"type": "SEQ",
"members": [
{
"type": "PATTERN",
"value": "[#]+.*"
}
]
},
"expression": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_expression_kind"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "_expression_kind"
},
{
"type": "STRING",
"value": ")"
}
]
}
]
},
"_expression_kind": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "value"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "function_call"
},
{
"type": "SYMBOL",
"name": "tool"
},
{
"type": "SYMBOL",
"name": "math"
},
{
"type": "SYMBOL",
"name": "logic"
}
]
}
},
"identifier": {
"type": "PATTERN",
"value": "[a-z|_|.]+[0-9]?"
},
"value": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "integer"
},
{
"type": "SYMBOL",
"name": "float"
},
{
"type": "SYMBOL",
"name": "string"
},
{
"type": "SYMBOL",
"name": "boolean"
},
{
"type": "SYMBOL",
"name": "list"
},
{
"type": "SYMBOL",
"name": "function"
},
{
"type": "SYMBOL",
"name": "table"
},
{
"type": "SYMBOL",
"name": "map"
}
]
},
"integer": {
"type": "PATTERN",
"value": "[-]?[0-9]+"
},
"float": {
"type": "PATTERN",
"value": "[-]?[0-9]+[.]{1}[0-9]*"
},
"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": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "STRING",
"value": "]"
}
]
},
"function": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "function"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "<"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "STRING",
"value": ">"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "item"
},
{
"type": "STRING",
"value": "}"
}
]
},
"table": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "table"
},
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "<"
},
{
"type": "REPEAT1",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "STRING",
"value": ">"
}
]
},
{
"type": "SYMBOL",
"name": "expression"
}
]
}
},
"map": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "="
},
{
"type": "SYMBOL",
"name": "expression"
}
]
}
},
{
"type": "STRING",
"value": "}"
}
]
},
"math": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "math_operator"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
}
},
"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": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "SYMBOL",
"name": "logic_operator"
},
{
"type": "SYMBOL",
"name": "expression"
}
]
}
},
"logic_operator": {
"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": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "assignment_operator"
},
{
"type": "SYMBOL",
"name": "statement"
}
]
}
},
"assignment_operator": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "="
},
{
"type": "STRING",
"value": "+="
},
{
"type": "STRING",
"value": "-="
}
]
},
"if_else": {
"type": "PREC_LEFT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "if"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "else_if"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "else"
}
]
},
{
"type": "BLANK"
}
]
}
]
}
},
"if": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "if"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "statement"
},
{
"type": "STRING",
"value": "}"
}
]
},
"else_if": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "else if"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "statement"
},
{
"type": "STRING",
"value": "}"
}
]
},
"else": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "else"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "statement"
},
{
"type": "STRING",
"value": "}"
}
]
},
"function_call": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "STRING",
"value": ")"
}
]
}
},
"while": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "while"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "item"
},
{
"type": "STRING",
"value": "}"
}
]
},
"for": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "for"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "in"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "item"
},
{
"type": "STRING",
"value": "}"
}
]
},
"transform": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "transform"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "in"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "item"
},
{
"type": "STRING",
"value": "}"
}
]
},
"filter": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "filter"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "in"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "item"
},
{
"type": "STRING",
"value": "}"
}
]
},
"find": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "find"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "in"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "item"
},
{
"type": "STRING",
"value": "}"
}
]
},
"remove": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "remove"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "STRING",
"value": "in"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "item"
},
{
"type": "STRING",
"value": "}"
}
]
},
"select": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "select"
},
{
"type": "STRING",
"value": "<"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "STRING",
"value": ">"
},
{
"type": "STRING",
"value": "from"
},
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "{"
},
{
"type": "SYMBOL",
"name": "item"
},
{
"type": "STRING",
"value": "}"
}
]
},
{
"type": "BLANK"
}
]
}
]
}
},
"insert": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "insert"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "list"
}
},
{
"type": "STRING",
"value": "into"
},
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "where"
},
{
"type": "SYMBOL",
"name": "logic"
}
]
},
{
"type": "BLANK"
}
]
}
]
}
},
"async": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "async"
},
{
"type": "STRING",
"value": "{"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "statement"
}
},
{
"type": "STRING",
"value": "}"
}
]
},
"tool": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "SYMBOL",
"name": "_tool_kind"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "STRING",
"value": ")"
}
]
}
},
"_tool_kind": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "assert"
},
{
"type": "STRING",
"value": "assert_equal"
},
{
"type": "STRING",
"value": "help"
},
{
"type": "STRING",
"value": "length"
},
{
"type": "STRING",
"value": "output"
},
{
"type": "STRING",
"value": "output_error"
},
{
"type": "STRING",
"value": "append"
},
{
"type": "STRING",
"value": "metadata"
},
{
"type": "STRING",
"value": "move"
},
{
"type": "STRING",
"value": "read"
},
{
"type": "STRING",
"value": "remove"
},
{
"type": "STRING",
"value": "trash"
},
{
"type": "STRING",
"value": "write"
},
{
"type": "STRING",
"value": "from_json"
},
{
"type": "STRING",
"value": "to_json"
},
{
"type": "STRING",
"value": "to_string"
},
{
"type": "STRING",
"value": "bash"
},
{
"type": "STRING",
"value": "fish"
},
{
"type": "STRING",
"value": "raw"
},
{
"type": "STRING",
"value": "sh"
},
{
"type": "STRING",
"value": "zsh"
}
]
}
},
"extras": [
{
"type": "PATTERN",
"value": "\\s"
}
],
"conflicts": [],
"precedences": [],
"externals": [],
"inline": [],
"supertypes": []
}