Documentation
  • Introduction
  • Why Ampersand?
    • The Business Rules Manifesto and Ampersand
  • Tutorial
    • Example system: Enrollment
    • Conceptual Model: Enrollment
    • Your tool: RAP4
    • Making your first Ampersand script
  • Reactive programming
  • The language Ampersand
    • How to read syntax statements
    • Truth
    • Atoms
    • The CONCEPT statement
    • The RELATION statement
    • The MEANING statement
    • The PURPOSE statement
    • The CLASSIFY statement
    • The RULE statement
    • Terms
      • Semantics
      • Semantics in logic
        • Primitive terms
        • Boolean operators
        • Relational operators
        • Residual operators
      • Semantics in natural language
        • Primitive terms in natural language
        • Boolean operators in natural language
        • Relational operators in natural language
        • Residual operators in natural language
      • Semantics in sets
        • Primitive terms in set theory
        • Boolean operators in set theory
        • Relational operators in set theory
      • Semantics of terms, defined algebraically
        • Boolean operators in algebra
        • Relational operators in algebra
      • Semantics visualized
        • Semantics of boolean operators visualized
        • Semantics of relational operators visualized
        • Semantics of residuals visualized
    • Context
    • Module
    • Best Practices
    • Syntactical Conventions
      • The CONCEPT statement
      • The RELATION statement
      • The RULE statement
      • The CONTEXT statement
      • The INCLUDE statement
      • Explanation
      • Patterns
      • Population
        • Population in spreadsheets
      • The PURPOSE statement
      • The IDENT statement
      • The TABLE statement
      • Language support
    • The INCLUDE statement
    • Patterns
    • Services
      • Example: Client
      • Example: Login
      • Syntax and meaning
      • Explanation
      • Layout of user interfaces
        • Your own widgets (HTML and CSS)
      • CRUD
    • Population
      • Population in spreadsheets
    • The ENFORCE statement
    • The IDENT statement
    • The TABLE statement
    • Language support
    • Current date
    • The Preprocessor
    • Design considerations
  • Running the Ampersand compiler
    • Configuration
    • Commands (vs. 4.0.0 and later)
    • Options (up to vs. 3.17.4)
  • Architecture of an Ampersand Application
    • Backend framework
    • Hooks
    • Extensions
      • The ExecEngine
  • Deploying your Ampersand script
    • Compiler
    • Deploy your own web application on your laptop
    • Prototype multi-stage build
    • Prototype database
  • Reusing Available Modules
    • Modules
    • Security
    • SIAM (Sessions, Identity and Access Management) Module
  • Exercises
    • Delivery
    • VOG (in Dutch)
  • Installing Ampersand
    • Deploying your Prototype
    • Installing the tools manually
  • Modeling
    • Domain Driven Design
    • Data modeling
    • Legal modeling
    • Architecture modeling
    • Metamodeling
    • Limitations of Ampersand
  • Configuring your application
  • The Excel Importer
  • Plans
    • Current State
    • NoSQL storage
    • API documentation
    • OWL and RDFS input
    • Refactor the front-end
  • Research
Powered by GitBook
On this page
  • Purpose
  • Learning the syntax
  • Symbols
  • terms
  • List of reserved words
Export as PDF
  1. The language Ampersand

Syntactical Conventions

PreviousBest PracticesNextThe CONCEPT statement

Last updated 4 years ago

To keep this chapter as readable as possible, we have chosen to omit some details that are irrelevant for practically all &-modelers. In the very rare case that these technicalities are of interest, the reader could have a look in , where all EBNF statements are in comments.

Purpose

This page is meant as a reference for syntactical details and conventions, reserved words, etc.

Learning the syntax

The most effective way to learn Ampersand's syntax is to copy from existing scripts. This is learning by examples. This reference chapter is suitable to check things, and less suitable for learning.

Symbols

Ampersand has reserved words, such as RELATION, CONTEXT, CONTAINS. All reserved words are written in capital letters. They are introduced on the fly. You will find an exhaustive list of reserved words at the end of this page.

Untyped atoms are written between double quotes, e.g. "Peter" or "KD-686-D". If you want to introduce a double quote inside an atom, escape it with a backslash, e.g. "the symbol \" is called double quote". Numeric atoms always start with a digit, e.g. 4711 or 75.88E3. The boolean atoms are TRUE and FALSE. Dates and timestamps follow the Excel-syntax, e.g. ??? The atom _SESSION indicates the current user session, and is an instance of concept SESSION. It is used in services.

Brackets must always match. For terms, we use round brackets ( and ). For populations and services we use square brackets [ and ].

Constructs that contain ampersand statements are contexts and patterns. They always come in pairs: PATTERN and ENDPATTERN, and CONTEXT and ENDCONTEXT.

White space characters (spaces, tabs, CRLF) are meaningless. You can use them freely to layout your script in a way that helps you to recognize its structure.

A comment on a single line starts with --. Everything after a -- symbol is ignored until the line ends. Multiline comments are wrapped between comment brackets {- and -}. Multiline comments may be nested.

Identifiers always start with a letter. Concepts start with a capital letter, as in Person, Case, A, and Order. Relation names start with a lower case letter, as in contains, attr, sessionLogin, or r.

terms

terms are combined with operators. Binary operators may require brackets to avoid ambiguity. To save writing unneccessary brackets, some precedence rules are in place.

operator category

precedence

operators

logic

1 (weakest)

|- (subset), = (equal)

binary boolean

2

\/ (union), /\ (intersect), - (difference)

binary relational

3

; (composition), ! (relational addition), \ (right residual), / (left residual), <> (diamond operator)

unary prefix, unary postfix

4 (strongest)

- (complement), ~ (converse)

Within an operator category, you must place brackets to disambiguate. E.g. r/\s\/t is not allowed. You have to write either (r/\s)\/t or r/\(s\/t). Across categories, you may omit brackets because a higher precedence binds stronger. So r;s\/t means (r;s)\/t. (Note that (r;s)\/t and r;(s\/t) have different meanings). Associative operators (\/, /\, ;) need not be disambiguated with brackets. So r\/s\/t and (r\/s)\/t and r\/(s\/t) all mean exactly the same.

List of reserved words

Keywords in Ampersand are always written in CAPITALS.

  • Keywords for the main structure of the code

    • ENDCONTEXT

    • ENGLISH

    • DUTCH

    • META

    • THEMES

    • ENDPATTERN

    • PRAGMA

    • UNI

    • INJ

    • SUR

    • TOT

    • SYM

    • ASY

    • TRN

    • RFX

    • IRF

    • PROP

    • CONTAINS

    • RULE

    • MESSAGE

    • VIOLATION

    • TXT

    • SRC

    • TGT

    • I

    • V

    • ONE

    • ROLE

    • MAINTAINS

  • Keywords for documentation

    • REF

    • REST

    • HTML

    • LATEX

    • MARKDOWN

    • INTERFACE

    • FOR

    • LINKTO

    • BOX

  • Keywords for identities

  • Keywords for views

    • VIEW

    • ENDVIEW

    • DEFAULT

    • TEMPLATE

    • HTML

  • Keywords for generalisations:

    • CLASSIFY

    • ISA

    • IS

  • Keywords for TType:

    • REPRESENT

    • TYPE

    • ALPHANUMERIC

    • BIGALPHANUMERIC

    • HUGEALPHANUMERIC

    • PASSWORD

    • BINARY

    • BIGBINARY

    • HUGEBINARY

    • DATE

    • DATETIME

    • BOOLEAN

    • INTEGER

    • FLOAT

    • AUTOINCREMENT

  • Reserved words for values of atoms:

    • TRUE

    • FALSE --for booleans

    • _SESSION

  • Reserved words for concepts

    • ONE

    • SESSION

  • Experimental keywords:

    • SERVICE

    • EDITS

  • Deprecated keywords:

    • SPEC

    • KEY

    • PROCESS

    • ENDPROCESS

Keywords for

Keywords for

Keywords for

the sourcecode of the parser
CONTEXT
IN
INCLUDE
PATTERN
CONCEPT
relations
RELATION
POPULATION
rules
PURPOSE
MEANING
services
IDENT