N NezamDocumentation

Business Language grammar#

The root parser composes every imported grammar module and defines the top-level program, declaration, statement, package, namespace, workspace, and configuration entry flow.

Source#

PropertyValue
Grammar filepackages/business/language/grammar/BusinessLanguage.g4
Grammar nameBusinessLanguage
Grammar kindparser
Importscommon, type, literal, expression, field, table, function, enum, message, annotation, struct, validation, error, app, api, class, entity, service, form, module, interface, controls, configuration, rule, subscription, test, source_ui, program, iac
Imported byNone
Direct rule or token count24

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: packageDeclaration, packageBody, workspaceDeclaration, usingDeclaration, versionLiteral, configDeclaration, namespaceDeclaration.

  • Declarations: configDeclaration, namespaceDeclaration, packageDeclaration, usingDeclaration, workspaceDeclaration
  • Bodies: packageBody
  • Literals: versionLiteral

Key grammar excerpts#

packageDeclaration#

antlr
packageDeclaration
    : PACKAGE qualifiedIdentifier packageBody?
    ;

packageBody#

antlr
packageBody
    : SEMICOLON
    | OPEN_BRACE packageMember* CLOSE_BRACE
    ;

workspaceDeclaration#

antlr
workspaceDeclaration
    : WORKSPACE qualifiedIdentifier OPEN_BRACE workspaceMember* CLOSE_BRACE
    ;

Complete rule and token inventory#

text
configBlock, configDeclaration, configEntry, configEntryKey, configEntryList, configEntrySeparator, configValue, declaration
namespaceDeclaration, packageBody, packageDeclaration, packageMember, program, programItem, statement, usingAlias
usingCondition, usingDeclaration, usingImportList, usingVersion, versionLiteral, versionSegment, workspaceDeclaration, workspaceMember

Examples#

Minimal package#

bl
package finance.payables;

field VendorId: string {
  max_length: 40;
  key: true;
}

table Vendor {
  field vendor_id: VendorId key origin;
  field company_code: CompanyCode key;
  field active: bool default(true);
}

public function find_vendor(vendor_id: VendorId): Vendor? {
  select var vendor: Vendor where Vendor.vendor_id = vendor_id;
  return vendor;
}

Configuration table plus behavior#

bl
table PayablePolicy {
  field company_code: CompanyCode key;
  field duplicate_invoice_check: bool required;
}

rule invoice_can_post(invoice_id: InvoiceId): bool {
  return invoice_id != null;
}

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.
  • /language/
  • /language/declarations/
  • /language/modules-namespaces/

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.
Source: packages/business/language/grammar-files/business-language.md