Description of VEPRAN language

 

1. Expressions

2. Variables

3. Functions and procedures

4. Types and declarations

5. Program structure

6. Operators

7. Error messages

8. Syntax

 

 

1.  Expressions

 

1.1 Index - integer positive value , which takes values in the range 0 .. 65535

index operations :

comparison operations < > <= >= =

binary logical operations and, or

binary arithmetic operations + - div *

the unary logical not

unary arithmetic operators are + lg2 ex2

All the above operations are performed on the indexes and act in the body according to the descending order of precedence : unary ,binary arithmetic ,binary logical operations ,

comparison . In comparison operations and logical operations, TRUTH is induced by 0.

Example:      a*b<c                 (a*b)<c         0   if a*b<c

             not a div 2                (not a)/2       0/2  if à<>0

 

1.2 Expressions with slices

Expression of type SLICE can be

register X or

register Y or

the mask M or

a variable of type SLICE.

Example: X

Y

s (previously described slice s)

 

2. Variables

 

Variables can be of the following types:

INDEX

SLICE ,

user-defined type.

You can declare an array of variables of those types.

Constants was not typed and take integer values from 0 .. 65535 .

Example:

slice g[10],h,i[13];

const cOr=15;

 

3. Functions and procedures

 

You can write a procedure or function within another . Any function or procedure available only to the variables , parameters, and variables are described outside of the procedures and functions (global variables).

Possible recursive procedure calls. Specifiers settings REFER , CONST . CONST

preceded by immutable parameters REFER to parameters passed by reference . Specified before the type specifier applies to all list settings , then to the next parameter .

Specifier allows you to REFER passed as actual parameters to arrays of the specified type without control size .value returned value of the function should be assigned to the local variable RESULT.

Example:

FUNCTION func(REFER to index a[ ],CONST b; // variables passed by reference

// in this case b immutable

// a array without size

usertype c // a variable is passed by value

):slice; {function returns a value of type slice}

index d; {local variable}

begin

result:=x // returns the value of the register X

end;

 

4. Types and declarations

 

Description dynamic arrays allows you to specify and change the size of the array during program execution . For this purpose it is necessary to describe a variable as the array size , and then before the first

using execute the operator placement .

Example: program A;

 index i[ ];

 begin

   index i[1+2];

   i[0]:=1

 end.

The program can present the description of the user type.

TYPE type_name=type;

where type is one of the designs

        1      SLICE , INDEX , type_name

        2      RECORD

                 type field_name1 , .. , field_nameK;

                 ..

                 type field_nameN , .. , field_nameM

                END

        3      ARRAY [ size ] OF type

Further referencing variables user-defined type is a natural way : the fields through the point to elements of the array by specifying the index in square brackets . The elements of the array indexed by numbers from 0 to size-1.

Description of variables of this type : type_name name1,name2,..,nameK;

To describe the input data and results of the tasks are used accordingly keywords

The INPUT and OUTPUT .

Then describe variables of this type will be

INPUT INDEX var1,var2 ;// var1,var2 - input

OUTPUT INDEX var4,var5 ; // var4,var5 - output

INPUT OUTPUT INDEX var7,var8 ;//var7,var8 – input output

INPUT INDEX var10,OUTPUT var11;//var10 - input

                                                           // var11 - input output

When creating modules to include variables , functions or procedures in the interface part of the PUBLIC keyword is used.

Example:

PUBLIC procedure commonproc1; begin .. end ;

 PUBLIC slice s;

P.S.: All external user-defined types are automatically included in the front-end part.

 

5. Program structure

 

 PROGRAM program_name ;

 external_modules

 declaration_constants,types,variables,procedures,functions

 body

 .

6. Keywords

 

FOR .. [TO|DOWNTO] .. DO  - loop type for

WHILE .. DO                        - loop type while

BREAK ..                              - operator interrupt cycle

CONTINUE ..                       - operator continue cycle

IF .. THEN .. [ ELSE .. ]       - operator conditions

BEGIN                                  - the beginning of the operator unit

End                                         - the end of the operator unit

PROCEDURE                       - the beginning of a procedure Declaration

FUNCTION                          - beginning of the function Declaration

CONST                                                          - the beginning of the announcement of the list of constants specifier passing immutable parameter

INDEX                                   - base type

SLICE                                    - base type

DOWNTO                             - specifies the reverse direction account in the cycle type for

PROGRAM                           - program start

UNIT                                      - start module

REFER                                  - specifier passing a parameter by reference

TYPE                                     - start ads user-defined type

RECORD .. END                  - announcement record fields

ARRAY [ .. ] OF                   - array declaration

PUBLIC                                - is an access specifier

USES                                     - the beginning of the list of modules used

INPUT                                   - the input specifier

OUTPUT                               - specifier input

X , Y , M                                - slice CPU registers

 

7. Error messages

 

The compiler scans the program until the first found error .

 

8. Syntax .

 

 program::

  PROGRAM program_name ;

  external_modules

  declaration_constants,types,variables,procedures,functions

  body

 .

 module::

  UNIT module_name ;

   external_modules

  declaration_constants,types,variables,procedures,functions

  body

 

 body::

  begin operators_list end

 

 operators_list::

  operator

  operator ; operators_list

 

 operator::

  blank

  body

  operator_index_assignment

  operator_assignment

  label : cycle_operator

  cycle_operator

  BREAK label

  CONTINUE label

  IF expression THEN operator

  IF expression THEN operator ELSE operator

  processor_command

  allocation_operator

 

allocation_operator ::

 type_name variable_name [ expression ]

 

cycle_operator::

 FOR operator_index_assignment direction_attribute expression DO operator

 FOR ïåðåìåííàÿ TO expression direction_attribute operator

 WHILE expression DO operator

 

direction_attribute::

 TO

 DOWNTO

 

 operator_index_assignment::

  variable := expression

 

 operator_assignment::

  variable := variable

 

 variable::

  X

  Y

  M

  variable_name qualified_name

 

 qualified_name::

  blank

  . field_name qualified_name

  [ expression ] qualified_name

 

 external_modules::

  blank

  USES modules_list ;

 

 modules_list::

  module_name

  module_name , modules_list

 

 declaration_constants,types,variables,procedures,functions::

  LSP blank

  LSP declaration_constants //

   declaration_constants,types,variables,procedures,functions;

  LSP declaration_types //

   declaration_constants,types,variables,procedures,functions;

  LSP declaration_variables //

   declaration_constants,types,variables,procedures,functions;

  LSP declaration_procedure //

   declaration_constants,types,variables,procedures,functions;

  LSP declaration_function //

   declaration_constants,types,variables,procedures,functions;

 

 declaration_constants::

  CONST constants_list;

 

 constants_list::

  constant_name = constant_expression

  constant_name = constant_expression , constants_list

 

 declaration_type::

  type type_name=type ;

 

 type::

  SLICE

  FIELD

  INDEX

  type_name

  RECORD list_lists_fields END

  ARRAY [ constant_expression ] of type

 

 list_lists_fields::

  type list_fields

  type list_fields ;  list_lists_fields

 

 list_fields::

  field_name

  field_name ,  list_fields

 

 variables_declaration::

  type_name list_new_variables ;

 

 list_new_variables::

  new_variable

  new_variable , list_new_variables

 

 new_variable::

  LSP variable_name

  LSP variable_name [ constant_expression ]

 

 LSP(list of specifiers)::

  SP

  SP LSP

 

 SP(specifier)::

  blank

  INPUT

  OUTPUT

  PUBLIC

 

 procedure_declaration::

  procedure_header

   declaration_constants,types,variables,procedures,functios

   body

   ;

  

function_declaration::

  function_header

   declaration_local_constants,types,variables,procedures,functios

   body

   ;

 

 function_header::

  FUNCTION function_name(list_parameters_declaration):type_name;

  FUNCTION function_name:type_name;

 

 procedure_header::

  PROCEDURE procedure_name(list_parameters_declaration);

  PROCEDURE procedure_name;

 

 list_parameters_declaration::

  type_name list_parameters

  type_name list_parameters; list_parameters_declaration

  LSPT type_name list_parameters

  LSPT type_name list_parameters; list_parameters_declaration

 

 LSPT(list specifiers parameters transmission)::

  SPT

  LSPT SPT

 

 SPT(specifier parameters transmission)::

  REFER

  CONST

 

 list_parameters::

  parameter_name

  LSPT parameter_name

  list_parameters,parameter_name

  list_parameters,LSPT parameter_name