# RSL Language Examples

## Package Examples

```rsl
// Basic
Package MyApp

// Qualified name
Package com.example.healthcare

// With imports
Package com.example.frontend
Import com.example.backend.UserService
Import com.example.common.*

// With TestSuite
Package com.tests
Import com.app.MainSystem
TestSuite Tests : Application [
    systemUnderTest MainSystem
]
```

## System Examples

```rsl
// Minimal
System MinimalSys : Business
System Simple_ "With Alias" : Application

// Basic types with description
System BizSystem : Business [
    description "Business system"
]

System AppSystem : Application [
    description "Application system"
]

System SoftSys : SoftwareSystem [
    description "Software system"
]

System HardSys : HardwareSystem [
    description "Hardware system"
]

System OtherSys : Other [
    description "Generic system"
]

// Type with SubType (all Application subtypes)
System WebApp : Application:Application_Web
System MobileApp : Application:Application_Mobile
System DesktopApp : Application:Application_Desktop
System SensorApp : Application:Application_Sensor
System ActuatorApp : Application:Application_Actuator
System OtherApp : Application:Application_Other

// Type with SubType (all SoftwareSystem subtypes)
System OS : SoftwareSystem:SoftwareSystem_OS
System VM : SoftwareSystem:SoftwareSystem_VM
System DBMS : SoftwareSystem:SoftwareSystem_DBMS
System WebServer : SoftwareSystem:SoftwareSystem_WebServer
System WebClient : SoftwareSystem:SoftwareSystem_WebClient
System EmailServer : SoftwareSystem:SoftwareSystem_EmailServer
System EmailClient : SoftwareSystem:SoftwareSystem_EmailClient
System OfficeTool : SoftwareSystem:SoftwareSystem_OfficeTool
System OtherServer : SoftwareSystem:SoftwareSystem_OtherServer
System OtherClient : SoftwareSystem:SoftwareSystem_OtherClient
System OtherSoft : SoftwareSystem:SoftwareSystem_Other

// Type with SubType (all HardwareSystem subtypes)
System Server : HardwareSystem:HardwareSystem_Server
System Desktop : HardwareSystem:HardwareSystem_Desktop
System Laptop : HardwareSystem:HardwareSystem_Laptop
System Smartphone : HardwareSystem:HardwareSystem_Smartphone
System Smartwatch : HardwareSystem:HardwareSystem_Smartwatch
System Sensor : HardwareSystem:HardwareSystem_Sensor
System Actuator : HardwareSystem:HardwareSystem_Actuator
System Storage : HardwareSystem:HardwareSystem_Storage
System Printer : HardwareSystem:HardwareSystem_Printer
System Network : HardwareSystem:HardwareSystem_Network
System OtherHard : HardwareSystem:HardwareSystem_Other

// Type with SubType (Business subtypes)
System PublicSector : Business:Business_PublicSector
System ITDept : Business:Business_IT
System OtherBiz : Business:Business_Other

// Flags (mutually exclusive)
System ReusableSys : Application [
    isReusable
]

System FinalSys : Application [
    isFinal
]

// Metadata
System WithVendor : Application [
    vendor "Acme Corp"
]

System WithVersion : Application [
    version "1.2.3"
]

System WithTags : Application [
    tag(name "env" value "prod")
    tag(name "region" value "us-east")
]

// Complete example
System FullSystem "Complete Example" : Application:Application_Web [
    isReusable
    vendor "Tech Inc"
    version "2.0.1"
    tag(name "tier" value "critical")
    tag(name "compliance" value "SOC2")
    description "Fully specified system with all options"
]
```

---

## LinguisticLanguage Examples

```rsl
// Basic language definitions
LinguisticLanguage EN : English
LinguisticLanguage ES : Spanish
LinguisticLanguage DE : German
LinguisticLanguage FR_ : French
LinguisticLanguage IT_ : Italian
LinguisticLanguage PT : Portuguese
LinguisticLanguage JA : Japanese

// With alias
LinguisticLanguage English_ "en-US" : English

// With description
LinguisticLanguage MainLanguage : English [
    description "Primary language for requirements"
]

// Complete example
LinguisticLanguage ProjectLanguage "English-US" : English [
    description "Main language used for project documentation and requirements"
]
```

---

## LinguisticFragment Examples

```rsl
// Simple word fragment
LinguisticFragment ActionVerb ("create")
LinguisticFragment ActionVerb ("create", "add", "update", "delete", "manage")

// Part-of-speech fragment
LinguisticFragment VerbPhrase (Verb)
LinguisticFragment NounPhrase (Noun)
LinguisticFragment AdjectivePhrase (Adjective)

// Multiple parts combined
LinguisticFragment Article (Determiner, "a", "an", "the")
LinguisticFragment Preposition (Adposition, "to", "from", "with", "by")

// Element property reference
LinguisticFragment ActorRef (Actor.name)
LinguisticFragment EntityRef (DataEntity.name)

// Mixed fragment types
LinguisticFragment VerbAction (Verb, "create", "manage", "process")
LinguisticFragment NounObject (Noun, ProperNoun, DataEntity.name)

// Fragment referencing other fragments
LinguisticFragment CommonVerbs ("create", "update", "delete")
LinguisticFragment ExtendedVerbs (CommonVerbs, "manage", "process")

// Complex fragments with descriptions
LinguisticFragment CRUDVerbs ("create", "read", "update", "delete") 
    description "Standard CRUD operation verbs"

LinguisticFragment SystemActors (Actor.name, Stakeholder.name) 
    description "References to system actors and stakeholders"

// All part-of-speech types
LinguisticFragment AllPOS (
    Adjective, Adposition, Adverb, Auxiliary,
    CoordinatingConjunction, Determiner, Interjection,
    Noun, Numeral, Particle, Pronoun, ProperNoun,
    Punctuation, SubordinatingConjunction, Symbol, Verb, Other
)
```

---

## LinguisticRule Examples

```rsl
// Basic rule - UseCase name must start with verb
LinguisticRule UCNameStartsWithVerb : Syntax [
    property UseCase.name
    pattern Verb
    severity Error
]

// Rule with description
LinguisticRule UCNamePattern : Syntax [
    property UseCase.name
    pattern Verb + Noun
    severity Warning
    description "Use case name should start with verb followed by noun"
]

// Multiple pattern parts
LinguisticRule UCNameFullPattern : Syntax [
    property UseCase.name
    pattern Verb + Determiner + Noun
    severity Error
    description "Use case name: verb + article + noun (e.g., 'Create a Customer')"
]

// Pattern with alternatives (|)
LinguisticRule UCNameWithArticle : Syntax [
    property UseCase.name
    pattern Verb + ("a" | "an" | "the") + Noun
    severity Warning
]

// Using fragments
LinguisticFragment CRUDVerbs ("create", "read", "update", "delete")
LinguisticRule UCUseCRUDVerb : Semantics [
    property UseCase.name
    pattern CRUDVerbs + Noun
    severity Warning
    description "Use standard CRUD verbs in use case names"
]

// Multiple alternatives
LinguisticRule GoalStartsRight : Syntax [
    property Goal.name
    pattern (Verb | "to" | "To") + Verb
    severity Error
]

// Complex pattern with mixed elements
LinguisticRule FRDescription : Syntax [
    property FR.description
    pattern Determiner + Noun + Verb + (Noun | ProperNoun)
    severity Warning
    description "Functional requirement description format"
]

// Using element references
LinguisticRule UCReferencesActor : Semantics [
    property UseCase.description
    pattern Actor.name + Verb + DataEntity.name
    severity Warning
]

// All rule types
LinguisticRule MorphologyRule : Morphology [
    property UserStory.name
    pattern Noun + Verb
    severity Warning
]

LinguisticRule SyntaxRule : Syntax [
    property UseCase.name
    pattern Verb + Noun
    severity Error
]

LinguisticRule SemanticsRule : Semantics [
    property FR.description
    pattern Verb + DataEntity.name
    severity Warning
]

// Different severity levels
LinguisticRule CriticalPattern : Syntax [
    property UseCase.name
    pattern Verb
    severity Error
]

LinguisticRule SuggestedPattern : Syntax [
    property UseCase.description
    pattern Determiner + Noun
    severity Warning
]

// Different properties
LinguisticRule CheckID : Syntax [
    property UseCase.id
    pattern (Verb | Noun)
    severity Warning
]

LinguisticRule CheckName : Syntax [
    property UseCase.name
    pattern Verb + Noun
    severity Error
]

LinguisticRule CheckDescription : Semantics [
    property UseCase.description
    pattern Determiner + Noun + Verb
    severity Warning
]

// Complex real-world examples
LinguisticFragment SystemVerbs ("create", "update", "delete", "manage", "process", "validate")
LinguisticFragment BusinessNouns ("customer", "order", "product", "invoice", "payment")

LinguisticRule UseCaseNaming "Use Case Naming Convention" : Syntax [
    property UseCase.name
    pattern SystemVerbs + (Determiner | Noun) + BusinessNouns
    severity Error
    description "Use cases must follow: [action verb] + [article/noun] + [business noun]"
]

LinguisticRule StakeholderDescription : Semantics [
    property Stakeholder.description
    pattern Adjective + Noun + Verb + DataEntity.name
    severity Warning
    description "Stakeholder descriptions should include attributes and data interactions"
]

// Combining multiple fragment references
LinguisticFragment Articles ("a", "an", "the")
LinguisticFragment Actions ("create", "manage", "delete")
LinguisticFragment Objects (Noun, DataEntity.name)

LinguisticRule ComplexUCPattern : Syntax [
    property UseCase.name
    pattern Actions + Articles + Objects
    severity Warning
    description "Standard use case pattern with fragments"
]

// Pattern with long chains
LinguisticRule DetailedFR : Syntax [
    property FR.description
    pattern Determiner + Adjective + Noun + Verb + Adverb + Verb + Noun
    severity Warning
    description "Detailed functional requirement pattern"
]

// Alternatives at multiple positions
LinguisticRule FlexiblePattern : Syntax [
    property UseCase.name  
    pattern (Verb | "Process" | "Handle") + (Determiner | Adjective) + (Noun | DataEntity.name)
    severity Warning
]
```

---

## Stakeholder Examples

```rsl
// Minimal
Stakeholder stk_CEO : Organization
Stakeholder stk_ITDept : OrganizationalUnit
Stakeholder stk_EndUser : Person

// Basic types
Stakeholder stk_Company : Organization [
    description "The company organization"
]

Stakeholder stk_TechTeam : OrganizationalUnit [
    description "Technical team"
]

Stakeholder stk_Customer : Person [
    description "End customer user"
]

Stakeholder stk_PaymentSystem : System [
    description "External payment system"
]

Stakeholder stk_OtherEntity : Other [
    description "Other stakeholder type"
]

// With subtypes - Organization
Stakeholder stk_Owner : Organization:Organization_Owner
Stakeholder stk_ClientOrg : Organization:Organization_Customer
Stakeholder stk_Sponsor : Organization:Organization_Sponsor
Stakeholder stk_PartnerOrg : Organization:Organization_Partner
Stakeholder stk_GovEntity : Organization:Organization_Government
Stakeholder stk_Regulator : Organization:Organization_RegulatorAgent

// With subtypes - OrganizationalUnit
Stakeholder stk_ITUnit : OrganizationalUnit:OrganizationalUnit_IT
Stakeholder stk_OpsUnit : OrganizationalUnit:OrganizationalUnit_Operations
Stakeholder stk_SupportUnit : OrganizationalUnit:OrganizationalUnit_Support
Stakeholder stk_OtherUnit : OrganizationalUnit:OrganizationalUnit_Other

// With subtypes - Person (detailed)
Stakeholder stk_AppUser : Person:Person_User
Stakeholder stk_ProjectMgr : Person:Person_Manager_ProjectManager
Stakeholder stk_TeamLead : Person:Person_Manager_TeamManager
Stakeholder stk_FuncMgr : Person:Person_Manager_FunctionalManager
Stakeholder stk_BA : Person:Person_Technical_BusinessAnalyst
Stakeholder stk_RE : Person:Person_Technical_RequirementsEngineer
Stakeholder stk_Trainer : Person:Person_Technical_Trainer
Stakeholder stk_Trainee : Person:Person_Technical_Trainee
Stakeholder stk_Architect : Person:Person_Technical_SoftwareArchitect
Stakeholder stk_Developer : Person:Person_Technical_SoftwareDeveloper
Stakeholder stk_Designer : Person:Person_Technical_SoftwareDesigner
Stakeholder stk_Tester : Person:Person_Technical_SoftwareTester

// With subtypes - System
Stakeholder stk_InternalSys : System:System_Internal
Stakeholder stk_ExternalSys : System:System_External
Stakeholder stk_OtherSys : System:System_Other

// With alias
Stakeholder stk_Admin "System Administrator" : Person:Person_User

// With isA (inheritance)
Stakeholder stk_BaseUser : Person
Stakeholder stk_SpecialUser : Person [
    isA stk_BaseUser
]

// With partOf (mandatory)
Stakeholder stk_ParentOrg : Organization
Stakeholder stk_ChildDept : OrganizationalUnit [
    partOf mandatory stk_ParentOrg
]

// With partOf (optional)
Stakeholder stk_OptionalDept : OrganizationalUnit [
    partOf optional stk_ParentOrg
]

// With tags
Stakeholder stk_TaggedUser : Person [
    tag(name "level" value "senior")
    tag(name "clearance" value "high")
]

// Complete example
Stakeholder stk_Developer : Person:Person_Technical_SoftwareDeveloper
Stakeholder stk_ITUnit : OrganizationalUnit:OrganizationalUnit_IT
Stakeholder stk_CompleteStakeholder "Senior Developer" : Person:Person_Technical_SoftwareDeveloper [
    isA stk_Developer
    partOf mandatory stk_ITUnit
    tag(name "experience" value "5+ years")
    tag(name "role" value "backend")
    description "Senior backend developer with 5+ years experience"
]
```

---

## Actor Examples

```rsl
// Minimal
Actor a_SimpleUser : User
Actor a_ExtSys : ExternalSystem
Actor a_OtherActor : Other

// With alias
Actor a_Admin "Administrator" : User

// With description
Actor a_Customer : User [
    description "Customer using the system"
]

// With isA inheritance
Actor a_BaseUser : User
Actor a_PowerUser : User [
    isA a_BaseUser
]

// With stakeholder reference
Stakeholder stk_EndUserStakeholder : Person
Actor a_SystemUser : User [
    stakeholder stk_EndUserStakeholder
]

// With tags
Actor a_MobileUser : User [
    tag(name "platform" value "mobile")
    tag(name "version" value "iOS")
]

// Complete example
Stakeholder stk_AdminStakeholder : Person:Person_User
Actor a_BaseUser : User
Actor a_Administrator "System Admin" : User [
    isA a_BaseUser
    stakeholder stk_AdminStakeholder
    tag(name "access-level" value "full")
    tag(name "department" value "IT")
    description "System administrator with full access"
]

// External system actor
Actor a_PaymentGateway : ExternalSystem [
    description "External payment processing system"
]

// Extended type
ActorType CustomActorType
Actor a_SpecialActor : CustomActorType
```

---

## DataEntity Examples

```rsl
// Minimal
DataEntity e_Customer : Master
DataEntity e_Order : Transaction
DataEntity e_Country : Reference

// Basic types
DataEntity e_Config : Parameter
DataEntity e_Product : Master
DataEntity e_Invoice : Document
DataEntity e_Sale : Transaction
DataEntity e_Other : Other

// With subtypes
DataEntity e_RegularEntity : Master:Regular
DataEntity e_WeakEntity : Master:Weak
DataEntity e_OtherSubEntity : Master:Other

// With alias
DataEntity e_User "System User" : Master

// With isA inheritance
DataEntity e_Person : Master
DataEntity e_Employee : Master [
    isA e_Person
]

// With attributes
DataEntity e_SimpleEntity : Master [
    attribute id_ : Integer
    attribute name : String
    attribute active : Boolean
]

// Attributes with sizes
DataEntity e_Product : Master [
    attribute code : String(50)
    attribute description_ : Text(500)
    attribute price : Decimal(10.2)
]

// Attributes with aliases
DataEntity e_Customer : Master [
    attribute customerId "Customer ID" : Integer
    attribute fullName "Full Name" : String(100)
]

// Attributes with all options
DataEntity e_FullEntity : Master [
    attribute id_ : Integer [defaultValue " 0" helpMessage "Unique identifier" description "Primary key identifier"]
    attribute name_ : String(100) [defaultValue "Unnamed" values "Option1, Option2, Option3" visualization "TextBox" helpMessage "Enter the name" description "Entity name"]
]

// Attributes with constraints
DataEntity e_ConstrainedEntity : Master [
    attribute id_ : Integer [ constraints(PrimaryKey NotNull Unique)]
    attribute email : Email [constraints(NotNull Unique)]
    attribute count : Integer [constraints(multiplicity "1" NotNull)]
]

// Attribute with ForeignKey
DataEntity e_Customer : Master
DataEntity e_Order : Transaction [
    attribute orderId : Integer [constraints(PrimaryKey)]
    attribute customerId : Integer [constraints(ForeignKey(e_Customer))]
]

// ForeignKey with options
DataEntity e_Product : Master [
    attribute name_ : String(50)
]
DataEntity e_OrderItem : Transaction [
    attribute productId : Integer [constraints(ForeignKey(e_Product toField productId showAsField e_Product.name_ defaultValue " 0" onDelete CASCADE))]
]

// Attribute with ManyToMany
DataEntity e_Course : Master [
    attribute courseId : Integer [constraints(PrimaryKey)]
    attribute title : String(100)
]
DataEntity e_Enrollment : Transaction [
    attribute studentId : Integer
    attribute courseId : Integer
]
DataEntity e_Student : Master [
    attribute studentId : Integer [constraints(PrimaryKey)]
    attribute name_ : String(100)
    attribute courses : Integer [constraints(ManyToMany(e_Course throughEntity e_Enrollment throughSourceField studentId throughTargetField e_Course.courseId))]
]

// Attribute with derived value
DataEntity e_Invoice : Document [
    attribute total : Decimal [constraints(Derived("sum of line items"))]
]

// Attribute with multiple constraint flags
DataEntity e_SecureData : Master [
    attribute sensitiveField : String [constraints(NotNull ReadOnly NotVisible Encrypted)]
]

// Attribute with Check constraint
DataEntity e_Product : Master [
    attribute price : Decimal [constraints(Check(PricePositive "price > 0") Check(PriceReasonable "price < 1000000"))]
]

// Attribute with DataEnumeration
DataEnumeration enum_Status values(Active, Inactive, Pending)
DataEntity e_Task : Transaction [
    attribute status_ : DataEnumeration enum_Status
]

// Entity constraints
DataEntity e_ReadOnlyEntity : Master [
    attribute id_ : Integer
    attribute data : String
    constraints(ReadOnly)
]

DataEntity e_EncryptedEntity : Master [
    attribute secrets : String
    constraints(Encrypted)
]

DataEntity e_EntityWithShowAs : Master [
    attribute id_ : Integer
    attribute displayName : String
    constraints(showAs(displayName))
]

// Entity with multiple constraints
DataEntity e_ComplexEntity : Master [
    attribute id_ : Integer
    attribute name_ : String
    attribute status_ : String
    constraints(ReadOnly Encrypted showAs(name_) Check(ValidStatus "status in ('Active', 'Inactive')"))
]

// Complete entity example
DataEnumeration enum_CustomerStatus values(
    Active "Customer Active",
    Inactive "Customer Inactive",
    Suspended "Customer Suspended"
)
DataEntity e_Person : Master
DataEntity e_CompleteEntity "Full Customer Record" : Master:Regular [
    isA e_Person
    attribute customerId : Integer [constraints(PrimaryKey NotNull) description "Unique customer identifier"]
    attribute email : Email [helpMessage "Customer email address" constraints(NotNull Unique) description "Primary email for communication"]
    attribute status_ : DataEnumeration enum_CustomerStatus
    attribute lastOrderDate : Date [constraints(ReadOnly) description "Date of last order"]
    constraints(Encrypted showAs(email))
    tag(name "table" value "customers")
    tag(name "schema" value "public")
    description "Complete customer master data entity"
]

// Extended types
DataEntityType CustomEntityType
DataEntity e_ExtendedTypeEntity : CustomEntityType

DataEntityType BaseType
DataEntitySubType CustomSubType
DataEntity e_WithCustomSubType : BaseType:CustomSubType
```

---

## DataEntityCluster Examples

```rsl
// Minimal (requires main entity)
DataEntity e_Customer : Master
DataEntityCluster ec_CustomerCluster : Master [
    main e_Customer
]

// All cluster types
DataEntity e_Customer : Master
DataEntityCluster ec_ParamCluster : Parameter [
    main e_Customer
]

DataEntityCluster ec_RefCluster : Reference [
    main e_Customer
]

DataEntityCluster ec_MasterCluster : Master [
    main e_Customer
]

DataEntityCluster ec_DocCluster : Document [
    main e_Customer
]

DataEntityCluster ec_TransCluster : Transaction [
    main e_Customer
]

DataEntityCluster ec_OtherCluster : Other [
    main e_Customer
]

// With alias
DataEntity e_Order : Transaction
DataEntityCluster ec_OrderCluster "Order Processing Cluster" : Transaction [
    main e_Order
]

// With children
DataEntity e_Order : Transaction
DataEntity e_OrderItem : Transaction
DataEntity e_Payment : Transaction

DataEntityCluster ec_OrderProcessing : Transaction [
    main e_Order
    child e_OrderItem
    child e_Payment
]

// Children with uses
DataEntity e_Order : Transaction
DataEntity e_OrderItem : Transaction
DataEntity e_Payment : Transaction
DataEntity e_Product : Master
DataEntity e_Customer : Master

DataEntityCluster ec_OrderFull : Transaction [
    main e_Order
    child e_OrderItem [uses e_Product]
    child e_Payment [uses e_Customer]
]

// With uses at cluster level
DataEntity e_Vendor : Master
DataEntity e_Category : Reference
DataEntity e_ProductVariant : Other
DataEntity e_Product : Master

DataEntityCluster ec_ProductCluster : Master [
    main e_Product
    child e_ProductVariant
    uses e_Vendor, e_Category
]

// With tags
DataEntity e_Customer : Master
DataEntityCluster ec_TaggedCluster : Master [
    main e_Customer
    tag(name "module" value "CRM")
    tag(name "priority" value "high")
]

// Complete example
DataEntity e_CustomerEntity : Master
DataEntity e_AddressEntity : Master
DataEntity e_ContactEntity : Master
DataEntity e_PreferenceEntity : Reference
DataEntity e_RegionEntity : Reference

DataEntityCluster ec_CompleteCustomerCluster "Customer Management Cluster" : Master [
    main e_CustomerEntity
    child e_AddressEntity [uses e_RegionEntity]
    child e_ContactEntity
    child e_PreferenceEntity
    uses e_RegionEntity
    tag(name "domain" value "customer")
    tag(name "bounded-context" value "CRM")
    description "Complete customer cluster with addresses, contacts, and preferences"
]

// Extended type
DataEntity e_Customer : Master
DataEntityClusterType CustomClusterType
DataEntityCluster ec_CustomCluster : CustomClusterType [
    main e_Customer
]
```

---

## DataEnumeration Examples

```rsl
// Minimal
DataEnumeration enum_Status values(Active, Inactive)

// Multiple values
DataEnumeration enum_Priority values(Low_, Medium_, High_, Critical)

// With aliases
DataEnumeration enum_OrderStatus values(
    Pending "Order Pending",
    Processing "In Processing",
    Shipped "Shipped",
    Delivered "Delivered",
    Cancelled "Cancelled"
)

// With cluster alias
DataEnumeration enum_PaymentMethod "Payment Methods" values(
    CreditCard,
    DebitCard,
    PayPal,
    BankTransfer,
    Cash
)

// With description
DataEnumeration enum_CustomerType values(Individual, Business_, Government) [
    description "Types of customers in the system"
]

// With tags
DataEnumeration enum_Region values(North, South, East, West) [
    tag(name "category" value "geographic")
    tag(name "version" value "1.0")
]

// Complete example
DataEnumeration enum_AccountStatus "Account Status Types" values(
    Active "Active Account",
    Suspended "Temporarily Suspended",
    Closed_ "Permanently Closed",
    PendingActivation "Pending Activation",
    PendingClosure "Pending Closure"
) [
    tag(name "domain" value "account-management")
    tag(name "usage" value "critical")
    description "All possible account status values in the system"
]

// Used in DataEntity
DataEnumeration enum_UserRole values(Admin, Editor, Viewer)
DataEntity e_User : Master [
    attribute role : DataEnumeration enum_UserRole
]
```

---

## Data Examples

```rsl
// Minimal (requires DataEntity type reference)
DataEntity e_Product : Master
Data d_ProductData : e_Product

// With alias
Data d_CustomerData "Customer Test Data" : e_Customer

// Simple data with description
Data d_TestUsers : e_User [
    description "Test user data for development"
]

// With tags
Data d_SeedData : e_Product [
    tag(name "environment" value "test")
    tag(name "auto-load" value "true")
]

// Data with table (requires attributes in entity)
DataEntity e_Customer : Master [
    attribute id_ : Integer
    attribute name_ : String
    attribute active : Boolean
]

Data d_CustomerRecords : e_Customer := [
    [id_, name_, active]
    [1, "John Doe", True]
    [2, "Jane Smith", True]
    [3, "Bob Wilson", False]
]

// Data table with different types
DataEntity e_Order : Transaction [
    attribute orderId : Integer
    attribute orderDate : Date
    attribute total : Decimal
]

Data d_OrderData : e_Order := [
    [orderId, orderDate, total]
    [100, 2024-01-15, 99.99]
    [101, 2024-01-16, 149.50]
    [102, 2024-01-17, 75.25]
]

// Data table with datetime
DataEntity e_Event : Transaction [
    attribute eventId : Integer
    attribute timestamp : Datetime
    attribute description_ : String
]

Data d_EventLog : e_Event := [
    [eventId, timestamp, description_]
    [1, "D2024-01-15T10:30:00", "User login"]
    [2, "D2024-01-15T10:35:45", "Data updated"]
    [3, "D2024-01-15T11:00:00", "User logout"]
]

// Complete example
DataEntity e_ProductCatalog : Master [
    attribute sku : String
    attribute productName : String
    attribute price : Decimal
    attribute inStock : Boolean
]

Data d_InitialProducts "Initial Product Catalog" : e_ProductCatalog := [
    [sku, productName, price, inStock]
    ["PROD-001", "Widget A", 29.99, True]
    ["PROD-002", "Widget B", 49.99, True]
    ["PROD-003", "Gadget X", 99.99, False]
    ["PROD-004", "Tool Z", 15.50, True]
] [
    tag(name "seed-data" value "true")
    tag(name "version" value "1.0")
    description "Initial product catalog for system setup"
]
```

---

## ActionType Examples

```rsl
// Original types (built-in CRUD actions)
ActionType aCreate
ActionType aRead
ActionType aUpdate
ActionType aDelete

// Minimal custom action
ActionType at_Submit

// With alias
ActionType at_Publish "PublishContent"

// With description
ActionType at_Validate [
    description "Validate data or business rules"
]

// Multiple custom actions for business operations
ActionType at_CreateOrder
ActionType at_CreateInvoice
ActionType at_CreatePayment

ActionType at_ReadOrder
ActionType at_ReadInventory
ActionType at_ReadCustomer

ActionType at_UpdateStatus
ActionType at_UpdatePrice
ActionType at_UpdateAddress

ActionType at_DeleteRecord
ActionType at_DeleteDraft
ActionType at_CancelOrder

// Complex business actions
ActionType at_Approve
ActionType at_Reject
ActionType at_ApplyDiscount
ActionType at_CalculateTax
ActionType at_ProcessPayment
ActionType at_NotifyUser
ActionType at_GenerateReport
ActionType at_ExportData

// With tags (single)
ActionType at_CriticalAction [
    tag(name "severity" value "high")
]

// With multiple tags
ActionType at_AuditedAction [
    tag(name "audit" value "required")
    tag(name "log-level" value "info")
    tag(name "domain" value "compliance")
]

// With description and tags
ActionType at_SensitiveOperation [
    tag(name "security" value "encrypted")
    tag(name "notification" value "admin")
    description "Operations on sensitive data require encryption and admin notification"
]

// Complete example
ActionType at_CompleteAction "Comprehensive Business Action" [
    tag(name "domain" value "commerce")
    tag(name "version" value "1.0")
    tag(name "criticality" value "high")
    tag(name "audit-required" value "true")
    description "Complete action specification with all options and metadata"
]

// Workflow-related actions
ActionType at_SubmitForApproval
ActionType at_ScheduleTask
ActionType at_ExecuteAsync
ActionType at_SendNotification
ActionType at_RollbackTransaction

// Data manipulation actions
ActionType at_MergeRecords
ActionType at_SplitRecord
ActionType at_ArchiveData
ActionType at_RestoreData
ActionType at_SetDefault

// System actions
ActionType at_SystemInitialize
ActionType at_SystemShutdown
ActionType at_SystemReset
ActionType at_SystemHealthCheck

// Security actions
ActionType at_AuthorizeUser
ActionType at_AuthenticateSession
ActionType at_RevokeAccess
ActionType at_AuditLog

// Extended type
ActionTypeType CustomActionCategory
ActionType at_CustomAction : CustomActionCategory
```

---

## Behavior Examples

```rsl
// StateMachine (complete lifecycle with transitions)

Package DocumentManager

System DocumentSystem "Document Manager" : Application [ isFinal ]

DataEntity e_Document : Document

Actor a_Author : User
Actor a_Reviewer : User
Actor a_Publisher : User

ActionType aCreate_
ActionType aSubmit
ActionType aAssign
ActionType aApproveFinal
ActionType aRejectFinal
ActionType aPublish
ActionType aRemove
ActionType aModify

UseCase uc_AddDraftDocument : EntityCreate [
    primaryActor a_Author
    actions aCreate_, aModify
]

UseCase uc_SubmitDocumentForReview : EntityUpdate [
    primaryActor a_Author
    actions aSubmit
]

UseCase uc_AssignReviewer : EntityUpdate [
    primaryActor a_Reviewer
    actions aAssign
]

UseCase uc_DecideFinalApproval : EntityUpdate [
    primaryActor a_Reviewer
    actions aApproveFinal, aRejectFinal
]

UseCase uc_PublishDocument : EntityUpdate [
    primaryActor a_Publisher
    actions aPublish
]

UseCase uc_RemoveDocument : EntityDelete [
    primaryActor a_Publisher
    actions aRemove
]

StateMachine stm_DocumentLifecycle "Document Lifecycle" : Simple [
    dataEntity e_Document
    description "Document lifecycle state machine"
    state Initial "Document lifecycle" isInitial :
        useCase uc_AddDraftDocument action aCreate_ 
            nextState Draft

    state Draft "Document in Draft" :
        useCase uc_SubmitDocumentForReview action aSubmit 
            nextState SubmittedForReview

    state SubmittedForReview "Awaiting reviewer assignment" :
        useCase uc_AssignReviewer action aAssign 
            nextState InReview

    state InReview "Under review by assigned reviewers" :
        useCase uc_DecideFinalApproval action aApproveFinal 
            nextState Approved
        useCase uc_DecideFinalApproval action aRejectFinal 
            nextState ReviewRejected

    state Approved "Approved, awaiting publication" :
        useCase uc_PublishDocument action aPublish 
            nextState Published

    state ReviewRejected "Rejected, returned to author" :
        useCase uc_AddDraftDocument action aModify 
            nextState Draft

    state Published "Available to users" isFinal :
        useCase uc_RemoveDocument action aRemove 
            nextState Eliminated

    state Eliminated "Inactive or archived" isFinal
]

// ActiveEvent examples
Stakeholder stk_Customer : Person
Stakeholder stk_PaymentGateway : System:System_External

Event ev_OrderPlaced : Send [
    participant stk_Customer
    description "Customer places an order"
]

Event ev_PaymentReceived : Receive [
    participant stk_PaymentGateway
    description "Payment confirmation received"
]

Event ev_TimeoutEvent : Timer [
    isCatch
    description "Timeout triggers escalation"
]

Event ev_CancelEvent : Cancel [
    isThrow
    description "User cancels the process"
]

Event ev_ErrorEvent : Error [
    description "Generic error event"
]

// ActiveTask examples
Stakeholder stk_Customer : Person
Stakeholder stk_PaymentGateway : System:System_External

Task t_ValidateOrder : User [
    participant stk_Customer
    description "User validates order details"
]

Task t_ApproveOrder : Manual [
    participant stk_Customer
    description "Manual approval task"
]

Task t_ChargePayment : Service [
    participant stk_PaymentGateway
    description "Service charges payment"
]

Task t_NotifyCustomer : Send [
    participant stk_Customer
    participantExternal stk_PaymentGateway
    description "Send notification to external system"
]

Task t_ReceiveConfirmation : Receive [
    participant stk_Customer
    participantExternal stk_PaymentGateway
    description "Receive confirmation from external system"
]

Task t_RunScript : Script [
    participant stk_Customer
    description "Execute automation script"
]

Task t_ApplyRules : BusinessRule [
    participant stk_Customer
    description "Apply business rules"
]

// ActiveFlow examples
Event ev_OrderPlaced : Send []
Event ev_PaymentReceived : Receive []

Task t_ValidateOrder : User []
Task t_ChargePayment : User []
Task t_ApproveOrder : User []
Task t_NotifyCustomer : User []
Task t_RunScript : User []
Task t_ApplyRules : User []

TaskFlow tf_OrderFlow : Sequence [
    activeElements ev_OrderPlaced, t_ValidateOrder, t_ChargePayment, ev_PaymentReceived
    description "Sequential order processing flow"
]

TaskFlow tf_ConditionalFlow : SequenceConditional [
    condition "paymentApproved == True"
    activeElements t_ApproveOrder, t_ChargePayment
    description "Conditional flow based on approval"
]

TaskFlow tf_ParallelFlow : Parallel [
    activeElements t_NotifyCustomer, t_RunScript, t_ApplyRules
    description "Parallel notification and processing"
]
```

---

## Requirements Examples (full specification)

```rsl
// Support elements
Package EcommerceShop

System EcommerceSystem "Ecommerce Shop" : Application [ isFinal ]

Stakeholder stk_BusinessOwner : Person:Person_Manager
Actor a_Customer : User
Actor a_SupportAgent : User
Actor a_PaymentSystem : ExternalSystem

ActionType aCreateOrder [ 
    description "Create a new order in the system"
]
ActionType aUpdateOrder [ 
    description "Update an existing order"
]
ActionType aShow [ 
    description "Display or retrieve information"
]

Event ev_CustomerRequest : Receive [
    participant stk_BusinessOwner
]

Event ev_PaymentTimeout : Timer

DataEntity e_Order : Transaction
DataEntity e_OrderItem : Transaction

// Goal examples
Goal g_OnlineOrdering : Functional [
    stakeholder stk_BusinessOwner
    priority High
    description "Enable online order creation"
]

Goal g_ResponseTime : Performance:Performance_SystemResponseTime [
    stakeholder stk_BusinessOwner
    priority Medium
    description "System responds quickly to user actions"
]

// FR examples
FR fr_CreateOrder : Functional [
    stakeholder stk_BusinessOwner
    acceptanceCriteria ac_CreateOrder : Valid [
        rule "Order is created for valid cart"
    ]
    priority High
    description "System shall create an order from a valid cart"
]

// QR examples
QR qr_ResponseTime : Performance:Performance_SystemResponseTime [
    expression [ <= 2 Time_Sec ]
    stakeholder stk_BusinessOwner
    priority High
    description "Page response time shall be <= 2 seconds"
]

// Constraint examples
Constraint c_DataRetention : Legal:Legal_National [
    stakeholder stk_BusinessOwner
    description "Customer data must be retained for 5 years"
]

// UserStory examples
UserStory us_SubmitOrder : UserStory [
    stakeholder stk_BusinessOwner
    asA a_Customer
    iWant "submit an order"
    soThat "I can purchase items"
    acceptanceCriteria ac_SubmitOrder : Valid [
        scenario "Submit order" given "cart is valid" when "user submits" then "order is created"
    ]
    priority High
    description "User can submit a purchase order"
]

// UseCase examples (complete)
// ============================================================
// IMPORTANT: UseCase Element Ordering (PRECONDITIONS FIRST)
// ============================================================
// UseCase syntax order (as per RSL grammar):
//   precondition (1st - comes BEFORE actions)
//   postcondition (2nd - comes BEFORE actions)
//   actions (3rd)
//   extensionPoints, includes, extends, acceptanceCriteria, etc.
//
// CORRECT ORDER examples below:
// ============================================================

// Simple example: precondition, postcondition, actions
UseCase uc_SimpleExample : EntityRead [
    primaryActor a_Customer
    precondition "User is logged in"
    postcondition "Data is displayed"
    actions aShow
]

// Medium example: explicit ordering
UseCase uc_CheckInventory : EntitiesSearch [
    primaryActor a_SupportAgent
    dataEntity e_OrderItem
    precondition "Order exists"
    postcondition "Inventory status is returned"
    actions aShow
    description "Check inventory availability"
]

// Complete example: showing full order
UseCase uc_CalculateTax : EntityRead [
    primaryActor a_SupportAgent
    precondition "Order items are selected"
    postcondition "Tax amount is calculated and stored"
    actions aShow, aUpdateOrder
    description "Calculate taxes for the order"
]

UseCase uc_ApplyDiscount : EntityUpdate [
    primaryActor a_SupportAgent
    precondition "Order is not finalized"
    postcondition "Discount is applied to order"
    actions aUpdateOrder
    description "Apply discount to the order"
]

UseCase uc_SubmitOrder "Submit Order" : EntityCreate [
    stakeholder stk_BusinessOwner
    primaryActor a_Customer
    supportingActors a_SupportAgent, a_PaymentSystem
    triggeredBy ev_CustomerRequest
    dataEntity e_Order
    // PRECONDITIONS AND POSTCONDITIONS COME FIRST (before actions)
    precondition "Customer is authenticated"
    postcondition "Order is created and stored"
    // THEN actions
    actions aCreateOrder, aUpdateOrder
    // Then other properties
    extensionPoints ep_Discount ["Apply discount"], ep_FraudCheck ["Manual fraud review"]
    includes uc_CheckInventory, uc_CalculateTax
    extends uc_ApplyDiscount onExtensionPoint ep_Discount
    acceptanceCriteria ac_SubmitOrderValidation : Valid [
        rule "Order is created after successful validation"
    ]
    acceptanceCriteria ac_SubmitOrderSuccess : Valid [
        scenario "Order accepted" given "payment is approved" when "order is submitted" then "confirmation is displayed"
    ]
    priority High
    tag(name "domain" value "commerce")
    tag(name "criticality" value "high")
    description "User submits an order for processing"
    mainScenario ms_SubmitOrderHappy(Main) "Happy path" [
        description "Standard order submission flow"
        s1(Actor:OpenApp) "Open app" actor a_Customer
        s2(Actor:ClickOnButton) "Checkout" actor a_Customer
        s3(System:Display) "Show order summary"
        s4(Actor:Write) "Enter shipping details" actor a_Customer
        s5(System:Validate) "Validate order" [
            scenario scn_AltInvalidCart(Alternative) "Cart invalid" [
                description "Cart validation fails"
                s5a(System:Display) "Show validation errors"
                s5b(Actor:Write) "Fix cart issues" actor a_Customer nextStep s5
            ]
        ]
        s6(System:Execute) "Calculate totals"
        s7(System:Execute) "Create order" [
            scenario scn_ExPaymentTimeout(Exception) "Payment timeout" [
                description "Payment gateway timeout"
                s7a(Event:Timer) "Wait for payment response" event ev_PaymentTimeout
                s7b(System:Display) "Show timeout message"
                s7c(Actor:ClickOnButton) "Retry payment" actor a_Customer nextStep s7
            ]
            scenario scn_AltPaymentDeclined(Alternative) "Payment declined" [
                description "Payment rejected by gateway"
                s7d(System:Display) "Show payment declined"
                s7e(Actor:Write) "Enter new payment method" actor a_Customer nextStep s7
            ]
        ]
        s8(System:Display) "Show confirmation"
        s9(Event:Receive) "Order confirmation" event ev_CustomerRequest
    ]
]
```
