Files
storybook/tests/examples/logical_operators.sb
Sienna Meridian Satterwhite 9c20dd4092 feat: implement storybook DSL with template composition and validation
Add complete domain-specific language for authoring narrative content for
agent simulations.

Features:
- Complete parser using LALRPOP + logos lexer
- Template composition (includes + multiple inheritance)
- Strict mode validation for templates
- Reserved keyword protection
- Semantic validators (trait ranges, schedule overlaps, life arcs, behaviors)
- Name resolution and cross-reference tracking
- CLI tool (validate, inspect, query commands)
- Query API with filtering
- 260 comprehensive tests (unit, integration, property-based)

Implementation phases:
- Phase 1 (Parser): Complete
- Phase 2 (Resolution + Validation): Complete
- Phase 3 (Public API + CLI): Complete

BREAKING CHANGE: Initial implementation
2026-02-08 13:24:35 +00:00

96 lines
2.3 KiB
Plaintext

// Test logical operators in life arc transitions
life_arc ComplexConditions {
state monitoring {
// AND operator
on age > 18 and status is active -> adult_active
on energy > 0.5 and health > 80 -> healthy_energetic
// OR operator
on tired or hungry -> needs_rest
on age < 5 or age > 65 -> dependent
// NOT operator
on not ready -> waiting
on not completed -> in_progress
}
state adult_active {
on age < 18 or status is inactive -> monitoring
}
state healthy_energetic {
on energy < 0.3 or health < 50 -> monitoring
}
state needs_rest {
on not tired and not hungry -> monitoring
}
state dependent {
on age >= 5 and age <= 65 -> monitoring
}
state waiting {
on ready -> monitoring
}
state in_progress {
on completed -> monitoring
}
}
life_arc NestedLogic {
state checking {
// Complex nested conditions
on age > 18 and status is active and energy > 0.5 -> triple_and
on tired or hungry or sick -> any_problem
on not ready and not completed -> both_false
// Mixed operators
on age > 21 and status is verified or is_admin -> allowed
on health > 50 and not sick or emergency -> proceed
}
state triple_and {
on age < 18 or status is inactive or energy < 0.5 -> checking
}
state any_problem {
on not tired and not hungry and not sick -> checking
}
state both_false {
on ready or completed -> checking
}
state allowed {
on age < 21 and status is unverified and not is_admin -> checking
}
state proceed {
on health < 50 and sick and not emergency -> checking
}
}
life_arc BooleanLogic {
state idle {
// Boolean literals with operators
on enabled is true and paused is false -> running
on enabled is false or error is true -> stopped
on not initialized -> initializing
}
state running {
on enabled is false or paused is true -> idle
}
state stopped {
on enabled is true and error is false -> idle
}
state initializing {
on initialized -> idle
}
}