Rule grammar#
Rule grammar describes executable business rules with typed parameters, return types, and block bodies.
Source#
| Property | Value |
|---|---|
| Grammar file | packages/business/language/grammar/rule.g4 |
| Grammar name | rule |
| Grammar kind | parser |
| Imports | common, type, expression |
| Imported by | BusinessLanguage, module |
| Direct rule or token count | 1 |
How to use this page#
Read the examples first when authoring Business Language. Use the rule inventory when checking exact grammar coverage or when updating parser, lowering, editor, or documentation behavior.
Entry rules and syntax families#
Start with these rules when reading this grammar: ruleDeclaration.
- Declarations:
ruleDeclaration
Key grammar excerpts#
ruleDeclaration#
ruleDeclaration
: RULE identifier OPEN_PAREN parameterList? CLOSE_PAREN COLON typeExpression blockStatement
| RULE identifier SEMICOLON
// @define @name_fields(identifier) @symbol(kind=global) @scope(level=3)
;Complete rule and token inventory#
ruleDeclarationExamples#
Business rule#
rule invoice_requires_approval(invoice_id: InvoiceId): bool {
return invoice_total(invoice_id) > approval_limit(invoice_id);
}Rule declaration shell#
rule vendor_is_active(vendor_id: VendorId): bool {
return true;
}Common authoring mistakes#
- Do not copy examples without checking the rule inventory for the exact grammar boundary.
- Do not add behavior that depends on missing configuration or undeclared user-facing errors.
Related guides#
- /language/rules-tests-errors/
- /language/configuration-resolver-patterns/
Authoring notes#
- Represent tenant, company, country, process, and time-varying policy as configuration data.
- Keep examples aligned with the grammar source, not with inferred syntax from another language.
- Use declared messages for user-facing failures, and fail closed when required configuration is absent.