App grammar#
App grammar describes application declarations, pages, navigation, actions, layouts, and UI wiring at the application level.
Source#
| Property | Value |
|---|---|
| Grammar file | packages/business/language/grammar/app.g4 |
| Grammar name | app |
| Grammar kind | parser |
| Imports | common, expression, literal, form, type |
| Imported by | BusinessLanguage, module |
| Direct rule or token count | 38 |
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: appDeclaration, appStateDeclaration.
- Declarations:
appDeclaration,appStateDeclaration
Key grammar excerpts#
appDeclaration#
appDeclaration
: annotation* accessModifier? APP identifier
appDeclarationWithHeader
| annotation* accessModifier? APP identifier
appDeclarationWithoutHeader
// @define @name_fields(identifier) @role(member_owner) @kind(layout:app) @symbol(kind=global) @scope(level=2)
;appStateDeclaration#
appStateDeclaration
: annotation* accessModifier? identifier COLON typeExpression SEMICOLON?
// @define @name_fields(identifier) @role(member_definition) @kind(member:state) @symbol(kind=non_local)
;Complete rule and token inventory#
appDeclaration, appDeclarationWithHeader, appDeclarationWithoutHeader, appHeader, appHeaderProperty, appInlineHeaderProperty, appInlineHeaderValue, appInlineItem
appLayoutProperty, appLayoutValue, appMember, appStateDeclaration, commandPaletteCommand, commandPaletteCommandLabel, commandPaletteCommandOption, commandPaletteGroup
commandPaletteGroupName, commandPaletteSection, formLayout, formMount, formMountConfig, formMountProperty, formMountValue, formRef
layoutPreset, layoutSection, navigationItem, navigationProperty, navigationPropertyKey, navigationSection, navigationValue, startupSection
toolbarAction, toolbarActionLabel, toolbarActionOption, toolbarGroup, toolbarGroupName, toolbarSectionExamples#
Application shell with mounted form#
app PayablesApp {
title: "Payables";
form Vendors: VendorForm {
layout: two_column;
}
startup: Vendors;
}Navigation and toolbar sections#
app FinanceConsole {
navigation: {
vendors: {
label: "Vendors";
form: Vendors;
}
}
toolbar: {
main: "Refresh" -> refresh_vendors;
}
}Inline form and object mount config#
app VendorWorkspace {
form VendorEditor {
body: {
vendor_name: Text from Vendor.vendor_name;
}
}
form vendors: VendorForm {
layout: grid;
params: { readonly: false, source: VendorMaster };
}
startup: VendorEditor;
}Unquoted action labels and options#
app VendorConsole {
form vendors: VendorForm {
layout: grid;
}
toolbar: main:
Save vendor -> save_vendor icon: "save" primary true;
command_palettes: global:
Open vendor -> open_vendor shortcut "Ctrl+K";
startup: vendors;
}Header app with state and shell layout#
app BackOffice {
title: "Back Office";
} {
state {
selected_vendor_id: VendorId;
}
form vendors: VendorForm {
layout: grid;
options: { density: "compact" };
}
command_palettes: {
global: "Open vendors" -> open_vendors shortcut: "Ctrl+K";
}
ui: {
layout: desktop;
}
startup: vendors;
}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/apps-forms-controls/
- /language/source-ui-layouts/
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.