N NezamDocumentation

Entity grammar#

Entity grammar describes business entities, entity fields, keys, indexes, relations, and data lifecycle blocks.

Source#

PropertyValue
Grammar filepackages/business/language/grammar/entity.g4
Grammar nameentity
Grammar kindparser
Importscommon, type, field, expression
Imported byBusinessLanguage, module
Direct rule or token count29

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#

antlr
entityDeclaration
    : accessModifier? ENTITY identifier entityInheritance? entityImplements? OPEN_BRACE entityMember* CLOSE_BRACE
      // @define @name_fields(identifier) @symbol(kind=global) @scope(level=2)
    ;

inlineFieldDeclaration#

antlr
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#

antlr
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#

text
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, validationSection

Examples#

Entity with key#

bl
entity VendorProfile {
  field vendor_id: VendorId key;
  field risk_score: decimal;
}

Entity relation#

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