Previous Up Next

A.5  Changing the Parser’s behaviour

Some of these properties can be changed by choosing one of the following syntax options (see syntax_options in the description of get_flag/2). The following options exist (unless otherwise noted, the options are disabled by default):

bar_is_no_atom:
disallow the use of an unquoted vertical bar as atom or functor, except when it occurs in infix-position.
bar_is_semicolon:
translate occurrences of unquoted infix vertical bars into terms with functor ;/2, e.g. (a|b) = (a;b).
based_bignums:
Allow base notation even to write integers longer than the wordsize (this implies they are always positive because the most significant bit is not interpreted as a sign bit).
blanks_after_sign:
ignore blank space between a sign and a number (by default, this space is significant and will lead to the sign being taken as prefix operator rather than the number’s sign). Also allow signs of numbers to be quoted.
doubled_quote_is_quote:
parse a pair of quotes within a quoted item as one occurrence of the quote within the item (atom, string, or character list). If this option is off (the default), this is simply parsed as two consecutive items. In the case of strings and character lists, these consecutive items are concatenated into a single literal, unless the no_string_concatenation options is set.
eof_is_no_fullstop:
do not treat end-of-file as a fullstop.
float_needs_point:
require floating point numbers to be written with a decimal point, e.g. 1.0e-3 instead of 1e-3.
iso_escapes:
ISO-Prolog compatible escape sequences within strings and atoms.
iso_base_prefix:
allow binary, octal or hexadecimal numbers to be written with 0b, 0o or 0x prefix respectively, and disallow the base’number notation.
iso_restrictions:
enable all ISO-Prolog syntax restrictions that are not controlled by individual settings. This includes: disallowing operators as operands of operators; disallowing an atom to be declared as both an infix and a postfix operator; restrictions on changing operator properties for comma, vertical bar, and the empty-bracket atoms.
limit_arg_precedence:
do not allow terms with a precedence higher than 999 as structure arguments, unless parenthesised.
nested_comments:
allow bracketed comments to be nested.
nl_in_quotes:
allow newlines to occur inside quotes (default).
no_array_subscripts:
disallow the ECLiPSe specific array-subscript syntax.
no_attributes:
disallow the ECLiPSe specific syntax for variable attributes in curly braces.
no_blanks:
do not allow blanks between functor an opening parenthesis (default).
no_curly_arguments:
disallow the ECLiPSe specific syntax for structures with named arguments in curly braces.
no_string_concatenation:
do not parse consecutive string literals as a single (concatenated) string.
plus_is_no_sign:
do not interpret a plus sign preceding a number as the number’s sign (effectively ignoring it), but treat it as a possible prefix operator +/1.
read_floats_as_breals:
read all floating point numbers as bounded reals rather than as floats. The resulting breal is a small interval enclosing the true value of the number in decimal notation.
syntax_errors_fail:
the predicates of the read-family fail when encountering a syntax error (after printing an error message). Without this option, the predicates throw an error term of the form error(syntax_error(MessageString), context(...)).
var_functor_is_apply:
allow variables as functors, and parse a term like X(A,B,C) as if it were apply(X,[A,B,C]).

A number of further syntax options is provided for the purpose of parsing non-Prolog-like languages, in particular the Zinc family:

atom_subscripts:
allow subscripts after atoms, and parse a term like a[B,C] as if it were subscript(a,[B,C]).
general_subscripts:
allow subscripts after atoms, parenthesized subterms and subscripted terms, and parse a term such as a[B][C] as if it were written in the form subscript(subscript(a,[B]),[C]), or a term such as (a-b)[C] as if it were subscript(a-b,[C]).
curly_args_as_list:
parse the arguments of a term in curly brackets as a list, i.e., parse {a,b,c} as {}([a,b,c]) instead of the default {}((a,b,c)).

Syntax option settings can be local to a module or exported, e.g.,

:- local syntax_option(not nl_in_quotes).
:- export syntax_option(var_functor_is_apply).

Previous Up Next