Syntax Reference
HERCs dialect departs from the traditional Prolog notation in several ways.
All the differences are summarized below:
- Comments and commented-out code begins with semicolon (;) and ends at the end of the line. There are no block comments at the moment.
- Square brackets are used instead of curly brackets.
- Whitespace is used as a separator.
- Symbols (atoms) can start with upper or lower case characters.
- Variables have to start with star (*) rather than with upper case letter.
- Anonymous variable is denoted with just a single star.
- Cut operator is denoted as slash (/).
- Unconditional fail is denoted as fail.
- An empty list/pair is denoted as empty square brackets ([]).
- Everything is pair, which is denoted using colon character (:). This is an example of a simple pair: [1 : 2]
- Lists are nothing more than nested pairs. Therefore [1 2 3]
is in reality a nested pair terminated with empty list, such as this [1 : [2 : [3 : []]]].
- All predicates are denoted using S-expressions rather than
M-expressions.
Hence, you will have [parent *x *y] rather than parent(X, Y).
- Entire clauses are denoted as lists instead of explicit description.
Therefore you will have
[[sibling *x *y] [parent_child *z *x] [parent_child *z *y]]
rather than
sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y).
- Prolog modules are symbol based (contain symbols) and have their own dedicated syntax.
There is an import list, module header, list of symbols and the definitions closed by module footer.
- Prolog programs can also be stored in batch form.
In this case, a batch file is nothing more than recorded commands, just as if they were entered during interactive session.
If you are familiar with BNF notation then the following set of rules should answer a lot of questions.