Subsections

- 1 Symbols
- 2 Comments
- 3 Reserved words
  - 1 Turbo Pascal reserved words
  - 2 Delphi reserved words
  - 3 Free Pascal reserved words
  - 4 Modifiers
- 4 Identifiers
- 5 Numbers
- 6 Labels
- 7 Character strings

# 1 Pascal Tokens

In this chapter we describe all the pascal reserved words, as well as the various ways to denote strings, numbers, identifiers etc.

# 1 Symbols

Free Pascal allows all characters, digits and some special ASCII symbols in a Pascal source file.

> Recognised symbols

The following characters have a special meaning:

     + - * / = < > [ ] . , ( ) : ^ @ { } $ #

and the following character pairs too:

    <= >= := += -= *= /= (* *) (. .) //

When used in a range specifier, the character pair `(.` is equivalent to the left square bracket `[`. Likewise, the character pair `.)` is equivalent to the right square bracket `]`. When used for comment delimiters, the character pair `(*` is equivalent to the left brace `{` and the character pair `*)` is equivalent to the right brace `}`. These character pairs retain their normal meaning in string expressions.

# 2 Comments

Free Pascal supports the use of nested comments. The following constructs are valid comments:

    (* This is an old style comment *)
    {  This is a Turbo Pascal comment }
    // This is a Delphi comment. All is ignored till the end of the line.

The following are valid ways of nesting comments:

    { Comment 1 (* comment 2 *) }
    (* Comment 1 { comment 2 } *)
    { comment 1 // Comment 2 }
    (* comment 1 // Comment 2 *)
    // comment 1 (* comment 2 *)
    // comment 1 { comment 2 }

The last two comments must be on one line. The following two will give errors:

     // Valid comment { No longer valid comment !!
        }

and

     // Valid comment (* No longer valid comment !!
        *)

The compiler will react with a 'invalid character' error when it encounters such constructs, regardless of the `-So` switch.

# 3 Reserved words

Reserved words are part of the Pascal language, and cannot be redefined. They will be denoted as this throughout the syntax diagrams. Reserved words can be typed regardless of case, i.e. Pascal is case insensitive. We make a distinction between Turbo Pascal and Delphi reserved words, since with the `-So` switch, only the Turbo Pascal reserved words are recognised, and the Delphi ones can be redefined. By default, Free Pascal recognises the Delphi reserved words.

## 1 Turbo Pascal reserved words

The following keywords exist in Turbo Pascal mode

    absolute
    and
    array
    asm
    begin
    break
    case
    const
    constructor
    continue
    destructor
    div
    do
    downto
    else
    end
    file
    for
    function
    goto
    if
    implementation
    in
    inherited
    inline
    interface
    label
    mod
    nil
    not
    object
    of
    on
    operator
    or
    packed
    procedure
    program
    record
    repeat
    self
    set
    shl
    shr
    string
    then
    to
    type
    unit
    until
    uses
    var
    while
    with
    xor

## 2 Delphi reserved words

The Delphi (II) reserved words are the same as the pascal ones, plus the following ones:

    as
    class
    except
    exports
    finalization
    finally
    initialization
    is
    library
    on
    property
    raise
    try

## 3 Free Pascal reserved words

On top of the Turbo Pascal and Delphi reserved words, Free Pascal also considers the following as reserved words:

    dispose
    exit
    false
    new
    true

## 4 Modifiers

The following is a list of all modifiers. Contrary to Delphi, Free Pascal doesn't allow the programmer to redefine these modifiers.

    absolute
    abstract
    alias
    assembler
    cdecl
    default
    export
    external
    far
    forward
    index
    name
    near
    override
    pascal
    popstack
    private
    protected
    public
    published
    read
    register
    saveregisters
    stdcall
    virtual
    write

Remark: Predefined types such as `Byte`, `Boolean` and constants such as `maxint` are not reserved words. They are identifiers, declared in the system unit. This means that these types can be redefined in other units. The programmer is, however, not encouraged to do this, as it will cause a lot of confusion.

# 4 Identifiers

Identifiers denote constants, types, variables, procedures and functions, units, and programs. All names of things that are defined are identifiers. An identifier consists of 255 significant characters (letters, digits and the underscore character), from which the first must be an alphanumeric character, or an underscore (`_`) The following diagram gives the basic syntax for identifiers.

> Identifiers

# 5 Numbers

Numbers are denoted in decimal notation. Real (or decimal) numbers are written using engeneering notation (e.g. `0.314E1`). Free Pascal supports hexadecimal format the same way as Turbo Pascal does. To specify a constant value in hexadecimal format, prepend it with a dollar sign (`$`). Thus, the hexadecimal `$FF` equals 255 decimal. In addition to the support for hexadecimal notation, Free Pascal also supports binary notation. A binary number can be specified by preceding it with a percent sign (`%`). Thus, `255` can be specified in binary notation as `%11111111`. The following diagrams show the syntax for numbers.

> Numbers

# 6 Labels

Labels can be digit sequences or identifiers.

> Label

Remark: Note that the `-Sg` switch must be specified before labels can be used. By default, Free Pascal doesn't support `label` and `goto` statements.

# 7 Character strings

A character string (or string for short) is a sequence of zero or more characters from the ASCII character set, enclosed by single quotes, and on 1 line of the program source. A character set with nothing between the quotes (`''`) is an empty string.

> Character strings