feat(grammar): update tree-sitter grammar to v0.3.0

Updated tree-sitter grammar to match v0.3.0 LALRPOP parser:

Grammar updates:
- Schedule: block-based syntax with extends, override, recurrence
- Life arc: requires clause for field validation
- Template: uses behaviors/schedules syntax
- Behavior: correct keywords (choose/then/repeat with optional params)
- Type system: concept_comparison with any/is_condition
- Removed concept semicolon requirement

Query file updates:
- highlights.scm: updated node names to *_declaration
- outline.scm: updated for new declaration node names
- indents.scm: updated node names, removed concept semicolon

Corpus test updates:
- Created schedules.txt with v0.3.0 syntax tests
- Created highlights.txt for highlighting tests
- Updated type_system.txt for v0.3.0 type syntax
- Updated behaviors.txt for correct expression wrapping
- Updated declarations.txt to use correct node names
- Updated basic.txt to use character_declaration/character_body
- Deleted obsolete v0.2.0 syntax tests

Integration tests:
- Added tree_sitter_integration.rs test suite
- Fixed test_any_type to use correct v0.3.0 syntax
- Fixed test_tree_sitter_grammar_builds to use generate command
This commit is contained in:
2026-02-14 17:43:26 +00:00
parent 0c4994acd2
commit e6d297420c
15 changed files with 10449 additions and 7068 deletions

View File

@@ -10,9 +10,9 @@ character Alice {
(source_file
(declaration
(character
(character_declaration
name: (identifier)
body: (block
body: (character_body
(field
name: (dotted_path (identifier))
value: (value (integer)))))))
@@ -47,9 +47,9 @@ character Bob {
(source_file
(declaration
(character
(character_declaration
name: (identifier)
body: (block
body: (character_body
(field
(prose_block
marker: (prose_marker)

View File

@@ -1,29 +1,11 @@
==================
Simple Behavior
Basic behavior tree
==================
behavior SimpleBehavior {
walk_around
}
---
(source_file
(declaration
(behavior
name: (identifier)
root: (behavior_node
(action_node (identifier))))))
==================
Selector Behavior
==================
behavior SelectorBehavior {
? {
try_option_a
try_option_b
fallback
behavior BasicNeeds {
then {
CheckHunger
if(hungry) { EatFood }
}
}
@@ -31,23 +13,33 @@ behavior SelectorBehavior {
(source_file
(declaration
(behavior
(behavior_declaration
name: (identifier)
root: (behavior_node
(selector_node
(behavior_node (action_node (identifier)))
(behavior_node (action_node (identifier)))
(behavior_node (action_node (identifier))))))))
body: (behavior_body
root: (behavior_node
(sequence_node
(behavior_node
(action_node
(identifier)))
(behavior_node
(if_decorator_node
condition: (expression
(primary_expression
(path
(path_segments
(identifier)))))
child: (behavior_node
(action_node
(identifier)))))))))))
==================
Sequence Behavior
Behavior with selector
==================
behavior SequenceBehavior {
> {
check_energy
move_to_location
perform_action
behavior Combat {
choose {
if(has_weapon) { Attack }
Flee
}
}
@@ -55,25 +47,32 @@ behavior SequenceBehavior {
(source_file
(declaration
(behavior
(behavior_declaration
name: (identifier)
root: (behavior_node
(sequence_node
(behavior_node (action_node (identifier)))
(behavior_node (action_node (identifier)))
(behavior_node (action_node (identifier))))))))
body: (behavior_body
root: (behavior_node
(selector_node
(behavior_node
(if_decorator_node
condition: (expression
(primary_expression
(path
(path_segments
(identifier)))))
child: (behavior_node
(action_node
(identifier)))))
(behavior_node
(action_node
(identifier)))))))))
==================
Nested Behavior
Behavior with repeat
==================
behavior NestedBehavior {
> {
? {
check_condition_a
check_condition_b
}
perform_action
behavior Patrol {
repeat(5) {
WalkPath
}
}
@@ -81,100 +80,12 @@ behavior NestedBehavior {
(source_file
(declaration
(behavior
(behavior_declaration
name: (identifier)
root: (behavior_node
(sequence_node
(behavior_node
(selector_node
(behavior_node (action_node (identifier)))
(behavior_node (action_node (identifier)))))
(behavior_node (action_node (identifier))))))))
==================
Repeat Behavior
==================
behavior RepeatBehavior {
* {
patrol
}
}
---
(source_file
(declaration
(behavior
name: (identifier)
root: (behavior_node
(repeat_node
(behavior_node (action_node (identifier))))))))
==================
Behavior with Subtree
==================
behavior WithSubtree {
> {
@helpers::check_preconditions
main_action
}
}
---
(source_file
(declaration
(behavior
name: (identifier)
root: (behavior_node
(sequence_node
(behavior_node
(subtree_node
(path
(path_segments
(identifier)
(identifier)))))
(behavior_node (action_node (identifier))))))))
==================
Complex Nested Behavior
==================
behavior ComplexBehavior {
? {
> {
check_threat
flee_to_safety
}
> {
check_resources
gather_resources
}
* {
idle
}
}
}
---
(source_file
(declaration
(behavior
name: (identifier)
root: (behavior_node
(selector_node
(behavior_node
(sequence_node
(behavior_node (action_node (identifier)))
(behavior_node (action_node (identifier)))))
(behavior_node
(sequence_node
(behavior_node (action_node (identifier)))
(behavior_node (action_node (identifier)))))
(behavior_node
(repeat_node
(behavior_node (action_node (identifier))))))))))
body: (behavior_body
root: (behavior_node
(repeat_node
params: (integer)
child: (behavior_node
(action_node
(identifier)))))))))

View File

@@ -67,11 +67,11 @@ character Alice: Human from Curious {
(source_file
(declaration
(character
(character_declaration
name: (identifier)
species: (identifier)
template: (template_clause (identifier))
body: (block
body: (character_body
(field
name: (dotted_path (identifier))
value: (value (integer)))
@@ -110,16 +110,17 @@ template BaseCharacter strict {
(source_file
(declaration
(template
(template_declaration
name: (identifier)
(include (identifier))
(include (identifier))
(field
name: (dotted_path (identifier))
value: (value (integer)))
(field
name: (dotted_path (identifier))
value: (value (string))))))
body: (template_body
(include (identifier))
(include (identifier))
(field
name: (dotted_path (identifier))
value: (value (integer)))
(field
name: (dotted_path (identifier))
value: (value (string)))))))
==================
Life arc with states and transitions
@@ -150,7 +151,7 @@ life_arc Journey {
(source_file
(declaration
(life_arc
(life_arc_declaration
name: (identifier)
(field
(prose_block
@@ -158,115 +159,32 @@ life_arc Journey {
tag: (identifier)
content: (prose_content)
end: (prose_marker)))
(arc_state
(state_block
name: (identifier)
(on_enter
(block
(field
name: (dotted_path (identifier))
value: (value (integer)))))
(transition
condition: (expression
(comparison
(expression (primary_expression (path (path_segments (identifier)))))
(expression (primary_expression (integer)))))
target: (identifier)))
(arc_state
body: (state_body
(on_enter
(block
(field
name: (dotted_path (identifier))
value: (value (integer)))))
(transition
condition: (expression
(comparison
(expression (primary_expression (path (path_segments (identifier)))))
(expression (primary_expression (integer)))))
target: (identifier))))
(state_block
name: (identifier)
(transition
condition: (expression
(comparison
(expression (primary_expression (path (path_segments (identifier)))))
(expression (primary_expression (boolean)))))
target: (identifier)))
(arc_state
name: (identifier)))))
==================
Schedule with time blocks
==================
schedule DailyRoutine {
08:00 -> 09:00: breakfast {
location: kitchen
}
09:00 -> 12:00: work {
duration: 3h
}
}
---
(source_file
(declaration
(schedule
name: (identifier)
(schedule_block
start: (time)
end: (time)
activity: (identifier)
(block
(field
name: (dotted_path (identifier))
value: (value (path (path_segments (identifier)))))))
(schedule_block
start: (time)
end: (time)
activity: (identifier)
(block
(field
name: (dotted_path (identifier))
value: (value (duration))))))))
==================
Behavior tree - all node types
==================
behavior GuardBehavior {
? {
patrol
> {
detect_threat
alert(priority: high, "Guard duty")
}
* {
watch
}
@base::behaviors::Idle
}
}
---
(source_file
(declaration
(behavior
name: (identifier)
root: (behavior_node
(selector_node
(behavior_node (action_node (identifier)))
(behavior_node
(sequence_node
(behavior_node (action_node (identifier)))
(behavior_node
(action_node
(identifier)
(action_param
(dotted_path (identifier))
(value (path (path_segments (identifier)))))
(action_param
(value (string)))))))
(behavior_node
(repeat_node
(behavior_node (action_node (identifier)))))
(behavior_node
(subtree_node
(path
(path_segments
(identifier)
(identifier)
(identifier))))))))))
body: (state_body
(transition
condition: (expression
(comparison
(expression (primary_expression (path (path_segments (identifier)))))
(expression (primary_expression (boolean)))))
target: (identifier))))
(state_block
name: (identifier)
body: (state_body)))))
==================
Institution
@@ -281,9 +199,9 @@ institution Wonderland {
(source_file
(declaration
(institution
(institution_declaration
name: (identifier)
(block
body: (block
(field
name: (dotted_path (identifier))
value: (value (string)))
@@ -291,44 +209,6 @@ institution Wonderland {
name: (dotted_path (identifier))
value: (value (string)))))))
==================
Relationship with participants
==================
relationship Friendship {
Alice {
bond_strength: 5
}
WhiteRabbit as friend {
trust: 0.8
}
Caterpillar
}
---
(source_file
(declaration
(relationship
name: (identifier)
(participant
(path (path_segments (identifier)))
(block
(field
name: (dotted_path (identifier))
value: (value (integer)))))
(participant
(path (path_segments (identifier)))
(identifier)
(block
(field
name: (dotted_path (identifier))
value: (value (float)))))
(participant
(path (path_segments (identifier)))))))
==================
Location
==================
@@ -342,9 +222,9 @@ location TeaParty {
(source_file
(declaration
(location
(location_declaration
name: (identifier)
(block
body: (block
(field
name: (dotted_path (identifier))
value: (value (string)))
@@ -367,15 +247,16 @@ species Cat {
(source_file
(declaration
(species
(species_declaration
name: (identifier)
(include (identifier))
(field
name: (dotted_path (identifier))
value: (value (boolean)))
(field
name: (dotted_path (identifier))
value: (value (integer))))))
body: (species_body
(include (identifier))
(species_field
name: (identifier)
value: (boolean))
(species_field
name: (identifier)
value: (integer))))))
==================
Enum declaration
@@ -413,9 +294,9 @@ character SpecialAlice {
(source_file
(declaration
(character
(character_declaration
name: (identifier)
body: (block
body: (character_body
(field
name: (dotted_path (identifier))
value: (value
@@ -452,49 +333,52 @@ life_arc ComplexLogic {
(source_file
(declaration
(life_arc
(life_arc_declaration
name: (identifier)
(arc_state
(state_block
name: (identifier)
(transition
condition: (expression
(and_expression
(expression
(comparison
(expression
(field_access
(expression (primary_expression))
(identifier)))
(expression (primary_expression (integer)))))
(expression
(comparison
(expression
(field_access
(expression (primary_expression))
(identifier)))
(expression (primary_expression (float)))))))
target: (identifier))
(transition
condition: (expression
(or_expression
(expression
(not_expression
(expression
(field_access
(expression (primary_expression))
(identifier)))))
(expression
(comparison
(expression
(field_access
(expression (primary_expression))
(identifier)))
(expression (primary_expression (boolean)))))))
target: (identifier)))
(arc_state
name: (identifier))
(arc_state
name: (identifier)))))
body: (state_body
(transition
condition: (expression
(and_expression
(expression
(comparison
(expression
(field_access
(expression (primary_expression))
(identifier)))
(expression (primary_expression (integer)))))
(expression
(comparison
(expression
(field_access
(expression (primary_expression))
(identifier)))
(expression (primary_expression (float)))))))
target: (identifier))
(transition
condition: (expression
(or_expression
(expression
(not_expression
(expression
(field_access
(expression (primary_expression))
(identifier)))))
(expression
(comparison
(expression
(field_access
(expression (primary_expression))
(identifier)))
(expression (primary_expression (boolean)))))))
target: (identifier))))
(state_block
name: (identifier)
body: (state_body))
(state_block
name: (identifier)
body: (state_body)))))
==================
List and object values
@@ -513,9 +397,9 @@ character DataRich {
(source_file
(declaration
(character
(character_declaration
name: (identifier)
body: (block
body: (character_body
(field
name: (dotted_path (identifier))
value: (value
@@ -560,9 +444,9 @@ character Nested {
(source_file
(declaration
(character
(character_declaration
name: (identifier)
body: (block
body: (character_body
(field
name: (dotted_path
(identifier)

View File

@@ -0,0 +1,53 @@
==================
Keywords should highlight
==================
use schema::types;
character Alice from Person {
age: 25
}
---
(source_file
(declaration
(use_declaration
(path_segments
(identifier)
(identifier))))
(declaration
(character_declaration
name: (identifier)
template: (template_clause
(identifier))
body: (character_body
(field
name: (dotted_path
(identifier))
value: (value
(integer)))))))
==================
Any type in sub-concept
==================
sub_concept Field.Type {
name: "text",
value: 42
}
---
(source_file
(declaration
(sub_concept
parent: (identifier)
name: (identifier)
body: (sub_concept_record_body
(sub_concept_field
name: (identifier)
value: (string))
(sub_concept_field
name: (identifier)
value: (integer))))))

View File

@@ -0,0 +1,106 @@
==================
Basic schedule
==================
schedule WorkDay {
block morning {
08:00 -> 12:00
action: Work
}
}
---
(source_file
(declaration
(schedule_declaration
name: (identifier)
body: (schedule_body
(schedule_block
name: (identifier)
time_range: (time_range
start: (time)
end: (time))
(block_field
name: (identifier)
value: (identifier)))))))
==================
Schedule with extends
==================
schedule BakerDay extends WorkDay {
block early_prep {
05:00 -> 08:00
}
}
---
(source_file
(declaration
(schedule_declaration
name: (identifier)
extends: (identifier)
body: (schedule_body
(schedule_block
name: (identifier)
time_range: (time_range
start: (time)
end: (time)))))))
==================
Schedule with override
==================
schedule CustomDay extends BaseDay {
override work {
06:00 -> 14:00
intensity: "high"
}
}
---
(source_file
(declaration
(schedule_declaration
name: (identifier)
extends: (identifier)
body: (schedule_body
(override_block
name: (identifier)
time_range: (time_range
start: (time)
end: (time))
(block_field
name: (identifier)
value: (string)))))))
==================
Schedule with recurrence
==================
schedule WeeklySchedule {
recurrence MarketDay on Saturday {
block market {
06:00 -> 14:00
}
}
}
---
(source_file
(declaration
(schedule_declaration
name: (identifier)
body: (schedule_body
(recurrence_block
name: (identifier)
day: (identifier)
(schedule_block
name: (identifier)
time_range: (time_range
start: (time)
end: (time))))))))

View File

@@ -2,7 +2,7 @@
Concept declaration
==================
concept Cup;
concept BakedGood
---
@@ -12,34 +12,13 @@ concept Cup;
name: (identifier))))
==================
Multiple concept declarations
Sub-concept enum declaration
==================
concept Cup;
concept Customer;
concept Vendor;
---
(source_file
(declaration
(concept_declaration
name: (identifier)))
(declaration
(concept_declaration
name: (identifier)))
(declaration
(concept_declaration
name: (identifier))))
==================
Sub-concept - enum form
==================
sub_concept Cup.Size {
Small,
Medium,
Large
sub_concept BakedGood.Category {
Bread,
Pastry,
Cake
}
---
@@ -55,14 +34,12 @@ sub_concept Cup.Size {
(identifier)))))
==================
Sub-concept - record form with any
Sub-concept record declaration with values
==================
sub_concept Vendor.Inventory {
Bread: any,
Pastries: any,
Cakes: any,
Cup: any
sub_concept BakedGood.Quality {
freshness: 1.0,
taste: 0.8
}
---
@@ -75,51 +52,18 @@ sub_concept Vendor.Inventory {
body: (sub_concept_record_body
(sub_concept_field
name: (identifier)
type: (any_type))
value: (float))
(sub_concept_field
name: (identifier)
type: (any_type))
(sub_concept_field
name: (identifier)
type: (any_type))
(sub_concept_field
name: (identifier)
type: (any_type))))))
value: (float))))))
==================
Sub-concept - record form with typed fields
Concept comparison
==================
sub_concept Vendor.Inventory {
Bread: any,
Pastries: Number
}
---
(source_file
(declaration
(sub_concept
parent: (identifier)
name: (identifier)
body: (sub_concept_record_body
(sub_concept_field
name: (identifier)
type: (any_type))
(sub_concept_field
name: (identifier)
type: (identifier))))))
==================
Concept comparison with any conditions
==================
concept_comparison NotInterested {
NotInterested: {
Cup.Size: any,
Cup.Type: any,
Cup.Color: any
}
concept_comparison SkillLevel {
Apprentice: { freshness: any },
Master: { freshness: Tier is Master }
}
---
@@ -131,230 +75,58 @@ concept_comparison NotInterested {
(variant_pattern
name: (identifier)
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(any_type)))
name: (identifier)
condition: (any_type)))
(variant_pattern
name: (identifier)
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(any_type)))
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(any_type)))))))
name: (identifier)
condition: (is_condition
(is_value
field: (identifier)
value: (identifier))))))))
==================
Concept comparison with is conditions
Species declaration
==================
concept_comparison Interest {
Interested: {
Cup.Type: Cup.Type is Glass or Cup.Type is Plastic,
Cup.Color: Cup.Color is Red
}
species Human {
age: 25
energy: 0.75
}
---
(source_file
(declaration
(concept_comparison
(species_declaration
name: (identifier)
(variant_pattern
name: (identifier)
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(is_condition
(dotted_path
(identifier)
(identifier))
(identifier)
(dotted_path
(identifier)
(identifier))
(identifier))))
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(is_condition
(dotted_path
(identifier)
(identifier))
(identifier))))))))
body: (species_body
(species_field
name: (identifier)
value: (integer))
(species_field
name: (identifier)
value: (float))))))
==================
Concept comparison with multiple variants
==================
concept_comparison FoodQuality {
Excellent: {
Food.Freshness: Food.Freshness is Fresh
},
Poor: {
Food.Freshness: Food.Freshness is Stale or Food.Freshness is Spoiled
}
}
---
(source_file
(declaration
(concept_comparison
name: (identifier)
(variant_pattern
name: (identifier)
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(is_condition
(dotted_path
(identifier)
(identifier))
(identifier)))))
(variant_pattern
name: (identifier)
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(is_condition
(dotted_path
(identifier)
(identifier))
(identifier)
(dotted_path
(identifier)
(identifier))
(identifier))))))))
==================
Template with species extension
Template with species base
==================
template Person: Human {
age: 0..100
name: ""
name: "Unknown"
}
---
(source_file
(declaration
(template
(template_declaration
name: (identifier)
species: (identifier)
(field
name: (dotted_path (identifier))
value: (value (range (integer) (integer))))
(field
name: (dotted_path (identifier))
value: (value (string))))))
==================
Full type system example
==================
concept Cup;
sub_concept Cup.Size {
Small,
Medium,
Large
}
sub_concept Cup.Type {
Ceramic,
Glass,
Plastic
}
concept_comparison CupPreference {
Preferred: {
Cup.Size: any,
Cup.Type: Cup.Type is Glass or Cup.Type is Ceramic
},
Avoided: {
Cup.Size: any,
Cup.Type: Cup.Type is Plastic
}
}
---
(source_file
(declaration
(concept_declaration
name: (identifier)))
(declaration
(sub_concept
parent: (identifier)
name: (identifier)
body: (sub_concept_enum_body
(identifier)
(identifier)
(identifier))))
(declaration
(sub_concept
parent: (identifier)
name: (identifier)
body: (sub_concept_enum_body
(identifier)
(identifier)
(identifier))))
(declaration
(concept_comparison
name: (identifier)
(variant_pattern
name: (identifier)
(field_condition
sub_concept: (dotted_path
(identifier)
body: (template_body
(field
name: (dotted_path
(identifier))
condition: (condition_expr
(any_type)))
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(is_condition
(dotted_path
(identifier)
(identifier))
(identifier)
(dotted_path
(identifier)
(identifier))
(identifier)))))
(variant_pattern
name: (identifier)
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(any_type)))
(field_condition
sub_concept: (dotted_path
(identifier)
(identifier))
condition: (condition_expr
(is_condition
(dotted_path
(identifier)
(identifier))
(identifier))))))))
value: (value
(string)))))))