Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатика
ИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханика
ОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторика
СоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансы
ХимияЧерчениеЭкологияЭкономикаЭлектроника

Example of a type-definition-part

Читайте также:
  1. Example of a quantum gate
  2. Pauli-X gate example
  3. Study the table below. Go to Grammar Focus. Study the theory in detail. Find the examples of various parts of speech in the texts above.

type

natural = 0..maxint;

count = integer;

range = integer;

colour = (red, yellow, green, blue);

sex = (male, female);

year = 1900..1999;

shape = (triangle, rectangle, circle);

punchedcard = array [1..80] of char;

charsequence = file of char;

polar = record

r: real;

theta: angle

end;

indextype = 1..limit;

vector = array [indextype] of real;

person = ­ persondetails;

persondetails = record

name, firstname: charsequence;

age: natural;

married: Boolean;

father, child, sibling: person;

case s: sex of

male:

(enlisted, bearded: Boolean);

female:

(mother, programmer: Boolean)

end;

FileOfInteger = file of integer;

 

NOTE --- In the above example count, range, and integer denote the same type. The types denoted by year and natural are compatible with, but not the same as, the type denoted by range, count, and integer.

 

 

Declarations and denotations of variables

 

Variable-declarations

A variable shall be an entity to which a value can be attributed (see 6.8.2.2). Each identifier in the identifier-list of a variable-declaration shall denote a distinct variable possessing the type denoted by the type-denoter of the variable-declaration.

variable-declaration = identifier-list ':' type-denoter.

The occurrence of an identifier in the identifier-list of a variable-declaration of the variable-declaration-part of a block shall constitute its defining-point as a variable-identifier for the region that is the block. The structure of a variable possessing a structured-type shall be the structure of the structured-type. A use of a variable-access shall be an access, at the time of the use, to the variable thereby denoted. A variable-access, according to whether it is an entire-variable, a component-variable, an identified-variable, or a buffer-variable, shall denote a declared variable, a component of a variable, a variable that is identified by a pointer value (see 6.4.4), or a buffer-variable, respectively.

variable-access = entire-variable ½ component-variable ½ identified-variable ½ buffer-variable.

 

Example of a variable-declaration-part:

var

x, y, z, max: real;

i, j: integer;

k: 0..9;

p, q, r: Boolean;

operator: (plus, minus, times);

a: array [0..63] of real;

c: colour;

f: file of char;

hue1, hue2: set of colour;

p1, p2: person;

m, m1, m2: array [1..10, 1..10] of real;

coord: polar;

pooltape: array [1..4] of FileOfInteger;

date: record

month: 1..12;

year: integer

end;

 

NOTE --- Variables occurring in examples in the remainder of this International Standard should be assumed to have been declared as specified in the above example.

 

Entire-variables

entire-variable = variable-identifier.

variable-identifier = identifier.

 

Component-variables

 

General

A component of a variable shall be a variable. A component-variable shall denote a component of a variable. A reference or an access to a component of a variable shall constitute a reference or an access, respectively, to the variable. The value, if any, of the component of a variable shall be the same component of the value, if any, of the variable.

component-variable = indexed-variable ½ field-designator.

 


Дата добавления: 2015-11-26; просмотров: 92 | Нарушение авторских прав



mybiblioteka.su - 2015-2024 год. (0.007 сек.)