Struct grammar#
Struct grammar is the compatibility module for structured type declarations imported by the root grammar.
Source#
| Property | Value |
|---|---|
| Grammar file | packages/business/language/grammar/struct.g4 |
| Grammar name | struct |
| Grammar kind | parser |
| Imports | common, type, annotation, expression |
| Imported by | BusinessLanguage, module |
| Direct rule or token count | 7 |
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: structDeclaration.
- Declarations:
structDeclaration
Key grammar excerpts#
structDeclaration#
structDeclaration
: annotation* STRUCT identifier OPEN_BRACE structMemberList? CLOSE_BRACE
;Complete rule and token inventory#
fieldModifier, fieldReference, fieldSuffix, structDeclaration, structMember, structMemberList, structMemberTerminatorExamples#
Struct declaration#
struct PostingResult {
field posted: bool;
field document_number: string;
}Struct as DTO#
struct VendorDto {
field vendor_id: VendorId;
field vendor_name: 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/types-literals/
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.