Next: , Previous: , Up: Procedural Language Interpreter   [Index]

6.2 Procedural Language Syntax

The procedural language syntax much resembles the C syntax. And the imperative language syntax to which it only adds functions.

See Imperative Language Syntax.

Functions are introduced much like in C: type, name, parentheses surrounded and comma separated arguments, braces surrounded body. The syntax for function bodies is the one of the imperative language.

For functions not returning void the last statement is a return introduced expression, whose type matches the function type. Exactly one return statement is allowed for non void returning functions, none for void returning functions. Implicit conversions are performed for the return expressions as required.

See Implicit Conversions.

Function forward declarations are supported.

The formal syntax definition is:

program: function subsequent_function

function: definition
    | declaration

definition: `void' name `(' arguments_list `)' `{' block `}'
    | type_other_than_void name `(' arguments_list `)' `{' block_return `}'

arguments_list: `void'
    | optionals_list
    | argument subsequent_argument
    | argument subsequent_argument `,' optionals_list

argument: typed_named_argument
    | typeless_anonymous_argument

typed_named_argument: type reference_class name

typeless_anonymous_argument: reference_class

block_return: block `return' expression `;'

declaration: type name `(' positions_list `)' `;'

positions_list: `void'
    | optionals_list
    | position subsequent_position
    | position subsequent_position `,' optionals_list

optionals_list: reference_class `...'

position: typed_position
    | typeless_position

typed_position: type reference_class
    | type reference_class name

typeless_position: reference_class

    | `&'

    | `,' position subsequent_position

    | `,' argument subsequent_argument

    | function subsequent_function

The ‘block’ syntax is same as for the imperative language syntax.

Functions may return no value (‘void’) or data of one of the intrinsic cardinal, integer and real types (‘cardinal’, ‘integer’, ‘real’ respectively).

See Intrinsic Types.

Non scalar returns (including the intrinsic string type) are possible, on application request and provided the return data types provision for.

See Non Scalar Function Returns.

One ‘main’ function, returning intrinsic integer data and having an empty arguments list, is expected.

Pass by reference is supported and introduced via the ‘&’ literal.

Functions may allow additional arguments.

See Variadics.

Function arguments may be typeless and anonymous.

See Typeless Anonymous Arguments.

Next: , Previous: , Up: Procedural Language Interpreter   [Index]