4.17 HLA Character Set Constants and Character Set Expressions


4.17 HLA Character Set Constants and Character Set Expressions

HLA supports literal character set constants. These cset constants make it easy to initialize cset variables at compile time and they make it very easy to pass character set constants as procedure parameters. An HLA character set constant takes the following form:

 { Comma_separated_list_of_characters_and_character_ranges } 

The following is an example of a simple character set holding the numeric digit characters:

 { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' } 

When specifying a character set literal that has several contiguous values, HLA lets you concisely specify the values using only the starting and ending values of the range thusly:

 { '0'..'9' } 

You may combine characters and various ranges within the same character set constant. For example, the following character set constant is all the alphanumeric characters:

 { '0'..'9', 'a'..'z', 'A'..'Z' } 

You can use these cset literal constants in the const and val sections. The following example demonstrates how to create the symbolic constant AlphaNumeric using the character set above:

 const     AlphaNumeric: cset := {'0'..'9', 'a'..'z', 'A'..'Z' }; 

After the above declaration, you can use the identifier AlphaNumeric anywhere the character set literal is legal.

You can also use character set literals (and, of course, character set symbolic constants) as the initializer field for a static or readonly variable. The following code fragment demonstrates this:

 static      Alphabetic: cset := { 'a'..'z', 'A'..'Z' }; 

Anywhere you can use a character set literal constant, a character set constant expression is also legal. HLA supports the following operators in character set constant expressions:

 CSetConst + CSetConst           Computes the union of the two sets.[21] CSetConst * CSetConst           Computes the intersection of the two sets.[22] CSetConst - CSetConst           Computes the set difference of the two sets.[23] -CSetConst                      Computes the set complement.[24] 

Note that these operators only produce compile time results. That is, the expressions above are computed by the compiler during compilation; they do not emit any machine code. If you want to perform these operations on two different sets while your program is running, the HLA Standard Library provides routines you can call to achieve the results you desire.

[21]The set union is the set of all characters that are in either set.

[22]The set intersection is the set of all characters that appear in both operand sets.

[23]The set difference is the set of characters that appear in the first set but do not appear in the second set.

[24]The set complement is the set of all characters not in the set.




The Art of Assembly Language
The Art of Assembly Language
ISBN: 1593272073
EAN: 2147483647
Year: 2005
Pages: 246
Authors: Randall Hyde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net