Syntax
The syntax of Prolog programs resembles the syntax of logic programs as given before,
except for some small notational differences such as the symbol separating the head
from the body of a clause and the use of a dot to indicate the end of a clause.
Below we list the BNF-grammar rules that describe the syntax of Prolog clauses.
Terminal symbols are written bold-face.
\prologindex{BNF grammer}
\oprog{terms}{
\begin{tabbing} \small
\\
\\
\\
\end{tabbing}
}
$=P
\prologindex{terms}
Terms are defined in the usual way.
Prolog is, however, more liberal in what it considers as constants.
Any quoted expression like 'AzY' or '*!\&' is a constant.
Prolog also allows the use of a so-called anonymous variable,
which is written as an underscore as for example in s(_).
The anonymous variable is treated as an ordinary logical variable
except that it will never become bound.
Another difference is that arithmetical expressions,
such as $1 + 2X * 5+(1,2)*(X,5)
\oprog{clauses}{
\begin{tabbing} \small
\\
\\
\\
\\
\\
\\
\\
\end{tabbing}
}
Clauses represent either facts, rules or goals.
When Prolog-systems are used interactively, which is often the case,
the symbol ?- indicating a goal is usually given as a system prompt.
A fact is written as a literal ended by a dot.
However, a fact may also be written in a rule-format
by substituting the literal true for the body.
$=