This file is indexed.

/usr/lib/swi-prolog/doc/Manual/syntax.html is in swi-prolog-nox 6.6.4-2ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>SWI-Prolog 7.1.10 Reference Manual: Section 2.15</title><link rel="home" href="index.html">
<link rel="contents" href="Contents.html">
<link rel="index" href="DocIndex.html">
<link rel="summary" href="summary.html">
<link rel="previous" href="gc.html">
<link rel="next" href="cyclic.html">

<style type="text/css">

/* Style sheet for SWI-Prolog latex2html
*/

dd.defbody
{ margin-bottom: 1em;
}

dt.pubdef, dt.multidef
{ color: #fff;
padding: 2px 10px 0px 10px;
margin-bottom: 5px;
font-size: 18px;
vertical-align: middle;
overflow: hidden;
}

dt.pubdef { background-color: #0c3d6e; }
dt.multidef { background-color: #ef9439; }

.bib dd
{ margin-bottom: 1em;
}

.bib dt
{ float: left;
margin-right: 1.3ex;
}

pre.code
{ margin-left: 1.5em;
margin-right: 1.5em;
border: 1px dotted;
padding-top: 5px;
padding-left: 5px;
padding-bottom: 5px;
background-color: #f8f8f8;
}

div.navigate
{ text-align: center;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
}

div.title
{ text-align: center;
padding-bottom: 1em;
font-size: 200%;
font-weight: bold;
}

div.author
{ text-align: center;
font-style: italic;
}

div.abstract
{ margin-top: 2em;
background-color: #f0f0f0;
border: 1px dotted;
padding: 5px;
margin-left: 10%; margin-right:10%;
}

div.abstract-title
{ text-align: center;
padding: 5px;
font-size: 120%;
font-weight: bold;
}

div.toc-h1
{ font-size: 200%;
font-weight: bold;
}

div.toc-h2
{ font-size: 120%;
font-weight: bold;
margin-left: 2em;
}

div.toc-h3
{ font-size: 100%;
font-weight: bold;
margin-left: 4em;
}

div.toc-h4
{ font-size: 100%;
margin-left: 6em;
}

span.sec-nr
{
}

span.sec-title
{
}

span.pred-ext
{ font-weight: bold;
}

span.pred-tag
{ float: right;
padding-top: 0.2em;
font-size: 80%;
font-style: italic;
color: #fff;
}

div.caption
{ width: 80%;
margin: auto;
text-align:center;
}

/* Footnotes */
.fn {
color: red;
font-size: 70%;
}

.fn-text, .fnp {
position: absolute;
top: auto;
left: 10%;
border: 1px solid #000;
box-shadow: 5px 5px 5px #888;
display: none;
background: #fff;
color: #000;
margin-top: 25px;
padding: 8px 12px;
font-size: larger;
}

sup:hover span.fn-text
{ display: block;
}

/* Lists */

dl.latex
{ margin-top: 1ex;
margin-bottom: 0.5ex;
}

dl.latex dl.latex dd.defbody
{ margin-bottom: 0.5ex;
}

/* PlDoc Tags */

dl.tags
{ font-size: 90%;
margin-left: 5ex;
margin-top: 1ex;
margin-bottom: 0.5ex;
}

dl.tags dt
{ margin-left: 0pt;
font-weight: bold;
}

dl.tags dd
{ margin-left: 3ex;
}

td.param
{ font-style: italic;
font-weight: bold;
}

/* Index */

dt.index-sep
{ font-weight: bold;
font-size: +1;
margin-top: 1ex;
}

/* Tables */

table.center
{ margin: auto;
}

table.latex
{ border-collapse:collapse;
}

table.latex tr
{ vertical-align: text-top;
}

table.latex td,th
{ padding: 2px 1em;
}

table.latex tr.hline td,th
{ border-top: 1px solid black;
}

table.frame-box
{ border: 2px solid black;
}

</style>
</head>
<body style="background:white">
<div class="navigate"><a class="nav" href="index.html"><img src="home.gif" alt="Home"></a>
<a class="nav" href="Contents.html"><img src="index.gif" alt="Contents"></a>
<a class="nav" href="DocIndex.html"><img src="yellow_pages.gif" alt="Index"></a>
<a class="nav" href="summary.html"><img src="info.gif" alt="Summary"></a>
<a class="nav" href="gc.html"><img src="prev.gif" alt="Previous"></a>
<a class="nav" href="cyclic.html"><img src="next.gif" alt="Next"></a>
</div>
<h2 id="sec:syntax"><a id="sec:2.15"><span class="sec-nr">2.15</span> <span class="sec-title">Syntax 
Notes</span></a></h2>

<a id="sec:syntax"></a>

<p>SWI-Prolog syntax is close to ISO-Prolog standard syntax, which is 
closely compatible with Edinburgh Prolog syntax. A description of this 
syntax can be found in the Prolog books referenced in the introduction. 
Below are some non-standard or non-common constructs that are accepted 
by SWI-Prolog:

<p>
<ul class="latex">
<li><i><code>/* ... /* ... */ ... */</code></i><br>
The <code>/* ... */</code> comment statement can be nested. This is 
useful if some code with <code>/* ... */</code> comment statements in it 
should be commented out.
</ul>

<p><h3 id="sec:isosyntax"><a id="sec:2.15.1"><span class="sec-nr">2.15.1</span> <span class="sec-title">ISO 
Syntax Support</span></a></h3>

<a id="sec:isosyntax"></a>

<p>SWI-Prolog offers ISO compatible extensions to the Edinburgh syntax.

<p><h4 id="sec:processorcharset"><a id="sec:2.15.1.1"><span class="sec-nr">2.15.1.1</span> <span class="sec-title">Processor 
Character Set</span></a></h4>

<a id="sec:processorcharset"></a>

<p><a id="idx:ISOLatin1:179"></a><a id="idx:characterset:180"></a>The 
processor character set specifies the class of each character used for 
parsing Prolog source text. Character classification is fixed to use 
UCS/Unicode as provided by the C library <code>wchar_t</code> based 
primitives. See also <a class="sec" href="widechars.html">section 2.18</a>.

<p><h4 id="sec:charescapes"><a id="sec:2.15.1.2"><span class="sec-nr">2.15.1.2</span> <span class="sec-title">Character 
Escape Syntax</span></a></h4>

<a id="sec:charescapes"></a>

<p>Within quoted atoms (using single quotes: <code>'&lt;atom&gt;'</code>) 
special characters are represented using escape sequences. An escape 
sequence is led in by the backslash (<code><code>\</code></code>) 
character. The list of escape sequences is compatible with the ISO 
standard but contains some extensions, and the interpretation of 
numerically specified characters is slightly more flexible to improve 
compatibility. Undefined escape characters raise a <code>syntax_error</code> 
exception.<sup class="fn">18<span class="fn-text">Up to SWI-Prolog&nbsp;6.1.9, 
undefined escape characters were copied verbatim, i.e., removing the 
backslash.</span></sup>

<dl class="latex">
<dt><code>\a</code></dt>
<dd class="defbody">
Alert character. Normally the ASCII character 7 (beep).
</dd>
<dt><code>\b</code></dt>
<dd class="defbody">
Backspace character.
</dd>
<dt><code>\c</code></dt>
<dd class="defbody">
No output. All input characters up to but not including the first 
non-layout character are skipped. This allows for the specification of 
pretty-looking long lines. Not supported by ISO. Example:

<pre class="code">
format('This is a long line that looks better if it was \c
       split across multiple physical lines in the input')
</pre>

</dd>
<dt><code>\&lt;<var><span style="font-variant:small-caps">NEWLINE</span></var>&gt;</code></dt>
<dd class="defbody">
When in ISO mode (see the Prolog flag <a class="flag" href="flags.html#flag:iso">iso</a>), 
only skip this sequence. In native mode, white space that follows the 
newline is skipped as well and a warning is printed, indicating that 
this construct is deprecated and advising to use <code>\c</code>. We 
advise using <code>\c</code> or putting the layout <em>before</em> the <code><code>\</code></code>, 
as shown below. Using
<code>\c</code> is supported by various other Prolog implementations and 
will remain supported by SWI-Prolog. The style shown below is the most 
compatible solution.<sup class="fn">19<span class="fn-text">Future 
versions will interpret <code><code>\</code></code>&lt;<var>return</var>&gt; 
according to ISO.</span></sup>

<pre class="code">
format('This is a long line that looks better if it was \
split across multiple physical lines in the input')
</pre>

<p>instead of

<pre class="code">
format('This is a long line that looks better if it was\
 split across multiple physical lines in the input')
</pre>

</dd>
<dt><code>\e</code></dt>
<dd class="defbody">
Escape character (<span style="font-variant:small-caps">ASCII</span> 
27). Not ISO, but widely supported.
</dd>
<dt><code>\f</code></dt>
<dd class="defbody">
Form-feed character.
</dd>
<dt><code>\n</code></dt>
<dd class="defbody">
Next-line character.
</dd>
<dt><code>\r</code></dt>
<dd class="defbody">
Carriage-return only (i.e., go back to the start of the line).
</dd>
<dt><code>\s</code></dt>
<dd class="defbody">
Space character. Intended to allow writing <code>0'\s</code> to get the 
character code of the space character. Not ISO.
</dd>
<dt><code>\t</code></dt>
<dd class="defbody">
Horizontal tab character.
</dd>
<dt><code>\v</code></dt>
<dd class="defbody">
Vertical tab character (<span style="font-variant:small-caps">ASCII</span> 
11).
</dd>
<dt><code>\<code>xXX..\</code></code></dt>
<dd class="defbody">
Hexadecimal specification of a character. The closing <code>\</code> is 
obligatory according to the ISO standard, but optional in SWI-Prolog to 
enhance compatibility with the older Edinburgh standard. The code
<code>\xa\3</code> emits the character 10 (hexadecimal `a') followed by 
`3'. Characters specified this way are interpreted as Unicode 
characters. See also <code>\u</code>.
</dd>
<dt><code>\uXXXX</code></dt>
<dd class="defbody">
Unicode character specification where the character is specified using
<em>exactly</em> 4 hexadecimal digits. This is an extension to the ISO 
standard, fixing two problems. First, where <code>\x</code> defines a 
numeric character code, it doesn't specify the character set in which 
the character should be interpreted. Second, it is not needed to use the 
idiosyncratic closing <code><code>\</code></code> ISO Prolog syntax.
</dd>
<dt><code>\UXXXXXXXX</code></dt>
<dd class="defbody">
Same as <code>\uXXXX</code>, but using 8 digits to cover the whole 
Unicode set.
</dd>
<dt><code>\40</code></dt>
<dd class="defbody">
Octal character specification. The rules and remarks for hexadecimal 
specifications apply to octal specifications as well.
</dd>
<dt><code>\<code>\</code></code></dt>
<dd class="defbody">
Escapes the backslash itself. Thus, <code>'\\'</code> is an atom 
consisting of a single <code><code>\</code></code>.
</dd>
<dt><code>\quote</code></dt>
<dd class="defbody">
If the current quote (<code>"</code> or <code>'</code>) is preceded by a 
backslash, it is copied verbatim. Thus, <code>'\''</code> and <code>''''</code> 
both describe the atom with a single&nbsp;<code>'</code>.
</dd>
</dl>

<p>Character escaping is only available if
<code>current_prolog_flag(character_escapes, true)</code> is active 
(default). See <a id="idx:currentprologflag2:181"></a><a class="pred" href="flags.html#current_prolog_flag/2">current_prolog_flag/2</a>. 
Character escapes conflict with <a id="idx:writef2:182"></a><a class="pred" href="format.html#writef/2">writef/2</a> 
in two ways: <code>\40</code> is interpreted as decimal 40 by <a id="idx:writef2:183"></a><a class="pred" href="format.html#writef/2">writef/2</a>, 
but as octal 40 (decimal 32) by <code>read</code>. Also, the <a id="idx:writef2:184"></a><a class="pred" href="format.html#writef/2">writef/2</a> 
sequence
<code>\l</code> is illegal. It is advised to use the more widely 
supported
<a id="idx:format23:185"></a><span class="pred-ext">format/[2,3]</span> 
predicate instead. If you insist upon using <a id="idx:writef2:186"></a><a class="pred" href="format.html#writef/2">writef/2</a>, 
either switch <a class="flag" href="flags.html#flag:character_escapes">character_escapes</a> 
to <code>false</code>, or use double <code>\\</code>, as in <code>writef('\\l')</code>.

<p><h4 id="sec:nondecsyntax"><a id="sec:2.15.1.3"><span class="sec-nr">2.15.1.3</span> <span class="sec-title">Syntax 
for non-decimal numbers</span></a></h4>

<a id="sec:nondecsyntax"></a>

<p>SWI-Prolog implements both Edinburgh and ISO representations for 
non-decimal numbers. According to Edinburgh syntax, such numbers are 
written as <code>&lt;<var>radix</var>&gt;'&lt;number&gt;</code>, where &lt;<var>radix</var>&gt; 
is a number between 2 and 36. ISO defines binary, octal and hexadecimal 
numbers using
<code>0<em>[bxo]</em>&lt;<var>number</var>&gt;</code>. For example: <code>A is 0b100 \/ 0xf00</code> 
is a valid expression. Such numbers are always unsigned.

<p><h4 id="sec:digitgroupsyntax"><a id="sec:2.15.1.4"><span class="sec-nr">2.15.1.4</span> <span class="sec-title">Using 
digit groups in large integers</span></a></h4>

<a id="sec:digitgroupsyntax"></a>

<p>SWI-Prolog supports splitting long integers into <em>digit groups</em>. 
Digit groups can be separated with the sequence &lt;<var>underscore</var>&gt;,
&lt;<var>optional white space</var>&gt;. If the &lt;<var>radix</var>&gt; 
is 10 or lower, they may also be separated with exactly one space. The 
following all express the integer 1&nbsp;million:

<pre class="code">
1_000_000
1 000 000
1_000_/*more*/000
</pre>

<p>Integers can be printed using this notation with <a id="idx:format2:187"></a><a class="pred" href="format.html#format/2">format/2</a>, 
using the
<code>~I</code> format specifier. For example:

<pre class="code">
?- format('~I', [1000000]).
1_000_000
</pre>

<p>The current syntax has been proposed by Ulrich Neumerkel on the 
SWI-Prolog mailinglist.

<p><h4 id="sec:unicodesyntax"><a id="sec:2.15.1.5"><span class="sec-nr">2.15.1.5</span> <span class="sec-title">Unicode 
Prolog source</span></a></h4>

<a id="sec:unicodesyntax"></a>

<p>The ISO standard specifies the Prolog syntax in ASCII characters. As 
SWI-Prolog supports Unicode in source files we must extend the syntax. 
This section describes the implication for the source files, while 
writing international source files is described in <a class="sec" href="projectfiles.html">section 
3.1.3</a>.

<p>The SWI-Prolog Unicode character classification is based on version 
6.0.0 of the Unicode standard. Please note that <a id="idx:chartype2:188"></a><a class="pred" href="chartype.html#char_type/2">char_type/2</a> 
and friends, intended to be used with all text except Prolog source 
code, is based on the C library locale-based classification routines.

<p>
<ul class="latex">
<li><i>Quoted atoms and strings</i><br>
Any character of any script can be used in quoted atoms and strings. The 
escape sequences <code>\uXXXX</code> and <code>\UXXXXXXXX</code> (see
<a class="sec" href="syntax.html">section 2.15.1.2</a>) were introduced 
to specify Unicode code points in ASCII files.

<p>
<li><i>Atoms and Variables</i><br>
We handle them in one item as they are closely related. The Unicode 
standard defines a syntax for identifiers in computer languages.<sup class="fn">20<span class="fn-text"><a class="url" href="http://www.unicode.org/reports/tr31/">http://www.unicode.org/reports/tr31/</a></span></sup> 
In this syntax identifiers start with <code>ID_Start</code> followed by 
a sequence of <code>ID_Continue</code> codes. Such sequences are handled 
as a single token in SWI-Prolog. The token is a <em>variable</em> iff it 
starts with an uppercase character or an underscore (<code>_</code>). 
Otherwise it is an atom. Note that many languages do not have the notion 
of character case. In such languages variables <em>must</em> be written 
as
<code>_name</code>.

<p>
<li><i>White space</i><br>
All characters marked as separators (Z*) in the Unicode tables are 
handled as layout characters.

<p>
<li><i>Control and unassigned characters</i><br>
Control and unassigned (C*) characters produce a syntax error if 
encountered outside quoted atoms/strings and outside comments.

<p>
<li><i>Other characters</i><br>
The first 128 characters follow the ISO Prolog standard. Unicode symbol 
and punctuation characters (general category S* and P*) act as glueing 
symbol characters (i.e., just like <code><code>==</code></code>: an 
unquoted sequence of symbol characters are combined into an atom).

<p>Other characters (this is mainly <code>No</code>: <i>a numeric 
character of other type</i>) are currently handled as `solo'.
</ul>

<p><h4 id="sec:singleton"><a id="sec:2.15.1.6"><span class="sec-nr">2.15.1.6</span> <span class="sec-title">Singleton 
variable checking</span></a></h4>

<a id="sec:singleton"></a>

<p><a id="idx:singletonvariable:189"></a><a id="idx:anonymousvariable:190"></a>A <em>singleton 
variable</em> is a variable that appears only one time in a clause. It 
can always be replaced by <code>_</code>, the
<em>anonymous</em> variable. In some cases, however, people prefer to 
give the variable a name. As mistyping a variable is a common mistake, 
Prolog systems generally give a warning (controlled by <a id="idx:stylecheck1:191"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a>) 
if a variable is used only once. The system can be informed that a 
variable is meant to appear once by <em>starting</em> it with an 
underscore, e.g.,
<code>_Name</code>. Please note that any variable, except plain <code>_</code>, 
shares with variables of the same name. The term <code>t(_X, _X)</code> 
is equivalent to <code>t(X, X)</code>, which is <em>different</em> from
<code>t(_, _)</code>.

<p>As Unicode requires variables to start with an underscore in many 
languages, this schema needs to be extended.<sup class="fn">21<span class="fn-text">After 
a proposal by Richard O'Keefe.</span></sup> First we define the two 
classes of named variables.

<p>
<ul class="latex">
<li><i>Named singleton variables</i><br>
Named singletons start with a double underscore (<code>__</code>) or a 
single underscore followed by an uppercase letter, e.g., <code>__var</code> 
or
<code>_Var</code>.

<p>
<li><i>Normal variables</i><br>
All other variables are `normal' variables. Note this makes <code>_var</code> 
a normal variable.<sup class="fn">22<span class="fn-text">Some Prolog 
dialects write variables this way.</span></sup>
</ul>

<p>Any normal variable appearing exactly once in the clause <em>and</em> 
any named singleton variables appearing more than once are reported. 
Below are some examples with warnings in the right column. Singleton 
messages can be suppressed using the <a id="idx:stylecheck1:192"></a><a class="pred" href="debugger.html#style_check/1">style_check/1</a> 
directive.

<p><table class="latex frame-box center">
<tr><td>test(_).</td></tr>
<tr><td>test(_a).</td><td>Singleton variables: [_a] </td></tr>
<tr><td>test(_12).</td><td>Singleton variables: [_12] </td></tr>
<tr><td>test(A).</td><td>Singleton variables: [A] </td></tr>
<tr><td>test(_A).</td></tr>
<tr><td>test(__a).</td></tr>
<tr><td>test(_, _).</td></tr>
<tr><td>test(_a, _a).</td></tr>
<tr><td>test(__a, __a).</td><td>Singleton-marked variables appearing 
more than once: [__a] </td></tr>
<tr><td>test(_A, _A).</td><td>Singleton-marked variables appearing more 
than once: [_A] </td></tr>
<tr><td>test(A, A).</td></tr>
</table>

<p><b>Semantic singletons</b> 

<p>Starting with version 6.5.1, SWI-Prolog has <em>syntactic singletons</em> 
and <em>semantic singletons</em>. The first are checked by
<a id="idx:readclause3:193"></a><a class="pred" href="termrw.html#read_clause/3">read_clause/3</a> 
(and <a id="idx:readterm3:194"></a><a class="pred" href="termrw.html#read_term/3">read_term/3</a> 
using the option
<code>singletons(warning)</code>). The latter are generated by the 
compiler for variables that appear alone in a <em>branch</em>. For 
example, in the code below the variable <var>X</var> is not a <em>syntactic</em> 
singleton, but the variable <var>X</var> does not communicate any 
bindings and replacing
<var>X</var> with <var>_</var> does not change the semantics.

<pre class="code">
test :-
        (   test_1(X)
        ;   test_2(X)
        ).
</pre>

<p></body></html>