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 the sourcecode of the parser, where all EBNF statements are in comments.
This page is meant as a reference for syntactical details and conventions, reserved words, etc.
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.
Ampersand has reserved words, such as
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.
"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.
75.88E3. The boolean atoms are
FALSE. Dates and timestamps follow the Excel-syntax, e.g. ??? The atom
_SESSIONindicates 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
). For populations and services we use square brackets
Constructs that contain ampersand statements are contexts and patterns. They always come in pairs:
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
-}. Multiline comments may be nested.
Identifiers always start with a letter. Concepts start with a capital letter, as in
Order. Relation names start with a lower case letter, as in
terms are combined with operators. Binary operators may require brackets to avoid ambiguity. To save writing unneccessary brackets, some precedence rules are in place.
Within an operator category, you must place brackets to disambiguate. E.g.
r/\s\/tis not allowed. You have to write either
r/\(s\/t). Across categories, you may omit brackets because a higher precedence binds stronger. So
(r;s)\/t. (Note that
r;(s\/t)have different meanings). Associative operators (
;) need not be disambiguated with brackets. So
r\/(s\/t)all mean exactly the same.
Keywords in Ampersand are always written in CAPITALS.
- Keywords for views
- Keywords for generalisations:
- Keywords for TType:
- Reserved words for values of atoms:
- Reserved words for concepts
- Experimental keywords:
- Deprecated keywords: