Next: , Previous: Imperative Language Interpreter Usage Outline, Up: Imperative Language Interpreter

4.2 Imperative Language Syntax

The imperative language syntax is much resembling the C syntax. It allows for prefix unary and infix binary operators, integral, real and string constants, variables and functions use, variables declaration and control statements.

As with C syntax, central to the language syntax is the expression syntax. The imperative language interpreter employs the expression evaluator for expression parsing and evaluation, hence the supported expression syntax is the one allowed by the expression evaluator.

See Syntax.

See Expression Evaluator.

The supported control statements are the C if, else, while, do while and break statements, their syntax and semantics being pretty much same as in C. An extra elif statement is borrowed from the C preprocessor, yet its syntax is C inspired.

Block opening and closing braces are mandatory.

Declarations must preceded statements within a block. Variable initialization is dissallowed.

A more formal syntax definition is:

program: block

block: declarations_section statements_section

    | declarations_line declarations_section

declarations_line: type name subsequent_name `;'

    | `,' name subsequent_name

    | statement_line statements_section

statement_line: `;'
    | expression `;'
    | `do' `{' break_block `}' `while' `(' expression `)' `;'
    | `if' `(' expression `)' `{' block `}' elif_block_list else_block
    | `while' `(' expression `)' `{' break_block `}'

    | elif_block elif_block_list

elif_block: `elif' `(' expression `)' `{' block `}'

    | `else' `{' block `}'

break_block: declarations_section break_statements_section

    | break_statement_line break_statements_section

break_statement_line: `break' `;'
    | statement_line

The variable declaration may refer one of the expression evaluator intrinsic types, identified by literals `mode', `real' and `text' or an application defined type.

See Intrinsic Types.

See Application Defined Types.

See Data Type Definition.

Test statements (either `if', `elif', `while' or `do' `while') may refer intrinsic scalar types only (the integral `mode' and real `real').