1% BEGIN LICENSE BLOCK 2% Version: CMPL 1.1 3% 4% The contents of this file are subject to the Cisco-style Mozilla Public 5% License Version 1.1 (the "License"); you may not use this file except 6% in compliance with the License. You may obtain a copy of the License 7% at www.eclipse-clp.org/license. 8% 9% Software distributed under the License is distributed on an "AS IS" 10% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11% the License for the specific language governing rights and limitations 12% under the License. 13% 14% The Original Code is The ECLiPSe Constraint Logic Programming System. 15% The Initial Developer of the Original Code is Cisco Systems, Inc. 16% Portions created by the Initial Developer are 17% Copyright (C) 1994 - 2006 Cisco Systems, Inc. All Rights Reserved. 18% 19% Contributor(s): 20% 21% END LICENSE BLOCK 22% 23% @(#)umssyntax.tex 1.7 94/01/12 24% 25% \comment{@(\#)text1.mss 20.4 9/19/88} 26% \comment{t1, root=`manual.mss'} 27 28\chapter{Syntax} 29\label{chapsyntax} 30%HEVEA\cutdef[1]{section} 31 32\section{Introduction} 33 34This chapter provides a definition of the syntax of the {\eclipse} Prolog 35language. 36A complete specification of the syntax is provided and comparison to 37other commercial Prolog systems are made. The {\eclipse} syntax is based on that 38of Edinburgh Prolog (\cite{bowen81}). 39 40 41\section{Notation} 42The following notation is used in the syntax specification in this chapter: 43\begin{itemize} 44\item a \notation{term_h} is a term which is the head of the clause. 45\item a \notation{term_h(N)} is a \notation{term_h} of maximum 46 precedence \about{N}. 47\item a \notation{term_g} is a term which is a goal (body) of the clause. 48\item a \notation{term_g(N)} is a \notation{term_g} of maximum 49 precedence \about{N}. 50\item a \notation{term_a} is a term which is an argument of a compound term or 51 a list. 52\item a \notation{term(N)} can be any term (\notation{term_h}, 53 \notation{term_a} or \notation{term_h}) 54 of maximum precedence \about{N}. 55\item \notation{fx(N)} is a prefix operator of precedence \about{N} which is not 56 right associative. 57\item \notation{fy(N)} is a prefix operator of precedence \about{N} which is 58 right 59 associative. 60\item similar definitions apply for infix (\notation{xfx}, \notation{xfy}, 61 \notation{yfx}) and postfix (\notation{xf}, \notation{yf}) operators. 62\end{itemize} 63 64\subsection{Character Classes} 65\label{charclass} 66\index{character class} 67 68The following character classes exist: 69\vspace{0.3cm} 70 71\begin{tabular}{lll} 72\heading{Character Class} & \heading{Notation Used } 73 & \heading{Default Members} \\ 74\\ 75upper_case & \notation{UC} &all upper case letters\\ 76underline & \notation{UL} &\verb+_+\\ 77lower_case & \notation{LC} &all lower case letters\\ 78digit & \notation{N} &digits\\ 79blank_space & \notation{BS} &space, tab and nonprintable ASCII characters\\ 80end_of_line & \notation{NL} &line feed\\ 81atom_quote & \notation{AQ} &\verb+'+\\ 82string_quote & \notation{SQ} &\verb+"+\\ 83list_quote & \notation{LQ} & \\ 84chars_quote & \notation{CQ} & \\ 85radix & \notation{RA} & \\ 86ascii & \notation{AS} & \\ 87solo & \notation{SL} &\verb+! ; +\\ 88special & \notation{DS} &\verb+( [ { ) ] } , | +\\ 89line_comment & \notation{CM} &\verb+%+\\ 90escape & \notation{ES} &\verb+\+\\ 91first_comment & \notation{CM1} &\verb+/+\\ 92second_comment & \notation{CM2} &\verb+*+\\ 93symbol & \notation{SY} &\verb/# + - . : < = > ? @ ^ ` ~ $ & /\\ 94terminator & \notation{TS} & \\ 95\end{tabular} 96 97The character class of any character can be modified by a 98\biptxtref{chtab-declaration}{set_chtab/2}{../bips/kernel/syntax/set_chtab-2.html}. 99 100 101\subsection{Groups of characters} 102 103\begin{flushleft} 104\begin{tabular}{lll} 105\\ 106\heading{Group Type} & \heading{Notation} & \heading{Valid Characters} \\ 107\\ 108alphanumerical & \notation{ALP} 109 &\notation{UC} \notation{UL} \notation{LC} \notation{N}\\ 110non escape & \notation{NES} &any character except escape\\ 111sign & \notation{SGN} &\verb'+ -'\\ 112\end{tabular} 113\end{flushleft} 114 115 116\subsection{Valid Tokens} 117\label{tokendef} 118 119Terms are defined in terms of tokens, and tokens are defined in terms of 120characters and character classes. 121Individual tokens can be read with the predicates 122\bipref{read_token/2}{../bips/kernel/iochar/read_token-2.html} and 123\bipref{read_token/3}{../bips/kernel/iochar/read_token-3.html}. 124The description of the valid tokens follows. 125 126\vfill %<<<<<<<<<<<<<<<<<<<<< 127 128\subsubsection{Atoms} 129 130\begin{verbatim} 131ATOM = (LC ALP*) 132 | (SY | CM1 | CM2 | ES)+ 133 | (AQ (NES | ESCSEQ)* AQ) 134 | SL 135 | [] 136 | {} 137 | | 138\end{verbatim} 139If the syntax option \notation{doubled_quote_is_quote} is enabled, two 140immediately consecutive AQ characters may occur inside an AQ-quoted sequence, 141and will be interpreted as a single occurrence of the quote within the name. 142If the syntax option \notation{bar_is_no_atom} is active, the vertical bar 143cannot be used as an atom, unless quoted. 144 145\subsubsection{Numbers} 146 147\begin{enumerate} 148 149\item\heading{integers} 150\begin{verbatim} 151INT = [SGN] N+ 152\end{verbatim} 153 154\item\heading{based integers} 155\begin{verbatim} 156INTBAS = [SGN] N+ (AQ | RA) (N | LC | UC)+ 157\end{verbatim} 158The base must be an integer between 1 and 36 included, the value 159being valid for this base. 160 161If the syntax option \notation{iso_base_prefix} is active, the syntax for 162based 163integers is instead 164\begin{verbatim} 165INTBAS = [SGN] 0 (b | o | x) (N | LC | UC)+ 166\end{verbatim} 167which allows binary, octal and hexadecimal numbers respectively. 168 169\item\heading{character codes} 170\label{intchar} 171\begin{verbatim} 172INTCHAR = [SGN] (0 (AQ|RA)|AS) CHARCONST 173\end{verbatim} 174For all plain characters, CHARCONST is just that character, and the 175value of the integer is the character code of that character. 176For special characters, see the detailed definition 177of CHARCONST below \ref{charconst}. 178 179\item\heading{rationals} 180\begin{verbatim} 181RAT = [SGN] N+ UL N+ 182\end{verbatim} 183 184\item\heading{floats} 185\begin{verbatim} 186FLOAT = [SGN] N+ . N+ [ (e | E) [SGN] N+ | Inf ] 187 | [SGN] N+ (e | E) [SGN] N+ 188\end{verbatim} 189If the syntax option \notation{float_needs_point} is active, then 190only the first alternative (with floating point) is valid syntax. 191 192\item\heading{bounded reals} 193\begin{verbatim} 194BREAL = FLOAT UL UL FLOAT 195\end{verbatim} 196where the first float must be less or equal to the second. 197 198\end{enumerate} 199 200If the syntax option \notation{blanks_after_sign} is active, then 201blank space (\notation{BS*}) is allowed between the sign and the following 202digits. 203 204 205\subsubsection{Strings} 206\begin{verbatim} 207STRING = SQ (NES | ESCSEQ | SQ BS* SQ)* SQ 208\end{verbatim} 209Text enclosed in SQ (string_quote) characters is parsed as a constant of type 210string. By default, the double quote \verb.". is the SQ character. 211 212By default, consecutive strings are concatenated into a single string. 213This behaviour can be disabled by the syntax option 214\notation{doubled_quote_is_quote}, which causes doubled quotes to be 215interpreted as a single occurrence of the quote within the string. 216 217\subsubsection{Lists of numeric character codes} 218\begin{verbatim} 219LIST = LQ (NES | ESCSEQ | LQ BS* LQ)* LQ 220\end{verbatim} 221Text enclosed in LQ (list_quote) characters is parsed as a list of numeric 222character codes. For example, if the double quote \verb.". is defined as 223list_quote, then \verb."abc". is parsed as \verb.[97,98,99].. 224 225By default, consecutive character lists are concatenated into a single character 226list. 227This behaviour can be disabled by the syntax option 228\notation{doubled_quote_is_quote}, which causes doubled quotes to be 229interpreted as a single occurrence of the quote within the string. 230 231\subsubsection{Lists of single-character atoms} 232\begin{verbatim} 233LIST = CQ (NES | ESCSEQ | CQ BS* CQ)* CQ 234\end{verbatim} 235Text enclosed in CQ (chars_quote) characters is parsed as a list of single-atom 236characters. For example, if the double quote \verb.". is defined as 237chars_quote, then \verb."abc". is parsed as \verb.['a','b','c'].. 238 239By default, consecutive character lists are concatenated into a single character 240list. 241This behaviour can be disabled by the syntax option 242\notation{doubled_quote_is_quote}, which causes doubled quotes to be 243interpreted as a single occurrence of the quote within the string. 244 245\subsubsection{Variables} 246\begin{verbatim} 247VAR = (UC | UL) ALP* 248\end{verbatim} 249 250\subsubsection{End of clause} 251\begin{verbatim} 252EOCL = . (BS | NL | <end of file>) | TS | <end of file> 253\end{verbatim} 254If the syntax option \notation{iso_restrictions} is active, 255then end-of-file alone does not act as EOCL. 256 257 258\subsubsection{Escape Sequences within Quotes} 259\index{escape sequence} 260Within quoted constants (atoms, strings, character lists), the following 261escape sequences ESCSEQ may occur, and lead to 262the corresponding special character being inserted into the quoted item. 263\begin{flushleft} 264\begin{tabular}{lll} 265\heading{ESCSEQ =} & \heading{Result} & \heading{Syntax option}\\ 266ES \verb'a' & ASCII alert (7) &\\ 267ES \verb'b' & ASCII backspace (8) &\\ 268ES \verb'f' & ASCII form feed (12) &\\ 269ES \verb'n' & ASCII newline (10) &\\ 270ES \verb'r' & ASCII carriage return (13) &\\ 271ES \verb't' & ASCII tabulation (9) &\\ 272ES \verb'v' & ASCII vertical tab (11) &\\ 273ES \verb'e' & ASCII escape (27) & not iso_restrictions\\ 274ES \verb'd' & ASCII delete (127) & not iso_restrictions\\ 275ES \verb's' & ASCII space (32) & not iso_restrictions\\ 276ES (ES|AQ|SQ|LQ|CQ) & the ES,AQ,SQ,LQ or CQ character &\\ 277ES NL & ignored &\\ 278ES \verb'c' (BS\verb'|'NL)* & ignored & not iso_restrictions\\ 279ES three octal digits & character with given octal character code & not iso_escapes\\ 280ES octal digits ES & character with given octal character code & iso_escapes\\ 281ES \verb'x' hex digits ES & character with given hexadecimal character code &\\ 282\end{tabular} 283\end{flushleft} 284It is illegal for any other character to follow the ES. 285If the syntax option \notation{iso_escapes} is active, the octal escape 286sequence can be of any length and must be terminated with an ES character. 287Some sequences are disabled by the \notation{iso_restrictions} option. 288 289\subsubsection{Character Constants} 290\label{charconst} 291\index{character constant} 292An integer character constant (see \ref{intchar}) 293is by default introduced by the sequence \verb.0'. 294and followed by CHARCONST, which is defined as one of the following: 295\begin{flushleft} 296\begin{tabular}{lll} 297\heading{CHARCONST =} & \heading{Represents} & \heading{Syntax option}\\ 298(ALP|SL|DS|CM|CM1|CM2|SY|TS) & that character&\\ 299<SPACE> & ASCII space (32) &\\ 300(SQ|LQ|CQ) & the SQ,LQ or CQ character &\\ 301ES (ES|AQ|SQ|LQ|CQ) & the ES,AQ,SQ,LQ or CQ character &\\ 302ES \verb'a' & ASCII alert (7) &\\ 303ES \verb'b' & ASCII backspace (8) &\\ 304ES \verb'f' & ASCII form feed (12) &\\ 305ES \verb'n' & ASCII newline (10) &\\ 306ES \verb'r' & ASCII carriage return (13) &\\ 307ES \verb't' & ASCII tabulation (9) &\\ 308ES \verb'v' & ASCII vertical tab (11) &\\ 309AQ AQ & the AQ character itself & iso_escapes and doubled_quote_is_quote\\ 310ES octal digits ES & character with given octal character code & iso_escapes\\ 311ES \verb'x' hex digits ES & character with given hexadecimal character code &\\ 312<TAB> & ASCII tabulation (9) & not iso_escapes\\ 313NL & ASCII newline (10) & not iso_escapes\\ 314AQ & the AQ character itself & not iso_escapes\\ 315ES & the ES character itself & not iso_escapes\\ 316ES \verb'e' & ASCII escape (27) & not iso_restrictions\\ 317ES \verb'd' & ASCII delete (127) & not iso_restrictions\\ 318ES \verb's' & ASCII space (32) & not iso_restrictions\\ 319\end{tabular} 320\end{flushleft} 321It is recommended to use only those sequences that are recognised universally, 322i.e.\ independent of syntax option settings. The other sequences are present 323for compatibility with various Prolog dialects. The syntax options 324\notation{iso_escapes} and \notation{iso_restrictions} disable several 325of those. The AQ AQ sequence is of dubious value -- it is recommended to 326write \verb.0'\'. instead of \verb.0'''.. 327 328 329\section{Formal definition of clause syntax} 330What follows is the specification of the syntax. The terminal symbols are 331written in UPPER CASE or as the character sequence they consist of. 332\index{attributed variable} 333\index{subscript} 334\index{structure} 335\begin{verbatim} 336program ::= clause EOCL 337 | clause EOCL program 338 339clause ::= head 340 | head rulech goals 341 | rulech goals 342 343head ::= term_h 344 345goals ::= term_g 346 | goals , goals 347 | goals ; goals 348 | goals -> goals 349 | goals -> goals ; goals 350 351term_h ::= term_h(0) 352 | term(1200) 353 354term_g ::= term_g(0) 355 | term(1200) 356 357term(0) ::= VAR /* not a term_h */ 358 | attr_var /* not a term_h */ 359 | ATOM 360 | structure 361 | structure_with_fields 362 | subscript 363 | list 364 | STRING /* not a term_h nor a term_g */ 365 | number /* not a term_h nor a term_g */ 366 | bterm 367 368term(N) ::= term(0) 369 | prefix_expression(N) 370 | infix_expression(N) 371 | postfix_expression(N) 372 373prefix_expression(N) ::= fx(N) term(N-1) 374 | fy(N) term(N) 375 | fxx(N) term(N-1) term(N-1) 376 | fxy(N) term(N-1) term(N) 377\end{verbatim} 378\vfill\pagebreak %<<<<<<<<<<<<<<<<<<<<<<<<~ 379\begin{verbatim} 380infix_expression(N) ::= term(N-1) xfx(N) term(N-1) 381 | term(N) yfx(N) term(N-1) 382 | term(N-1) xfy(N) term(N) 383 384postfix_expression(N) ::= term(N-1) xf(N) 385 | term(N) yf(N) 386 387attr_var ::= VAR { attributes } 388 /* Note: no space before { */ 389 390attributes ::= attribute 391 | attribute , attributes 392 393attribute ::= qualified_attribute 394 | nonqualified_attribute 395 396qualified_attribute ::= ATOM : nonqualified_attribute 397 398nonqualified_attribute ::= term_a 399 400structure ::= functor ( termlist ) 401 /* Note: no space before ( */ 402 403structure_with_fields ::= functor { termlist } 404 | functor { } 405 /* Note: no space before { */ 406 407subscript ::= structure list 408 | VAR list 409 /* Note: no space before list */ 410 411termlist ::= term_a 412 | term_a , termlist 413 414list ::= [ listexpr ] 415 | .(term_a, term_a) 416 417listexpr ::= term_a 418 | term_a | term_a 419 | term_a , listexpr 420 421term_a ::= term(1200) 422 /* Note: it depends on syntax_options */ 423 424\end{verbatim} 425\vfill\pagebreak %<<<<<<<<<<<<<<<<<<<<<<<<~ 426\begin{verbatim} 427 428number ::= INT 429 | INTBAS 430 | INTCHAR 431 | RAT 432 | FLOAT 433 | BREAL 434 435bterm ::= ( clause ) 436 | { clause } 437 438functor ::= ATOM /* arity > 0 */ 439 440rulech ::= :- 441 | ?- 442\end{verbatim} 443 444 445 446\subsection{Comments} 447 448There are two types of comments: bracketed comments, which are enclosed 449by CM1-CM2 and CM2-CM1, and the end-of-line comment, which is enclosed 450by CM and NL. Both types of comment behave as separators. 451When the syntax option \notation{nested_comments} is on (the default is off), 452bracketed comments can be nested. 453 454 455\subsection{Operators} 456\index{operator} 457In Prolog, the user is able to modify the syntax dynamically by explicitly 458declaring new operators. The built-in 459\bipref{op/3}{../bips/kernel/syntax/op-3.html} performs this 460task. As in Edinburgh Prolog, a lower precedence value means that the 461operator binds more strongly (1 strongest, 1200 weakest). 462 463Any atom (whether symbolic, alphanumeric, or quoted) can be declared as an 464operator. Once an operator has been declared, the parser will accept 465the corresponding operator notation, and certain output built-ins will 466produce the operator notation if possible. There are three classes of 467operators: prefix, infix and postfix. 468\index{prefix operator}\index{operator!prefix} 469\index{infix operator}\index{operator!infix} 470\index{postfix operator}\index{operator!postfix} 471\begin{itemize} 472\item When \notation{f} is declared as a 473 prefix unary operator (\notation{fx} or 474 \notation{fy}), then the term \notation{f(X)} can alternatively be written as 475 \notation{f~X}. 476\item When \notation{f} is declared as a prefix binary operator (\notation{fxx} 477 or \notation{fxy}), then the term \notation{f(X,Y)} can alternatively be 478 written as \notation{f~X~Y}. 479\item When \notation{f} is declared as a postfix operator (\notation{xf} or 480 \notation{yf}), then the term \notation{f(X)} can alternatively be written as 481 \notation{X~f}. 482\item When \notation{f} is declared an an infix operator (\notation{xfx}, 483 \notation{xfy} or \notation{yfx}), then the term \notation{f(X,Y)} can 484 alternatively be written as \notation{X~f~Y}. 485\end{itemize} 486An operator can belong to more than one class, e.g., the plus sign 487is both a prefix and an infix operator at the same time. 488 489In the associativity specification of an operator (e.g., \notation{fx}, 490\notation{yfx}), \notation{x} 491represents an argument whose precedence must be lower than that of the 492operator. \notation{y} represents an argument whose precedence must be lower or 493equal to that of the operator. \notation{y} should be used if one wants to 494allow 495chaining of operators (i.e., if one wants them to be associative). The position 496of the \notation{y} will determine the 497grouping within a chain of operators. For example: 498\begin{quote} 499\begin{verbatim} 500Example declaration will allow to stand for 501--------------------------------------------------------------- 502:- op(500,xfx,in). A in B in(A,B) 503:- op(500,xfy,in). A in B in C in(A,in(B,C)) 504:- op(500,yfx,in). A in B in C in(in(A,B),C) 505:- op(500,fx ,pre). pre A pre(A) 506:- op(500,fy ,pre). pre pre A pre(pre(A)) 507:- op(500, xf,post). A post post(A) 508:- op(500, yf,post). A post post post(post(A)) 509:- op(500,fxx,bin). bin A B bin(A,B) 510:- op(500,fxy,bin). bin A bin B C bin(A,bin(B,C)) 511\end{verbatim} 512\end{quote} 513 514Operator declarations are usually local to a module, but they can be 515exported and imported. The operator visible in a module is either the 516local one (if any), an imported one, or a predefined one. 517Some operators are pre-defined (see Appendix \ref{chapopers} on 518page \pageref{chapopers}). They may be locally redefined if desired. 519 520Note that parentheses are used to build expressions with precedence zero 521and thus to override operator declarations.\footnote{% 522 Quotes, on the other hand, are used to build atoms from characters 523 with different or mixed character classes; they do not change 524 the precedence of operators.} 525 526 527\subsection{Operator Ambiguities} 528\index{ambiguity}\index{operator!ambiguity} 529Unlike the canonical syntax, operator syntax can lead to ambiguities. 530\begin{itemize} 531\item 532\index{prefix ambiguity} 533For instance, when a prefix operator is followed by an infix or postfix 534operator, the prefix is often not meant to be a prefix operator, but 535simply the left hand side argument of the following infix or postfix. 536In order to decide whether that is the case, {\eclipse} uses the operator's 537relative precedences and their associativities, and, if necessary, 538a two-token lookahead. If this rules out the prefix-interpretation, then 539the prefix is treated as a simple atom. In the rare case where this 540limited lookahead is not enough to disambigute, the prefix must be 541explicitly enclosed in parentheses. 542 543\item 544\index{infix/postfix ambiguity} 545Another source of ambiguity are operators which have been declared 546both infix and postfix. In this case, {\eclipse} uses a one-token 547lookahead to check whether the infix-interpretation can be ruled out. 548If yes, the operator is interpreted as postfix, otherwise as infix. 549Again, in rare cases parentheses may be necessary to enforce the 550interpretation as postfix. 551 552\item 553\index{prefix/infix ambiguity} 554When a binary prefix operator is followed by an infix operator, then 555either of them could be the main functor. Faced with the ambiguity, the 556system will prefer the infix interpretation. To force the binary prefix 557to be recognised, the infix must be enclosed in parentheses. 558\end{itemize} 559 560 561 562% ---------------------------------------------------------------------- 563\section{Syntax Differences between {\eclipse} and other Prologs} 564% ---------------------------------------------------------------------- 565\label{syntaxdiff} 566\index{syntax differences of {\eclipse}} 567 568{\eclipse} supports the following extensions of Prolog syntax: 569\begin{itemize} 570\item Attributed variables: \notation{X\{Attr\}}. 571\item Rational numbers: \notation{3_4}. 572\item Bounded real numbers: \notation{1.99__2.01}. 573\item Array subscripts: \notation{Matrix[3,4]}. 574\item Structures with named fields: \notation{emp\{age:33,salary:33000\}}. 575\item Binary prefix operators: \notation{some~X~p(X)}. 576\end{itemize} 577Some of these extensions can be disabled via syntax option settings 578(this is done for example by the compatibility packages). 579In addition to the above extensions, the following minor differences 580exist between default {\eclipse} syntax and most Prolog systems: 581\begin{itemize} 582\item In {\eclipse}, end of file is accepted as fullstop. 583 584\item By default, an unquoted vertical bar can be used as an atom or 585 functor (controlled by the syntax option \notation{bar_is_no_atom}). 586 587\item By default, operators with precedence higher than 1000 are allowed 588 in a comma-separated list of terms, i.e., structure arguments 589 and lists. The ambiguity is resolved by considering commas 590 as argument separators rather than operators inside the term. 591 Thus, for example, 592\begin{quote} 593\begin{verbatim} 594p(a :- b, c) 595\end{verbatim} 596\end{quote} 597 is accepted and parsed as \notation{p/2}. This behaviour can be disabled 598 (and turned into a syntax error) by setting the syntax option 599 \notation{limit_arg_precedence}. 600 601\item By default, double-quoted items are parsed as strings, not as character 602 lists. This behaviour can be changed via 603 \bipref{set_chtab/2}{../bips/kernel/syntax/set_chtab-2.html} 604 which allows string-quotes, list-quotes and atom-quotes to be redefined. 605 606\item By default, consecutive string- or list-quotes have the effect of 607 concatenating the quoted items, while consecutive atom-quotes have 608 no special meaning. This can be changed by using the syntax option 609 \notation{doubled_quote_is_quote}. 610 611\item By default, blank space between a sign and a number is significant: 612 When there is no space between sign and number, the sign is taken as 613 part of the number. With space, the sign is taken as prefix operator. 614 This is controlled by the syntax option \notation{blanks_after_sign}. 615\end{itemize} 616 617 618\section{Changing the Parser's behaviour} 619\indextt{syntax_option} 620Some of these properties can be changed by choosing one of the following 621syntax options (see \notation{syntax_options} in the description of 622\biptxtref{get_flag/2}{get_flag/2}{../bips/kernel/env/get_flag-2.html}). 623The following options exist (unless otherwise noted, the options are 624disabled by default): 625\begin{quote} 626\begin{description} 627\item[bar_is_no_atom:] disallow the use of an unquoted vertical bar as 628 atom or functor, except when it occurs in infix-position. 629\item[bar_is_semicolon:] translate occurrences of unquoted infix 630 vertical bars into terms with functor ;/2, e.g. \verb:(a|b) = (a;b):. 631\item[based_bignums:] Allow base notation even to write integers longer 632 than the wordsize (this implies they are always positive because the 633 most significant bit is not interpreted as a sign bit). 634\item[blanks_after_sign:] ignore blank space between a sign and a number 635 (by default, this space is significant and will lead to the sign 636 being taken as prefix operator rather than the number's sign). 637 Also allow signs of numbers to be quoted. 638\item[doubled_quote_is_quote:] parse a pair of quotes within a quoted item 639 as one occurrence of the quote within the string. If this option is off 640 (the default), consecutive string-quoted and list-quoted items are parsed 641 as a single (concatenated) item, and consecutive quoted atoms are parsed 642 as consecutive atoms. 643\item[float_needs_point:] require floating point numbers to be written 644 with a decimal point, e.g. \verb:1.0e-3: instead of \verb:1e-3:. 645\item[iso_escapes:] ISO-Prolog compatible escape sequences within 646 strings and atoms. 647\item[iso_base_prefix:] allow binary, octal or hexadecimal numbers to be 648 written 649 with 0b, 0o or 0x prefix respectively, and disallow the 650 \notation{base'number} notation. 651\item[iso_restrictions:] 652 enable all ISO-Prolog syntax restrictions that are not controlled 653 by individual settings. This includes: disallowing operators as 654 operands of operators; disallowing an atom to be declared as both 655 an infix and a postfix operator; restrictions on changing operator 656 properties for comma, vertical bar, and the empty-bracket atoms. 657\item[limit_arg_precedence:] 658 do not allow terms with a precedence higher than 999 as 659 structure arguments, unless parenthesised. 660\item[nested_comments:] allow bracketed comments to be nested. 661\item[nl_in_quotes:] allow newlines to occur inside quotes (default). 662\item[no_array_subscripts:] disallow the {\eclipse} specific array-subscript 663 syntax. 664\item[no_attributes:] disallow the {\eclipse} specific syntax for 665 variable attributes in curly braces. 666\item[no_blanks:] do not allow blanks between functor an opening parenthesis 667 (default). 668\item[no_curly_arguments:] disallow the {\eclipse} specific syntax for 669 structures with named arguments in curly braces. 670\item[plus_is_no_sign:] 671 do not interpret a plus sign preceding a number as the number's sign 672 (effectively ignoring it), but treat it as a possible prefix operator 673 \verb:+/1:. 674\item[read_floats_as_breals:] read all floating point numbers as bounded 675 reals rather than as floats. The resulting breal is a small interval 676 enclosing the true value of the number in decimal notation. 677\item[var_functor_is_apply:] allow variables as functors, and parse a term 678 like \notation{X(A,B,C)} as if it were \notation{apply(X,[A,B,C])}. 679\end{description} 680\end{quote} 681A number of further syntax options is provided for the purpose of parsing 682non-Prolog-like languages, in particular the Zinc family: 683\begin{quote} 684\begin{description} 685\item[atom_subscripts:] allow subscripts after atoms, and parse a term 686 like \notation{a[B,C]} as if it were \notation{subscript(a,[B,C])}. 687\item[general_subscripts:] allow subscripts after atoms, parenthesized 688 subterms and subscripted terms, and parse a term 689 such as \notation{a[B][C]} as if it were written in the form 690 \notation{subscript(subscript(a,[B]),[C])}, 691 or a term such as \notation{(a-b)[C]} as if it were 692 \notation{subscript(a-b,[C])}. 693\item[curly_args_as_list:] parse the arguments of a term in curly 694 brackets as a list, i.e., parse \notation{\{a,b,c\}} 695 as \notation{\{\}([a,b,c])} instead of the default \notation{\{\}((a,b,c))}. 696\end{description} 697\end{quote} 698Syntax option settings can be local to a module or exported, e.g., 699\begin{quote} 700\begin{verbatim} 701:- local syntax_option(not nl_in_quotes). 702:- export syntax_option(var_functor_is_apply). 703\end{verbatim} 704\end{quote} 705 706% ---------------------------------------------------------------------- 707\section{Short and Canonical Syntax} 708% ---------------------------------------------------------------------- 709 710The following table summarises the correspondence between the short syntax 711forms (supported by the parser and the term writer) and their corresponding 712canonical forms. Usually, the programmer does not have to be concerned about 713the canonical represention because the short syntax is accepted by the parser 714and reproduced by the term writer (unless canonical writing is explicitly 715requested). 716\begin{quote} 717\begin{verbatim} 718Known as Short Canonical Active 719------------------------------------------------------------------------ 720List [A|B] .(A,B) always 721Curly brackets {A} {}(A) always 722Subscripted variable X[...] subscript(X, [...]) default 723Subscripted struct S[...] subscript(S, [...]) default 724Declared structure f{...} with(f, [...]) default 725Attributed variable X{...} 'with attributes'(X, [...]) default 726Variable functor X(...) apply(X, [...]) optional 727\end{verbatim} 728\end{quote} 729Here \notation{A} and \notation{B} stand for arbitrary terms, \notation{X} for a 730variable, \notation{S} for a compound term in canonical syntax, \notation{f} for 731an arbitrary functor, and the ellipsis for a comma-separated sequence of 732arbitrary terms. 733 734%HEVEA\cutend 735