{
"$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
"name": "clispec",
"word": "identifier",
"rules": {
"source_file": {
"type": "SEQ",
"members": [
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_declaration"
}
}
]
},
"doc_comment": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "///"
},
{
"type": "PATTERN",
"value": ".*"
}
]
}
},
"line_comment": {
"type": "TOKEN",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "//"
},
{
"type": "PATTERN",
"value": ".*"
}
]
}
},
"identifier": {
"type": "PATTERN",
"value": "[a-zA-Z_][a-zA-Z0-9_]*"
},
"refinement_identifier": {
"type": "PATTERN",
"value": "@[a-zA-Z_][a-zA-Z0-9_]*"
},
"keyword_type": {
"type": "STRING",
"value": "type"
},
"keyword_opt": {
"type": "STRING",
"value": "opt"
},
"keyword_arg": {
"type": "STRING",
"value": "arg"
},
"keyword_cmd": {
"type": "STRING",
"value": "cmd"
},
"keyword_env": {
"type": "STRING",
"value": "env"
},
"keyword_requires": {
"type": "STRING",
"value": "requires"
},
"keyword_excludes": {
"type": "STRING",
"value": "excludes"
},
"keyword_ensures": {
"type": "STRING",
"value": "ensures"
},
"keyword_subcommands": {
"type": "STRING",
"value": "subcommands"
},
"operator_and": {
"type": "STRING",
"value": "&"
},
"operator_or": {
"type": "STRING",
"value": "|"
},
"open_paren": {
"type": "STRING",
"value": "("
},
"closed_paren": {
"type": "STRING",
"value": ")"
},
"open_bracket": {
"type": "STRING",
"value": "{"
},
"closed_bracket": {
"type": "STRING",
"value": "}"
},
"open_square": {
"type": "STRING",
"value": "["
},
"closed_square": {
"type": "STRING",
"value": "]"
},
"open_chevron": {
"type": "STRING",
"value": "<"
},
"closed_chevron": {
"type": "STRING",
"value": ">"
},
"comma": {
"type": "STRING",
"value": ","
},
"range": {
"type": "STRING",
"value": ".."
},
"_declaration": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "type_declaration"
},
{
"type": "SYMBOL",
"name": "opt_declaration"
},
{
"type": "SYMBOL",
"name": "arg_declaration"
},
{
"type": "SYMBOL",
"name": "cmd_declaration"
},
{
"type": "SYMBOL",
"name": "env_declaration"
},
{
"type": "SYMBOL",
"name": "doc_comment"
},
{
"type": "SYMBOL",
"name": "line_comment"
}
]
}
]
},
"declaration_block": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "open_bracket"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_declaration"
}
},
{
"type": "SYMBOL",
"name": "closed_bracket"
}
]
},
"_constraint_declaration": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "requires_clause"
},
{
"type": "SYMBOL",
"name": "excludes_clause"
},
{
"type": "SYMBOL",
"name": "ensures_clause"
},
{
"type": "SYMBOL",
"name": "subcommands_clause"
},
{
"type": "SYMBOL",
"name": "refinement_clause"
}
]
}
]
},
"constraint_block": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "open_square"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "_constraint_declaration"
}
},
{
"type": "SYMBOL",
"name": "closed_square"
}
]
},
"refinement_clause": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "refinement_identifier"
},
{
"type": "SYMBOL",
"name": "open_paren"
},
{
"type": "SYMBOL",
"name": "anonymous_list_expression"
},
{
"type": "SYMBOL",
"name": "closed_paren"
}
]
},
"named_identifier": {
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "[a-zA-Z][a-zA-Z0-9_]*"
}
},
"int_literal": {
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "-?\\d+"
}
},
"float_literal": {
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "-?\\d+\\.\\d+"
}
},
"string_literal": {
"type": "TOKEN",
"content": {
"type": "PATTERN",
"value": "\\\"(?:[^\\\"\\\\]|\\\\.)*\\\""
}
},
"bool_literal": {
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "true"
},
{
"type": "STRING",
"value": "false"
}
]
}
},
"fat_arrow": {
"type": "STRING",
"value": "=>"
},
"type_expression": {
"type": "CHOICE",
"members": [
{
"type": "PREC_LEFT",
"value": 1,
"content": {
"type": "SYMBOL",
"name": "named_identifier"
}
},
{
"type": "SYMBOL",
"name": "anonymous_enum_expression"
},
{
"type": "SYMBOL",
"name": "nested_type"
}
]
},
"nested_type": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "named_identifier"
},
{
"type": "SYMBOL",
"name": "open_chevron"
},
{
"type": "SYMBOL",
"name": "type_expression"
},
{
"type": "SYMBOL",
"name": "closed_chevron"
}
]
},
"_literals": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "int_literal"
},
{
"type": "SYMBOL",
"name": "float_literal"
},
{
"type": "SYMBOL",
"name": "string_literal"
},
{
"type": "SYMBOL",
"name": "bool_literal"
},
{
"type": "SYMBOL",
"name": "named_identifier"
}
]
},
"anonymous_enum_expression": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_literals"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "operator_or"
},
{
"type": "SYMBOL",
"name": "_literals"
}
]
}
}
]
},
"anonymous_list_expression": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_literals"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "comma"
},
{
"type": "SYMBOL",
"name": "_literals"
}
]
}
}
]
},
"identifier_with_list": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "named_identifier"
},
{
"type": "SYMBOL",
"name": "open_paren"
},
{
"type": "SYMBOL",
"name": "anonymous_list_expression"
},
{
"type": "SYMBOL",
"name": "closed_paren"
}
]
},
"type_declaration": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_type"
},
{
"type": "SYMBOL",
"name": "named_identifier"
},
{
"type": "SYMBOL",
"name": "fat_arrow"
},
{
"type": "SYMBOL",
"name": "type_expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "constraint_block"
},
{
"type": "BLANK"
}
]
}
]
},
"requires_clause": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_requires"
},
{
"type": "SYMBOL",
"name": "_boolean_expression"
}
]
},
"excludes_clause": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_excludes"
},
{
"type": "SYMBOL",
"name": "_boolean_expression"
}
]
},
"ensures_clause": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_ensures"
},
{
"type": "SYMBOL",
"name": "_boolean_expression"
}
]
},
"subcommands_clause": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_subcommands"
},
{
"type": "SYMBOL",
"name": "_boolean_expression"
}
]
},
"and_expression": {
"type": "PREC_LEFT",
"value": 2,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_boolean_expression"
},
{
"type": "SYMBOL",
"name": "operator_and"
},
{
"type": "SYMBOL",
"name": "_boolean_expression"
}
]
}
},
"or_expression": {
"type": "PREC_LEFT",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_boolean_expression"
},
{
"type": "SYMBOL",
"name": "operator_or"
},
{
"type": "SYMBOL",
"name": "_boolean_expression"
}
]
}
},
"paren_expression": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "open_paren"
},
{
"type": "SYMBOL",
"name": "_boolean_expression"
},
{
"type": "SYMBOL",
"name": "closed_paren"
}
]
},
"_boolean_expression": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "paren_expression"
},
{
"type": "SYMBOL",
"name": "named_identifier"
},
{
"type": "SYMBOL",
"name": "and_expression"
},
{
"type": "SYMBOL",
"name": "or_expression"
}
]
},
"opt_declaration": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_opt"
},
{
"type": "SYMBOL",
"name": "identifier_with_list"
},
{
"type": "SYMBOL",
"name": "fat_arrow"
},
{
"type": "SYMBOL",
"name": "type_expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "constraint_block"
},
{
"type": "BLANK"
}
]
}
]
},
"env_declaration": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_env"
},
{
"type": "SYMBOL",
"name": "identifier_with_list"
},
{
"type": "SYMBOL",
"name": "fat_arrow"
},
{
"type": "SYMBOL",
"name": "type_expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "constraint_block"
},
{
"type": "BLANK"
}
]
}
]
},
"arg_declaration": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_arg"
},
{
"type": "SYMBOL",
"name": "arg_unit"
},
{
"type": "SYMBOL",
"name": "fat_arrow"
},
{
"type": "SYMBOL",
"name": "type_expression"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "constraint_block"
},
{
"type": "BLANK"
}
]
}
]
},
"arg_unit": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "named_identifier"
},
{
"type": "SYMBOL",
"name": "open_paren"
},
{
"type": "SYMBOL",
"name": "range_unit"
},
{
"type": "SYMBOL",
"name": "closed_paren"
}
]
},
"range_unit": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_literals"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "range"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_literals"
},
{
"type": "BLANK"
}
]
}
]
},
"cmd_declaration": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "keyword_cmd"
},
{
"type": "SYMBOL",
"name": "identifier_with_list"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "constraint_block"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "declaration_block"
},
{
"type": "BLANK"
}
]
}
]
}
},
"extras": [
{
"type": "PATTERN",
"value": "\\s"
}
],
"conflicts": [],
"precedences": [],
"externals": [],
"inline": [],
"supertypes": [],
"reserved": {}
}