• Aucun résultat trouvé

Character Sets

Dans le document OS PL/I (Page 22-25)

One of two character sets may be used to write a source program; either a

60-character set or a 48-60-character set. For a given external procedure, the choice

between the two sets is optional. In practice, this choice will depend upon the available equipment.

60-CHARACTER SET

The 60-character set is composed of

alphabetic characters, digits, and special characters.

There are 29 alphabetic characters

beginning with the currency symbol ($), the number sign (#), and the commercial "at"

sign

Cal,

which precede the 26 letters of the English alphabet in the IBM System/360 collating sequence Extended Binary Coded Decimal Interchange Code (EBCDIC). For use with languages other than English, other characters may be substituted for

$,

#, and

a.

There are ten digits. The decimal digits are the digits 0 through 9. A binary digit is either a 0 or a 1.

An alphameric character is either an alphabetic character or a digit.

There are 21 speCial characters. They are as follows:

Chapter 2: Program Elements

Character Blank

Equal sign or assignment symbol

Plus sign +

Minus sign

Asterisk or multiply symbol

*

Slash or divide symbol /

Left parenthesis (

Right parenthesis )

Comma

Point or period Single quotation mark

or apostrophe

Percent symbol %

Semicolon Colon

"Not" symbol

"And" symbol

&

·Or" symbol

I

"Greater than" symbol

>

"Less than" symbol

<

Break character

Question mark ?

special characters are combined to create other symbols. For example,

<=

means "less than or equal to", ~= means

"not equal to". The combination ** denotes exponentiation (X**2 means X2). Blanks are not permitted in such composite symbols.

The break character is the same as the typewriter underline character. It can be used in a name, such as GROSS PAY, to improve readability.

-48-CHARACTER SET

The 48-character set is composed of 48 characters of the 60-character set. In all but tour cases, the characters of the

reduced set can be combined to represent the missing characters from the larger set.

For example, the percent symbol (I) is not included in the 48-character set, but a double slash (//) can be used to represent i t . The four characters that are not duplicated are the commercial "at" ~ign,

the number sign, the break character, and the question mark.

The restrictions and changes for this character set are described in sect-ion B,

"Character sets with EBCDIC and card-Punch Codes" •

Chapter 2: Program Elements 9

USING THE CHARACTER SET

All the elements that make up a PL/I program are constructed from the PL/I character sets. There are two exceptions:

character-string constants and comments may contain any of the 256 characters

represented by an 8-bit code.

Certain characters perform specific functions in a PL/I program. For example, many characters function as operators.

There are four types of operators:

arithmetic, comparison, bit-string, and string.

The arithmetic operators are:

+ denoting addition or prefix plus denoting subtraction or prefix

minus

*

denoting multiplication / denoting division

**

denoting exponentiation The comparison operators are:

>

denoting "greater than"

... >

denoting "not greater than"

>=

denoting "greater than or equal to~

= denoting "equal to"

... =

denoting "not equal to"

<=

denoting "less than or equal

<

denoting "less than"

... <

denoting "not less than"

The bit-string operators are:

denoting "not"

& denoting "and"

I

denoting "or"

The string operator is:

II

denoting concatenation

to"

Figure 2.1 shows some of the functions of other special characters.

Identifiers

In a PL/I program, names or labels are given to data, files, statements, and entry points of different program areas. In creating a name or label, a programmer must observe the syntax rules for creating an identifier.

An identifier is a single alphabetic character or a string of alphameric and

10 OS PL/I CKT AND OPT LRM PART I

break characters, not contained in a comment or constant, and preceded and followed by a blank or some other delimiter; the initial character of the string must be alphabetic. The length must not exceed 31 characters.

Language keywords also are identifiers, possibly preceded by a percent symbol C%).

A keyword is an identifier that, when used in the proper context, has a specific meaning to the compiler. A keyword can specify such things as the action to be taken, the nature of data, the purpose of a name. For example, READ, DECIMAL, and ENDFILE are keywords. Some keywords can be abbreviated. A complete list of keywords and their abbreviations is contained in section C, "Keywords and Keyword

Abbreviations".

~: PL/I keywords are not reserved words. They are recognized as keywords by the compiler only when they appear in their proper context. In other contexts they may be used as programmer-defined identifiers.

Examples of identifiers that could be used for names or labels:

A FILE2 LOOP 3 RATE OF_PAY

#32

Some identifiers, as discussed in later chapters, cannot exceed seven characters in length and must not contain the break

character. This limitation is placed upon certain names, called external names, that may be referred to by the operating system or by more than one separately compiled procedure. If an external name of a PL/I procedure contains more than seven

characters, i t is truncated by the

compiler, which concatenates the first four characters with the last three characters.

The entry name of a COBOL or FORTAN routine may have up to eight characters. If more than eight characters are specified, the leftmost eight are taken.

Blanks

Blanks may be used freely throughout a PL/I program. They may surround operators and most other delimiters. In general, any number of blanks may appear wherever one blank is allowed, such as between words in a statement.

r---,

1

Name Character Use

1---1 comma separates elements of a list: precedes

l BY NAME option.

l 1

period Indicates decimal point or binary point:

I 1 l 1

semicolon assignment

symbol colon

blank

single quotation mark

parentheses

larrow

I

=

( )

->

connects elements of a qualified name Terminates statements

Indicates assignment of values1

Connects prefixes to statements: can be used in specification for bounds of an array; can be used in RANGE specification of DEFAULT statement

separates elements of a statement Encloses string constants and picture

specification

Enclose lists: specify information associated with various keywords; in conjunction with operators and operands, delimit portions of a computational expression

Denotes locator qualification

l percent symbol I Indicates statements to be executed by the

I

compile-time preprocessor or listing

l control statements

1---1

1

1Note that the character = can be used as an equal sign and as an assignment symbol.

1

L---__________ ---J

Figure 2.1. Some functions of special characters One or more blaDks must be used to

separate identifiers and constants that are not separated by some other delimiter or by a comment. However, identifiers, constants

(except character-string constants) and composite operators (for example, ~=)

cannot contain blanks.

other cases that require or permit blanks are noted in the text where the feature of the language is discussed. Some examples of the use of blanks are:

AB+BC is equivalent to AB + BC

TABLE(10) is equivalent to TABLE (10)

FIRST,SECOND is equivalent to FIRST, SECOND ATOB is

!!2!:

equivalent to A TO B

Comments

Comments are permitted wherever blanks are allowed in a program, except within data items, such as a character string. A comment is treated as a blank and can therefore be used in place of a required separating blank. Comments do not

otherwise affect execution of a program:

they are used only for documentation purposes. Comments may be coded on the same line as statements, either inserted between statements or in the Ddddle of them.

The general format of a comment is:

/* character-string

The character pair /* indicates the beginning of a cOlllllent. The same character pair reversed,

*/,

indicates its end. No blanks or other characters can separate the two characters of either composite pair;

the slash and the asterisk must be

Chapter 2: Program Elements 11

immediately adjacent. The comment itself may contain any characters except the

*/

combination, which would be interpreted as

terminating the comment. The initial

/*.

Dans le document OS PL/I (Page 22-25)