We start with a list of all available keywords:
INCLUDEspecifies an include file
PREDICATEprecedes a predicate definition
DOMAINSdefines a new data type for optional type checking
DATABASEdeclares a database predicate (not implemented yet)
CONSTANTSdefines symbolic names for constant data
IMPORTspecifies a list of predicates to import
EXPORTspecifies a list of predicates to export
Following the 'module' definition, any of the remaining keywords may appear.
MODULE starts a module definition. It must appear as the first keyword in a
module and may not appear twice within one file. It is followed by an atom describing the
module name, which in this version of BAP must be the same as the filename without the
'.BAP' ending (these restrictions may fall in future BAP releases).
The BAP pre-processor removes this line from the source code and instead inserts the contents of the file <FileName>. The file is searched for in the current directory (in case of double quotes '') or the directory indicated by the environment variable BINC (in case of single quotes '').
The PREDICATE keyword declares and defines a single predicate in 'PASCAL' like fashion (the declaration of a routine directly precedes the definition).
The clauses of the predicate directly follow the declaration.
A predicate declaration consists of the predicate name followed by a list of data types. It is terminated by a full stop.
string_list = list of string.
term = int(integer);
term_list = list of term;
season = spring; summer; autumn; winter.
The DOMAINS Keyword allows the user to define more complex data types from those already provided:
With these primitive data types , the user is free to build up his own ones. The effect of a type declaration is that a new predicate is built up (with the name of the domain type), that checks whether its single argument fits its type declaration or not. If it fits, the predicate succeeds. If not, it creates a runtime error and fails.
The construction of these checking predicates is implemented quite straight forward (by something like a preprocessor), allowing the user do create nested data types.
Declares a predicate as being member of the database, allowing database entries to be accessed like ordinary predicates. You don't need to declare a database predicate, instead you can access it via the database(void) built-in predicate, for example: database(xyz_position(X,Y,Z)).
This feature is not implemented yet.
left_corner = 20.
upper_corner = 10.
width = 50.
height = 20.
complex_0 = c(0,0).
title = 'Hey Guys, what's up?'.
A constant declaration consists of a constant name, which must be an atom , and a value assigned to it. The value may be of any type. After declaring a constant, you may use it as synonym for its value. It will literally be replaced by its value.
This statement declares that 'member()' and 'repeat()' are predicates defined in this module and that they may be called from outside.
IMPORT <ModuleName> :- <DeclarationList>.
IMPORT auxpreds :-
This statement defines 'member()' and 'repeat()' as predicates defined outside the module. The module 'auxpreds' will be loaded and linked at runtime in the moment when 'member()' and 'repeat()' are called the first time.