Entity grammar#
Entity grammar describes business entities, entity fields, keys, indexes, relations, and data lifecycle blocks.
Source#
| Property | Value |
|---|---|
| Grammar file | packages/business/language/grammar/entity.g4 |
| Grammar name | entity |
| Grammar kind | parser |
| Imports | common, type, field, expression |
| Imported by | BusinessLanguage, module |
| Direct rule or token count | 29 |
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: entityDeclaration, inlineFieldDeclaration, primitiveType, entityFunctionDeclaration, returnType, functionBody.
- Declarations:
entityDeclaration,entityFunctionDeclaration,inlineFieldDeclaration - Types:
primitiveType,returnType - Bodies:
functionBody
Key grammar excerpts#
entityDeclaration#
entityDeclaration
: accessModifier? ENTITY identifier entityInheritance? entityImplements? OPEN_BRACE entityMember* CLOSE_BRACE
// @define @name_fields(identifier) @symbol(kind=global) @scope(level=2)
;inlineFieldDeclaration#
inlineFieldDeclaration
: { _input.LA(1) != FUNCTION && _input.LA(1) != VALIDATION && _input.LA(1) != BUSINESS_RULES && _input.LA(1) != AUTHORIZATION }?
identifier COLON fieldTypeSpec fieldModifier*
// @define @name_fields(identifier) @symbol(kind=non_local)
;primitiveType#
primitiveType: STRING | INTEGER | DECIMAL | FLOAT_KW | BOOLEAN | BOOL
| DATE | TIME | DATETIME | TIMESTAMP
| UUID | JSON | TEXT | BLOB
| NUMBER | URL | EMAIL | PHONE
| LIST | MAP | SET
;Complete rule and token inventory#
associatedModifier, authorizationRule, authorizationSection, businessRule, businessRulesSection, caseModifier, computedModifier, defaultModifier
entityDeclaration, entityFunctionDeclaration, entityImplements, entityInheritance, entityMember, fieldModifier, fieldTypeSpec, functionBody
inlineFieldDeclaration, patternModifier, primitiveType, rangeModifier, referencesModifier, returnType, typeExpressionList, typeParameter
typeParameterList, validationExpr, validationRule, validationRuleReference, validationSectionExamples#
Entity with key#
entity VendorProfile {
field vendor_id: VendorId key;
field risk_score: decimal;
}Entity relation#
entity VendorBankAccount {
field vendor_id: VendorId key;
field iban: string;
}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/data-modeling/
- /language/table-schema-reference/
Authoring notes#
- 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.