4.1.7.1 Overview

A Prolog program consists of a sequence of sentences. Each sentence is a Prolog term. How sentences are interpreted as terms is defined in ref-syn-syn-sen, below. Note that a term representing a sentence may be written in any of its equivalent syntactic forms. For example, the functor :-/2 could be written in standard prefix notation instead of as the usual infix operator.

Terms are written as sequences of tokens. Tokens are sequences of characters, which are treated as separate symbols. Tokens include the symbols for variables, constants, and functors, as well as punctuation characters such as parentheses and commas.

The interpretation of sequences of tokens as terms is defined in ref-syn-syn-trm. Each list of tokens that is read in (for interpretation as a term or sentence) must be terminated by a full-stop (a period followed by a layout character such as newline or space) token. Two tokens must be separated by a space if they could otherwise be interpreted as a single token. Both spaces and comments are ignored when interpreting the token list as a term. A comment may appear at any point in a token list (separated from other tokens by spaces where necessary).

The interpretation of sequences of characters as tokens is defined on ref-syn-syn-tok. The next section describes the notation used in the formal definition of Prolog syntax.


Send feedback on this subject.