• Keine Ergebnisse gefunden

USING THE UNDERSCORE CHARACTER

Im Dokument Pascal Reference (Seite 33-42)

The underscore ( ) is the only nonalphanumeric character allowed- in identifiers, and for this compiler the underscore is a significant character.

You can use the underscore to improve readability of identifier names in the same way you would use a space. For example, the identifiers in the right-hand column below are easier to read than those in the left-hand column.

POWEROFTEN MYDOGMAUDE

POWER OF TEN MY DOG MAUDE

You can also make identifiers more readable by using capitals for significant letters:

PowerOfTen MyDogMaude SEPARATORS

Separators delimit adjacent numbers, reserved words, and identifiers, none of which can have a separator embedded within it.

A separator can be any of the following ASCII characters:

o a space (ASCII code 20h) o a tab (ASCII code 09h) (~) o a formfeed (ASCII code 0Ch) (,) o a linefeed (ASCII Code 0Ah) (~)

o a comment

Always use a separator between an identifier and a number. If you fail to do so, the compiler gener-ally issues an error or warning message. In a few cases, however, a missing separator can be accepted.

For example, at the extend level, l00MOD#127

is accepted as 100 MOD #127, where #127 is a hexadecimal number. However,

l00MOD127

is assumed to be 100 followed by the identifier MOD127.

COMMENTS

Any character can be used wi thin a comment or string literal.

Comments in standard Pascal can span more than one line and take one of the following forms:

{This is a comment, enclosed in braces}

(*This is another form of comment*)

At the extend level, you can also begin comments wi th an exclamation point (1). For comments in this form, the linefeed delimits the comment.

Notation 2-3

Nested comments are permitted, so long as each level has different delimiters. Thus, when a com-ment is started. the compiler ignores succeeding text until it finds the matching end-of-comment.

Note that, such nested comments might not be portable.

SPECIAL SYMBOLS

Special symbols fall into three categories:

o punctuation o operators o reserved words PUNCTUATION

Table 2-1 below summarizes the use of several punctuation symbols.

Table 2-1. Summary of Punctuation.

(Page 1 of 2) Symbol

[ ]

:=

Purpose

Braces delimit comments.

Brackets delimit array indices, sets, and attributes. They can also replace the reserved words BEGIN and END in a program.

Parentheses parameter parameters.

delimit expressions, lists, and program Single quotation marks delimit string literals.

A colon directly followed by an equal

Tab1e 2-1. Summary of Punctuation.

(Page 2 of 2)

1

@

$

OPERATORS

A colon separates variables from types and labels from statements.

An equal sign separates identifiers and type clauses in a TYPE section.

A comma separates the components of a list.

A double period denotes a subrange.

A period designates the end of a program, indicates the fractional part. of a real number, and delimits fields in a record.

A caret denotes the value pointed to by a reference value. The question mark (1) and the at sign (@) are synonyms for the caret.

The question mark denotes the value pointed to by a reference value.

The at sign denotes the value pointed to by a reference value.

A number sign denotes numbers.

nondecimal A dollar sign prefixes metacommands.

Operators are a form of punctuation that indicate that an operation is to be performed. Some are alphabetic, others are one or two nonalphanumeric characters. Operators that consist of more than one character must not have a separator between the characters.

Notation 2-5

The operators that consist only of nonalphabetic characters are the following:

+

* /

> < <> <= >=

Some operators are reserved words, for example, NOT and DIV. (See below).

See Section 11, "Expressions," for a complete list of the nonalphabetic operators and a discussion of the use of operators in expressions.

RESERVED WORDS

Reserved words are used for names of attributes, directives, and features of the standard and extend levels of Pascal.

You cannot create an identifier that is the same as any reserved word. You can, however, declare an identifier that contains within it the letters of a reserved word (for example, the identi fier DOT containing the reserved word DO).

Reserved words are a fixed part of our version of Pascal. They include, for example, statement names, such as BREAK, and words such as BEGIN and END that bracket the main body of a program.

See Appendix D, "Summary Predeclared Identifiers,"

reserved words.

UNUSED CHARACTERS

of Reserved Words and for a complete list of

The following printing characters are not used by this version of Pascal:

% &

You can, however, use them within comments or string literals.

Error messages are generated if you use the following nonprinting ASCII characters in anything but a comment or string literal in a source file:

o ASCII characters 0 to 31 (0h to cepting the tab character (09h) formfeed character (0Ch)

IFh) , and

ex-the o ASCII characters 127 to 255 (7Fh to 0FFh) The tab character is treated as a space and is passed to the listing file. A formfeed is treated as a space and starts a new page in the listing file.

OTHER NOTES ON CHARACTERS

As an extension to the ISO standard, the question mark (?) or the at sign (@) can be substituted for a caret (A).

Table 2-2 characters character.

gives that

a list of represent

pairs the

of printing same ASCII

Table 2-2. Equivalent ASCII Characters.

ASCII Prints as 94

95

35 #

36 $

Equivalent Characters caret, up arrow

underscore, left arrow number sign, English pound sign

dollar sign, scarab (circle with four spikes)

Notation 2-7

3 IDENTIFIERS

Identifiers are names that denote the constants, variables, data types, procedures, functions, and other elements of a Pascal program. Procedures and functions must have identifiers: constants, data types, and variables usually are given identifiers, however they are not required to have them.

Some identifiers are predeclared: others you declare in a declaration section. Standard Pascal allows identifiers for the following elements of the Pascal language:

0 constants

0 types

0 variables

0 procedures

0 functions

0 programs

0 fields and tag fields in records

The following extend level features also can have identifiers:

o super array types o modules

o units

o statement labels

An identifier consists of a sequence of alpha-numeric characters or underscore characters. The first character must be alphabetic. Underscores in identifiers are allowed, and are significant, for example MY_IDENTIFIER.

Identifiers can be as long as you wish, as long as they fit on a single line. However, only the first 31 characters of an identifier are signifi-cant. The compiler generates a warning message, not a error, when an identi fier longer than 31 characters is encountered.

Identifiers 3-1

Standard Pascal allows unsigned integers as state-ment labels.

Extend level Pascal allows labels that are normal alphabetic identifiers.

Statement labels have the same scope rules as identifiers. (See the subsection "The Scope of An Identifier," below. ) Leading zeros are not significant.

Identifiers of seven characters or fewer save space during compilation.

NOTE

Most identifiers used internally by the runtime system are four alphabetic characters followed by the characters QQ. Avoid this form when creating new identifier names.

In addition, PUBLIC names should not begin with the characters XXX, as this can cause problems when the program is linked.

Im Dokument Pascal Reference (Seite 33-42)