feat(grammar): add type system nodes to tree-sitter
Added grammar rules for v0.3 type system declarations: - concept_declaration: semicolon-terminated base type - sub_concept: enum and record forms with dot notation - concept_comparison: nested pattern matching with variant_pattern - any_type: named node for the 'any' keyword - template species extension: optional ': Species' syntax Updated query files: - highlights.scm: new keywords and named field highlights - outline.scm: concept/sub_concept/concept_comparison in outline - indents.scm: indentation for new brace-delimited nodes Fixed pre-existing query issues: - Replaced invalid repeat_node reference with decorator_node - Removed invalid '?' punctuation reference Added comprehensive test corpus (type_system.txt) covering: - concept declaration (simple and multiple) - sub_concept enum and record forms - concept_comparison with any/is conditions - template with species extension - full combined example
This commit is contained in:
@@ -91,6 +91,18 @@
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "enum_declaration"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "concept_declaration"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "sub_concept"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "concept_comparison"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -350,6 +362,31 @@
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "species",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
@@ -1704,6 +1741,396 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"concept_declaration": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "concept"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "name",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ";"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sub_concept": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "sub_concept"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "parent",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "."
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "name",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "body",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "sub_concept_record_body"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "sub_concept_enum_body"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sub_concept_enum_body": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"sub_concept_record_body": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "sub_concept_field"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "sub_concept_field"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"sub_concept_field": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "name",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "type",
|
||||
"content": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "any_type"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"any_type": {
|
||||
"type": "STRING",
|
||||
"value": "any"
|
||||
},
|
||||
"concept_comparison": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "concept_comparison"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "name",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "variant_pattern"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "variant_pattern"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"variant_pattern": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "name",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "field_condition"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "field_condition"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"field_condition": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "sub_concept",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "dotted_path"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ":"
|
||||
},
|
||||
{
|
||||
"type": "FIELD",
|
||||
"name": "condition",
|
||||
"content": {
|
||||
"type": "SYMBOL",
|
||||
"name": "condition_expr"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"condition_expr": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "any_type"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "is_condition"
|
||||
}
|
||||
]
|
||||
},
|
||||
"is_condition": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "dotted_path"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "is"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "or"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "dotted_path"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "is"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "identifier"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"expression": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
@@ -1914,6 +2341,10 @@
|
||||
"conflicts": [
|
||||
[
|
||||
"path_segments"
|
||||
],
|
||||
[
|
||||
"sub_concept_enum_body",
|
||||
"sub_concept_record_body"
|
||||
]
|
||||
],
|
||||
"precedences": [],
|
||||
|
||||
@@ -269,6 +269,67 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "concept_comparison",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"name": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "variant_pattern",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "concept_declaration",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"name": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "condition_expr",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "any_type",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "is_condition",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "condition_node",
|
||||
"named": true,
|
||||
@@ -301,6 +362,14 @@
|
||||
"type": "character",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "concept_comparison",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "concept_declaration",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "enum_declaration",
|
||||
"named": true
|
||||
@@ -329,6 +398,10 @@
|
||||
"type": "species",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "sub_concept",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "template",
|
||||
"named": true
|
||||
@@ -531,6 +604,32 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "field_condition",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"condition": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "condition_expr",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"sub_concept": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "dotted_path",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "if_decorator_node",
|
||||
"named": true,
|
||||
@@ -598,6 +697,25 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "is_condition",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "dotted_path",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "life_arc",
|
||||
"named": true,
|
||||
@@ -1119,6 +1237,106 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "sub_concept",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"body": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "sub_concept_enum_body",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "sub_concept_record_body",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"parent": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "sub_concept_enum_body",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "sub_concept_field",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"name": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"type": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "any_type",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "sub_concept_record_body",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "sub_concept_field",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "subtree_node",
|
||||
"named": true,
|
||||
@@ -1147,6 +1365,16 @@
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"species": {
|
||||
"multiple": false,
|
||||
"required": false,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
@@ -1283,6 +1511,32 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "variant_pattern",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"name": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "field_condition",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "(",
|
||||
"named": false
|
||||
@@ -1355,6 +1609,10 @@
|
||||
"type": "and",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "any_type",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "append",
|
||||
"named": false
|
||||
@@ -1379,6 +1637,14 @@
|
||||
"type": "choose",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "concept",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "concept_comparison",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "cooldown",
|
||||
"named": false
|
||||
@@ -1515,6 +1781,10 @@
|
||||
"type": "string",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "sub_concept",
|
||||
"named": false
|
||||
},
|
||||
{
|
||||
"type": "succeed_always",
|
||||
"named": false
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user