The following notation is used in the syntax specification in this chapter:
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 | DS | ( [ { ) ] } , | |
| line_comment | CM | % |
| escape | ES | \ |
| first_comment | CM1 | / |
| second_comment | CM2 | * |
| symbol | SY | # + - . : < = > ? @ ^ ` ~ $ & |
| terminator | TS |
The character class of any character can be modified by a chtab-declaration.
| Group Type | Notation | Valid Characters |
| alphanumerical | ALP | UC UL LC N |
| any character | ANY | |
| non escape | NES | any character except escape |
| sign | SGN | + - |
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.
ATOM = (LC ALP*)
| (SY | CM1 | CM2 | ES)+
| (AQ (NES | ES ANY+)* AQ)
| SL
| []
| {}
| |
INT = [SGN] N+
INTBAS = [SGN] 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 = [SGN] 0 (b | o | x) (N | LC | UC)+
which allows binary, octal and hexadecimal numbers respectively.
INTCHAR = [SGN] 0 (AQ | RA) ANY | AS ANYThe value of the integer is the character code of the last character.
RAT = [SGN] N+ UL N+
FLOAT = [SGN] N+ . N+ [ (e | E) [SGN] N+ | Inf ]
| [SGN] N+ (e | E) [SGN] N+
checks are performed that the numbers are in a valid range.BREAL = FLOAT UL UL FLOATwhere the first float must be less or equal to the second.
If the syntax option blanks_after_sign is active, then
blank space (BS*) is allowed between the sign and the following digits.
STRING = SQ (NES | ES ANY+ | SQ BS* SQ)* SQBy 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.
LIST = LQ (NES | ES ANY+ | LQ BS* LQ)* LQBy 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.
VAR = (UC | UL) ALP*
EOCL = . (BS | NL | <end of file>) | TS | <end of file>
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.