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:
2026-02-14 14:29:29 +00:00
parent 4ce325e4ac
commit c49b00a2dc
8 changed files with 7402 additions and 4648 deletions

View File

@@ -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": [],