feat(type-system): implement concept_comparison with pattern matching
Added complete support for the new type system syntax including: - concept: Base type declarations - sub_concept: Enum and record sub-type definitions - concept_comparison: Compile-time pattern matching with conditional guards Parser changes: - Added VariantPattern, FieldCondition, and Condition AST nodes - Implemented "is" keyword for pattern matching (e.g., "CupType is Glass or CupType is Plastic") - Added Value::Any variant to support universal type matching - Disambiguated enum-like vs record-like sub_concept syntax LSP updates: - Added Value::Any match arms across code_actions, completion, hover, inlay_hints, and semantic_tokens - Type inference and formatting support for Any values Example fixes: - Fixed syntax error in baker-family behaviors (missing closing brace in nested if) - Removed deprecated core_enums.sb file
This commit is contained in:
@@ -1,145 +0,0 @@
|
||||
//! Core enumerations for Wonderland domain modeling
|
||||
|
||||
enum Size {
|
||||
Tiny, // 3 inches tall
|
||||
Small, // 1 foot tall
|
||||
Normal, // Human-sized
|
||||
Large, // 9 feet tall
|
||||
Huge // House-sized
|
||||
}
|
||||
|
||||
enum EmotionalState {
|
||||
Curious,
|
||||
Frightened,
|
||||
Confused,
|
||||
Brave,
|
||||
Angry,
|
||||
Melancholy,
|
||||
Amused
|
||||
}
|
||||
|
||||
enum CardSuit {
|
||||
Hearts,
|
||||
Diamonds,
|
||||
Clubs,
|
||||
Spades
|
||||
}
|
||||
|
||||
enum CardRank {
|
||||
two,
|
||||
three,
|
||||
four,
|
||||
five,
|
||||
six,
|
||||
seven,
|
||||
eight,
|
||||
nine,
|
||||
ten,
|
||||
knave,
|
||||
queen,
|
||||
king
|
||||
}
|
||||
|
||||
enum TimeState {
|
||||
normal,
|
||||
frozen,
|
||||
reversed,
|
||||
accelerated
|
||||
}
|
||||
|
||||
enum ManifestationLevel {
|
||||
invisible,
|
||||
fading_in,
|
||||
partial_grin,
|
||||
partial_body,
|
||||
mostly_visible,
|
||||
fully_visible,
|
||||
fading_out
|
||||
}
|
||||
|
||||
enum GovernmentType {
|
||||
monarchy,
|
||||
democracy,
|
||||
anarchy,
|
||||
tyranny,
|
||||
oligarchy
|
||||
}
|
||||
|
||||
enum GovernmentStyle {
|
||||
absolute_tyranny,
|
||||
benevolent_dictatorship,
|
||||
constitutional_monarchy,
|
||||
direct_democracy,
|
||||
representative_democracy,
|
||||
anarchist_collective
|
||||
}
|
||||
|
||||
enum HierarchyStyle {
|
||||
rigid,
|
||||
fluid,
|
||||
flat,
|
||||
nested,
|
||||
circular
|
||||
}
|
||||
|
||||
enum Temperament {
|
||||
volatile,
|
||||
calm,
|
||||
unpredictable,
|
||||
steady,
|
||||
chaotic
|
||||
}
|
||||
|
||||
enum Power {
|
||||
queen_only,
|
||||
king_only,
|
||||
shared,
|
||||
distributed,
|
||||
none
|
||||
}
|
||||
|
||||
enum JudicialPresumption {
|
||||
guilt,
|
||||
innocence,
|
||||
absurdity
|
||||
}
|
||||
|
||||
enum Sentence {
|
||||
beheading,
|
||||
banishment,
|
||||
imprisonment,
|
||||
fine,
|
||||
warning,
|
||||
pardon
|
||||
}
|
||||
|
||||
enum SeatRotation {
|
||||
clockwise,
|
||||
counterclockwise,
|
||||
random,
|
||||
none
|
||||
}
|
||||
|
||||
enum GatheringType {
|
||||
eternal_social_gathering,
|
||||
formal_ceremony,
|
||||
casual_meeting,
|
||||
spontaneous_assembly
|
||||
}
|
||||
|
||||
enum Purpose {
|
||||
tea_consumption,
|
||||
governance,
|
||||
entertainment,
|
||||
survival,
|
||||
chaos
|
||||
}
|
||||
|
||||
enum Enforcement {
|
||||
forbidden,
|
||||
discouraged,
|
||||
optional,
|
||||
encouraged,
|
||||
mandatory,
|
||||
required
|
||||
}
|
||||
@@ -29,7 +29,7 @@ behavior PrepKitchen {
|
||||
}
|
||||
|
||||
// type
|
||||
concept Vendor;
|
||||
concept Vendor
|
||||
|
||||
// type
|
||||
sub_concept VendorInventory {
|
||||
@@ -40,17 +40,17 @@ sub_concept VendorInventory {
|
||||
}
|
||||
|
||||
// type (but really just an enum lol)
|
||||
concept Cup;
|
||||
concept Cup
|
||||
|
||||
// enum
|
||||
sub_concept CupSize: {
|
||||
sub_concept CupSize {
|
||||
Small,
|
||||
Medium,
|
||||
Large
|
||||
}
|
||||
|
||||
// enum
|
||||
sub_concept CupType: {
|
||||
sub_concept CupType {
|
||||
Ceramic,
|
||||
Glass,
|
||||
Plastic
|
||||
@@ -83,7 +83,7 @@ concept_comparison CustomerInterestInCups {
|
||||
}
|
||||
|
||||
// type
|
||||
concept Plate;
|
||||
concept Plate
|
||||
|
||||
// enum
|
||||
sub_concept PlateColor {
|
||||
@@ -93,7 +93,7 @@ sub_concept PlateColor {
|
||||
}
|
||||
|
||||
// type
|
||||
concept Customer;
|
||||
concept Customer
|
||||
|
||||
// enum
|
||||
sub_concept CustomerInterest {
|
||||
@@ -113,9 +113,10 @@ behavior SellAtMarket {
|
||||
make_sale(Cup)
|
||||
}
|
||||
if(CustomerInterestInCups.Interested.CupSize is Small and CustomerInterestInCups.Interested.CupType is Ceramic and CustomerInterestInCups.Interested.CupColor is Green) {
|
||||
if (Plate.PlateColor is Blue or PlateColor is Green) {
|
||||
// variadic arguments
|
||||
make_sale(Cup, Plate)
|
||||
if (Plate.PlateColor is Blue or PlateColor is Green) {
|
||||
// variadic arguments
|
||||
make_sale(Cup, Plate)
|
||||
}
|
||||
}
|
||||
// or there can be generic fallthroughs too
|
||||
thank_customer
|
||||
@@ -144,7 +145,7 @@ behavior QuickPrep {
|
||||
}
|
||||
}
|
||||
|
||||
concept Hunger;
|
||||
concept Hunger
|
||||
|
||||
sub_concept HungerState {
|
||||
Hungry,
|
||||
|
||||
Reference in New Issue
Block a user