Syntax

QuLog does not have an operator precedence syntax and its syntax is not extensible. As in Prolog, a functor or predicate is written immediately next to its tuple of arguments as in p(...). There is a collection of reserved words that are used for the builtin operators. There is no need to use a full stop followed by a white space character, as in Prolog, to separate the relation rules (aka clauses), function and action rules, type definitions and type declarations. Instead we borrowed an idea from Python and made what is a normal program layout format for a Prolog program - each clause starting on a new line - a syntax requirement.

All the above program statements must begin at the left end of a new line. Each can be continued over several lines where all but the first line is indented by at least one space or tab. Starting rules at the left end of a newline, and indenting a continuation of a rule by several spaces, or one tab, is normal Prolog program layout. Our indentation indicator for continuation of a rule encourages this, making programs more readable. However, as a gesture towards Prolog programmers, including ourselves, a full stop followed by a newline, or spaces and a newline, may also be used at the end of a statement. It is ignored by the QuLog parser. Even if you use fullstops as terminators, you cannot put two clauses or rules on the same line of the program file.

Apart from requiring a predicate or functor to be adjacent to its (...) bracketed arguments, and treating a space or tab at the beginning of a new line as a continuation marker, QuLog is tolerant of spaces. They should be used to aid readability of the program. To aid in editing QuLog programs we have supplied an emacs mode and a simple Python/Tkinter based editor (quled) that uses tab to provide readable code layout and uses syntax highlighting.

As in Prolog, alphanumeric names beginning with an upper case letter or underscore _, or underscore on its own, are variables. To make such a name an atom (aka symbol), or the name of a relation or function, it can be singly quoted as in 'Peter', 'Father_of', 'Fact'.

In contrast, an alphanumeric name that begins with a lower case letter, which can contain under-scores, is an atom and is used to denote individual things or names of relations, functions or actions. Surrounding such a name with single quotes has no effect at all, and they will be dropped when the atom is displayed.

One difference in syntax between QuLog and Prolog is that QuLog allows zero arity compound terms such as empty().

The syntax for sets is a sequence of ground terms surrounded by parentheses such as {1,2,3}.

Lists and list patterns are as in Prolog but we also allow [H,..T] as equivalent to [H|T] and [H,..] as equivalent to [H|_].