Declarations#
Declarations are the main unit of Business Language source files. A source file is parsed as a sequence of declarations and statements, so declarations can appear at the top level and inside containers such as modules and namespaces.
Declaration map#
The grammar accepts these declaration families:
| Declaration | Purpose |
|---|---|
field | Reusable scalar field type with validation and properties |
table / entity | Persistent records, configuration tables, constraints, indexes, validations |
struct, type | Data shapes and type aliases |
enum | True invariant value sets |
function, rule, validation | Executable behavior and reusable validation |
message | Localized user-facing text and error catalogs |
service, api, subscription | Integration and event boundaries |
form, control, app | UI definitions |
program, resource, deployment | Runtime and infrastructure declarations |
module, package, namespace, using, import, export | Organization and dependency structure |
Module members can also include module-scoped label declarations.
Fields#
Fields define reusable scalar shapes.
field CurrencyCode: string {
max_length: 3;
key: true;
}Function return markers can be either : or ->. Function bodies can be block bodies, abstract semicolon bodies, fat-arrow expressions, fat-arrow statements, or fat-arrow query/delete statements.
Tables#
Tables define persisted records. Field modifiers such as key, origin, and default(...) describe storage behavior.
table PaymentTermPolicy {
field company_code: CompanyCode key;
field payment_term_id: PaymentTermId key origin;
field active: bool default(true);
field created_at: datetime default(now());
}Modifiers#
Common access modifiers are:
public
private
protected
internalCommon function modifiers are:
static
abstract
virtual
override
async
inlineUse annotations before declarations when metadata is needed:
@http(GET)
public function list_vendors(company_code_param: CompanyCode): Json {
return {};
}Functions#
Functions can be public, private, or annotated for HTTP exposure.
@http(GET)
function get_active_payment_terms(
company_code_param: CompanyCode,
limiter: limiter
): Json {
select *
from PaymentTermPolicy
where PaymentTermPolicy.company_code = company_code_param
and PaymentTermPolicy.active = true
order by payment_term_id
with limiter limiter;
}Messages#
Messages define reusable user-facing failures.
message payment_term_policy_required {
code: "AP-ERR-1001";
severity: error;
category: custom("config");
message: {
en: "Payment term policy is required";
};
}