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

@@ -18,6 +18,9 @@
"species"
"enum"
"state"
"concept"
"sub_concept"
"concept_comparison"
] @keyword.declaration
; Keywords - Control flow and modifiers
@@ -45,6 +48,7 @@
"remove"
"append"
"is"
"any"
] @keyword.special
; Boolean literals
@@ -74,9 +78,16 @@
(species name: (identifier) @type.species)
(enum_declaration name: (identifier) @type.enum)
(arc_state name: (identifier) @type.state)
(concept_declaration name: (identifier) @type.concept)
(sub_concept parent: (identifier) @type.concept)
(sub_concept name: (identifier) @type.sub_concept)
(concept_comparison name: (identifier) @type.concept_comparison)
(variant_pattern name: (identifier) @type.variant)
(template species: (identifier) @type.builtin)
; Field names
(field name: (dotted_path) @property)
(sub_concept_field name: (identifier) @property)
; Species reference
(character species: (identifier) @type.builtin)
@@ -124,14 +135,10 @@
"."
".."
"*"
"?"
"@"
] @punctuation.delimiter
; Behavior tree nodes
(selector_node "?" @keyword.behavior.selector)
(sequence_node ">" @keyword.behavior.sequence)
(repeat_node "*" @keyword.behavior.repeat)
(action_node (identifier) @function.action)
; Transitions

View File

@@ -38,8 +38,12 @@
(enum_declaration)
(selector_node)
(sequence_node)
(repeat_node)
(decorator_node)
(sub_concept)
(concept_comparison)
(variant_pattern)
] @indent.begin
; Dedent after semicolon at top level
(use_declaration ";" @indent.end)
(concept_declaration ";" @indent.end)

View File

@@ -55,3 +55,18 @@
(enum_declaration
name: (identifier) @name
) @symbol.enum
; Concepts
(concept_declaration
name: (identifier) @name
) @symbol.concept
; Sub-concepts
(sub_concept
name: (identifier) @name
) @symbol.sub_concept
; Concept comparisons
(concept_comparison
name: (identifier) @name
) @symbol.concept_comparison