next up previous index
Next: Formal definition of clause Up: Syntax Previous: Introduction   Index

Subsections

Notation

The following notation is used in the syntax specification in this chapter:


Character Classes

The following character classes exist:

Character Class Notation Used Default Members
     
upper_case UC all upper case letters
underline UL _
lower_case LC all lower case letters
digit N digits
blank_space BS space, tab and nonprintable ASCII characters
end_of_line NL line feed
atom_quote AQ '
string_quote SQ "
list_quote LQ  
radix RA  
ascii AS  
solo SL ( ) ] }
special SP ! , ; [ { |
line_comment CM %
escape ES \
first_comment CM1 /
second_comment CM2 *
symbol SY # + - . : < = > ? @ ^ ` ~ $ &

The character class of any character can be modified by a chtab-declaration.

Groups of characters

Group Type Notation Valid Characters
     
alphanumerical ALP UC UL LC N
delimiter DE ) } ] , |
any character ANY  
non escape NES any character except escape
sign SGN + -


Valid Tokens

Terms are defined in terms of tokens, and tokens are defined in terms of characters and character classes. Individual tokens can be read with the predicates read_token/2 and read_token/3. The description of the valid tokens follows.

Constants

1.
atoms
ATOM    = (LC ALP*)
        | (SY | CM1 | CM2 | ES)+
        | (AQ (NES | ES ANY+)* AQ)
        | |
        | ;
        | []
        | {}
        | !

2.
numbers

(a)
integers
INT = [SGN] BS* N+

(b)
based integers
INTBAS = N+ (AQ | RA) (N | LC | UC)+
The base must be an integer between 1 and 36 included, the value being valid for this base.

If the syntax option iso_base_prefix is active, the syntax for based integers is instead

INTBAS = 0 (b | o | x) (N | LC | UC)+
which allows binary, octal and hexadecimal numbers respectively.

(c)
ASCII codes
ASCII = 0 (AQ | RA) ANY | AS ANY
The value of the integer is the ASCII code of the last character.

(d)
rationals
RAT = [SGN] BS* N+ UL N+

(e)
floats
FLOAT = [SGN] BS* N+ . N+ [ (e | E) [SGN] N+ | Inf ]
     | [SGN] BS* N+        (e | E) [SGN] N+
checks are performed that the numbers are in a valid range.

(f)
bounded reals
BREAL = FLOAT UL UL FLOAT
where the first float must be less or equal to the second.

3.
strings
STRING = SQ (NES | ES ANY+ | SQ BS* SQ)* SQ
By default, consecutive strings are concatenated into a single string. This behaviour can be disabled by the syntax option doubled_quote_is_quote, which causes doubled quotes to be interpreted as a single occurrence of the quote within the string.

4.
lists of ASCII codes
LIST = LQ (NES | ES ANY+ | LQ BS* LQ)* LQ
By default, consecutive character lists are concatenated into a single character list. This behaviour can be disabled by the syntax option doubled_quote_is_quote, which causes doubled quotes to be interpreted as a single occurrence of the quote within the string.

Variables

VAR = (UC | UL) ALP*

End of clause

EOCL = . (BS | NL | <end of file>) | <end of file>

Escape Sequences within Strings and Atoms

Within atoms and strings, the escape sequences (ES ANY+) are interpreted: if the sequence matches one of the following valid escape sequences, the corresponding special character is inserted into the quoted item.

Escape Sequence Result
ES a ASCII alert (7)
ES b ASCII backspace (8)
ES f ASCII form feed (12)
ES n ASCII newline (10)
ES r ASCII carriage return (13)
ES t ASCII tabulation (9)
ES v ASCII vertical tab (11)
ES e ASCII escape (27)
ES d ASCII delete (127)
ES ES the ES character itself
ES AQ the AQ character itself
ES SQ the SQ character itself
ES LQ the LQ character itself
ES NL ignored
ES c (BS|NL)* ignored
ES three octal digits character whose character code is the given octal value
ES x hex digits ES character whose character code is the given hexadecimal value
Any other character following the ES constitutes a syntax error. If the syntax option iso_escapes is active, the octal escape sequence can be of any length and must be terminated with an ES character.


next up previous index
Next: Formal definition of clause Up: Syntax Previous: Introduction   Index
Warwick Harvey
2004-08-07