NetRexx expressions and variables

Cours NetRexx expressions and variables, tutoriel & guide de travaux pratiques en pdf.

Characters and Encodings

In the definition of a programming language it is important to emphasize the distinction between a character and the coded representation12 (encoding) of a character. The character “A”, for example, is the first letter of the English (Roman) alphabet, and this meaning is independent of any specific coded representation of that character. Different coded character sets (such as, for example, the ASCII13 and EBCDIC14 codes) use quite different encodings for this character (decimal values 65 and 193, respectively).
Except where stated otherwise, this document uses characters to convey meaning and not to imply a specific character code (the exceptions are certain operations that specifically convert between characters and their representations). At no time is NetRexx concerned with the glyph (actual appearance) of a character.

Character Sets

Programming in the NetRexx language can be considered to involve the use of two character sets. The first is used for expressing the NetRexx program itself, and is the relatively small set of characters described in the next section. The second character set is the set of characters that can be used as character data by a particular implementation of a NetRexx language processor. This character set may be limited in size (sometimes to a limit of 256 different characters, which have a convenient 8- bit representation), or it may be much larger. The Unicode15 character set, for example, allows for 65536 characters, each encoded in 16 bits.
Usually, most or all of the characters in the second (data) character set are also allowed within a NetRexx program, but only within commentary or immediate (literal) data.
The NetRexx language explicitly defines the first character set, in order that programs will be portable and understandable; at the same time it avoids restrictions due to the language itself on the character set used for data. However, where the language itself manipulates or inspects the data (as when carrying out arithmetic operations), there may be requirements on the data character set (for example, numbers can only be expressed if there are digit characters in the set).

Structure and General Syntax

A NetRexx program is built up out of a series of clauses that are composed of: zero or more blanks (which are ignored); a sequence of tokens (described in this section); zero or more blanks (again ignored); and the delimiter “ ;” (semicolon) which may be implied by line-ends or certain keywords. Conceptually, each clause is scanned from left to right before execution and the tokens composing it are resolved.
Identifiers (known as symbols) and numbers are recognized at this stage, comments (described below) are removed, and multiple blanks (except within literal strings) are reduced to single blanks. Blanks adjacent to operator characters (see page 43) and special characters (see page 43) are also removed.

Blanks and White Space

Blanks (spaces) may be freely used in a program to improve appearance and layout, and most are ignored. Blanks, however, are usually significant
• within literal strings (see below)
• between two tokens that are not special characters (for example, between two symbols or keywords)
• between the two characters forming a comment delimiter
• immediately outside parentheses (“(” and “)”) or brackets (“[” and “]”).
For implementations that support tabulation (tab) and form feed characters, these characters outside of literal strings are treated as if they were a single blank; similarly, if the last character in a NetRexx program is the End-of-file character (EOF, encoded in ASCII as decimal 26), that character is ignored.

Comments
Commentary is included in a NetRexx program by means of comments. Two forms of comment notation are provided: line comments are ended by the end of the line on which they start, and block comments are typically used for more extensive commentary.
Line comments A line comment is started by a sequence of two adjacent hyphens (“ –”); all characters following that sequence up to the end of the line are then ignored by the NetRexx language processor.

Example:
i=j+7 — this line comment follows an assignment
Block A block comment is started by the sequence of characters “/*”, and is ended by the
comments same sequence reversed, “*/”. Within these delimiters any characters are allowed
(including quotes, which need not be paired). Block comments may be nested, which
is to say that “/*” and “*/” must pair correctly. Block comments may be anywhere,
and may be of any length. When a block comment is found, it is treated as though it
were a blank (which may then be removed, if adjacent to a special character).

LIRE AUSSI :  Performances sur couche MAC des utilisateurs IEEE802.16e

Example:
/* This is a valid block comment */
40 NetRexx Language Definition Version 2.00
The two characters forming a comment delimiter (“/*” or “*/”) must be adjacent (that is, they may not be separated by blanks or a line-end).
Note: It is recommended that NetRexx programs start with a block comment that describes the program. Not only is this good programming practice, but some implementations may use this to distinguish NetRexx programs from other languages.
Implementation minimum: Implementations should support nested block comments to a depth of at least 10. The length of a comment should not be restricted, in that it should be possible to “comment out” an entire program.

Tokens
The essential components of clauses are called tokens. These may be of any length, unless limited by implementation restrictions,16 and are separated by blanks, comments, ends of lines, or by the nature of the tokens themselves.
The tokens are:
Literal A sequence including any characters that can safely be represented in an
strings implementation17 and delimited by the single quote character (‘) or the double-quote (« ). Use «  » to include a  » in a literal string delimited by « , and similarly use two single quotes to include a single quote in a literal string delimited by single quotes. A literal string is a constant and its contents will never be modified by NetRexx. Literal strings must be complete on a single line (this means that unmatched quotes may be detected on the line that they occur).
Any string with no characters (i.e., a string of length 0) is called a null string.

Examples:
‘Fred’
‘Aÿ’
« Don’t Panic! »
« 😡 »
‘You shouldn »t’ /* Same as « You shouldn’t » */
 » /* A null string */
Within literal strings, characters that cannot safely or easily be represented (for example “control characters”) may be introduced using an escape sequence. An escape sequence starts with a backslash (“\”), which must then be followed immediately by one of the following (letters may be in either uppercase or lowercase):
t the escape sequence represents a tabulation (tab) character
n the escape sequence represents a new-line (line feed) character
r the escape sequence represents a return (carriage return) character
fthe escape sequence represents a form-feed character
« the escape sequence represents a double-quote character
‘ the escape sequence represents a single-quote character
\the escape sequence represents a backslash character
– the escape sequence represents a “null” character (the character whose encoding equals zero), used to indicate continuation in a say instruction
0 (zero) the escape sequence represents a “null” character (the character whose encoding equals zero); an alternative to \-
xhh the escape sequence represents a character whose encoding is given by the two hexadecimal digits (“hh”) following the “x”. If the character encoding for the implementation requires more than two hexadecimal digits, they are padded with zero digits on the left.
uhhhh the escape sequence represents a character whose encoding is given by the four hexadecimal digits (“hhhh”) following the “u”. It is an error to use this escape if the character encoding for the implementation requires fewer than four hexadecimal digits.
Hexadecimal digits for use in the escape sequences above may be any decimal digit (0–
9) or any of the first six alphabetic characters (a–f), in either lowercase or uppercase.

Introduction 
Language objectives
Language concepts
Acknowledgements
NetRexx Overview 
NetRexx programs
Expressions and variables
Control instructions
NetRexx arithmetic
Doing things with strings
Parsing strings
Indexed strings
Arrays
Things that aren’t strings
Extending classes
Tracing
Binary types and conversions
Exception and error handling
NetRexx Language Definition
Notations 38
Characters and Encodings
Structure and General Syntax
Blanks and White Space
Comments
Do instruction
Package instruction
Minor and Dependent classes
Parsing templates
Numbers and Arithmetic 
Introduction
Definition
Binary values and operations
Exceptions
Methods for NetRexx strings
The built-in methods
Appendix

Cours gratuitTélécharger le cours complet

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *