Syntax errors are detected during reading1.
directive or, in general, any term read in by the
read/1 that fails to comply with
syntax requirements is displayed on the standard error
stream as soon as it is read, along with its position in the input
stream and a mark indicating the point in the string of symbols
where the parser has failed to continue analysis, e.g.:
| memb(X, X$L). ! Syntax error ! , or ) expected in arguments ! in line 5 ! memb ( X , X ! <<here>> ! $ L ) .
if ‘$’ has not been declared as an infix operator.
Note that any comments in the faulty line are not displayed with the
error message. If you are in doubt about which clause was wrong, then
you can use
to load the code and then use
listing/1 predicate to list all the
clauses that were successfully read in, e.g.:
| ?- listing(memb/2).
Please note: The built-in predicates
read/[1,2]normally raise an exception on syntax errors (see ref-ere). The behavior is controlled by the Prolog flag
The SICStus Prolog IDE (see SPIDER) will show syntax errors and many other programming errors directly in the editor, while the code is written, without loading the code.
By default, e.g. when using
[myprog], code is compiled.
Compiled code can not be listed with
consult([myprog]) ensures that the code is interpreted, making it available for listing with