You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reconciled EBNF grammar and language guide with current parser code.
Key changes:
- Removed statements: if, foreach, call, stop, focus, reply, return, read, write
- Added statements: when, match, let, prompt
- Added BAST import syntax
- Updated all examples to use new statement syntax
- Added documentation for new keywords: default, let, match, prompt
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This EBNF grammar provides a formal representation of the RIDDL language syntax. It's particularly useful for understanding the exact structure of each language element and how they relate to each other.
346
+
This EBNF grammar provides a formal representation of the RIDDL language syntax. It's particularly useful for understanding the exact structure of each language element and how they relate to each other.
3.**Place Functions Close to Usage**: Define functions within the entities that use them
565
-
4.**End Control Structures**: Always terminate control structures with `end` keyword
566
-
5.**Use Field References**: In foreach loops, use `foreach field X.items`
567
-
6.**Provide Default Actions**: Use `"nothing"` for empty else branches
575
+
4.**End When Statements**: Always terminate `when` statements with the`end` keyword
576
+
5.**Use Match for Multiple Conditions**: Prefer `match` over multiple `when` statements for readability
577
+
6.**Use Prompt for Complex Logic**: Use `prompt` to describe business logic for implementation
568
578
7.**Model Complete Flows**: Include UI components and user interactions
569
579
8.**Maintain Semantic Consistency**: Use the same field names for the same concepts
570
580
9.**Emit Events from Commands**: Ensure commands emit events to follow reactive principles
@@ -574,8 +584,8 @@ entity Product is {
574
584
575
585
## Common Syntax Issues
576
586
577
-
1. Don't use assignment operators (`=`); use `set field x to "value"`
578
-
2. Don't forget `end` after if statements and foreach loops
587
+
1. Don't use assignment operators (`=`) for fields; use `set field x to "value"` (but `let x = "value"` is valid for local bindings)
588
+
2. Don't forget `end` after `when` statements
579
589
3. Always include reference types before identifiers
580
590
4. Use proper syntax for function parameters and return values
581
591
5. Make sure all morph/tell statements have correct type references
@@ -584,6 +594,8 @@ entity Product is {
584
594
8. Never place entity, type, or repository definitions directly within a domain - they must be in a context
585
595
9. Never place definitions inside an author - authors only contain metadata
586
596
10. Make sure each context contains related definitions that form a bounded context
597
+
11. Use `when` for conditionals (not `if` which is no longer supported)
598
+
12. Use `prompt` for describing implementation logic (not bare quoted strings)
587
599
588
600
## Incomplete Definitions
589
601
@@ -650,8 +662,8 @@ From the formal grammar analysis, several important syntax points deserve specia
650
662
3.**Nested Element Validation**: Elements can only be nested within specific parent elements according to strict containment rules. For example, types must be defined within contexts, not directly within domains.
651
663
652
664
4.**Termination of Statements**: Control flow statements must be properly terminated:
653
-
-If statements must end with the `end` keyword
654
-
-Foreach loops must end with the `end` keyword
665
+
-`when` statements must end with the `end` keyword
666
+
-`match` statements are terminated by the closing brace
655
667
- Other statements are implicitly terminated
656
668
657
669
5.**Handler Clauses**: Handlers must use specific clause types:
@@ -663,3 +675,13 @@ From the formal grammar analysis, several important syntax points deserve specia
663
675
664
676
6.**Readability Words**: While readability words like `is`, `as`, `by`, etc. are often optional, their proper placement significantly improves model clarity. Use them consistently.
665
677
678
+
7.**New Statement Types** (as of January 2026):
679
+
-`when` replaces the former `if-then-else` statement
680
+
-`match` provides pattern matching for multiple conditions
681
+
-`let` creates local variable bindings
682
+
-`prompt` replaces bare quoted strings for describing implementation logic
683
+
684
+
8.**Removed Statements**: The following statements have been removed from the language:
0 commit comments