Previous Home Contents Next

Chapter 24: Formal syntax

24.1 Source

24.2 Lexical structure

24.3 Layout

24.4 Grammar

24.1 : Source

24.1.1 Source inclusions

24.1.2 Prepared source

24.1.3 Other system commands

Aldor source is a collection of lines containing a textual representation of a program.

Lines beginning with the character ``#'' are system commands and are not part of the program text.

24.1.1 : Source inclusions

Source inclusion collects the source lines which make up a program. This process is controled by the following system commands:

24.1.2 : Prepared source

The following commands allow source to be prepared by another program.

24.1.3 : Other system commands

Other system commands control the environment:

24.2 : Lexical structure

24.2.1 Characters

24.2.2 The escape character

24.2.3 Tokens

24.2.1 : Characters

The standard Aldor character set contains the following 97 characters:

Other characters may appear in source programs, but only in comments and string-style literals. Blank, tab and newline are called white space characters. All the special characters except quote, grave and ampersand are required for use in tokens. Grave and ampersand are reserved for future use.

24.2.2 : The escape character

Underscore is used as an ``escape'' character, which alters the meaning of the following text. The nature of the change depends on the context in which the underscore appears.

An escaped underscore is not an escape character.

An escape character followed by one or more white space characters causes the white space to be ignored. The remainder of this section assumes that escaped white space has been removed from the source.

24.2.3 : Tokens

The sequence of source characters is partitioned into tokens. The longest possible match is always used.

The tokens are classified as follows:

Comments and embedded white space are always ignored, except as used to separate tokens. For example, ``abc'' is taken as one token but ``a b c'' is taken as three.

24.3 : Layout

Normally page layout is not significant in an Aldor program. Within a ``#pile''/``#endpile'' pair, however, indendation and newlines have meaning, and are used to group collections of lines. Source within such a pair is in a piling context.

Indentation sensitivity may be turned off by enclosing source in a ``{''/``}'' pair. Within braces all white space -- leading, embedded, and newlines -- is ignored. This is a non-piling context. Piling and non-piling contexts may be nested.

The layout of a program in a piling context is understood by converting leading white space and newlines to special markers which are part of the language syntax.

This conversion follows the linearization rules:

These rules are applied from the most indented lines back out to the least indented lines.


Previous Home Contents Next