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


5.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 Expression 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_section:
    | declarations_line declarations_section

declarations_line: type name subsequent_name `;'

subsequent_name:
    | `,' name subsequent_name

statements_section:
    | 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_list:
    | elif_block elif_block_list

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

else_block:
    | `else' `{' block `}'

break_block: declarations_section break_statements_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 ‘cardinal’, ‘integer’, ‘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 integrals ‘cardinal’ and ‘integer’ and the real ‘real’).

The program completion syntax may be selected from the first occurence of a zero byte, the first occurence of an unmatched closing brace and the first occurence of a return introduced expression of some specified type.

See Program Completions.

See struct x1f4_c1_type.

In the latter case, the program syntax is amended as:

program: block

block: declarations_section statements_section return_statement

return_statement: `return' expression `;'

Next: Variables Collections, Previous: Imperative Language Interpreter Usage Outline, Up: Imperative Language Interpreter   [Index]