After reading previous page, your're sure to know, what a subtype is. Then you can to skip over this paragraph. For the others, who skipped previous page(click and read it) or cannot remember (click and recall), subtypes are used for specifying only valid range of values for specific situation from any type. For example, if you are measuring humidity and use percentage notation, you probably use only numbers between 0 and 100, because although swimming in the air, there cannot be more than 100% of humidity. On the other hand, you can use only whole numbers, or decimal numbers (the acurately ones will probably do). So the reason of this page is explanation of defining such a subtype.
Subtypes can be defined by several ways.
The most easy way is enumerating all possible values from any type. As an example, we can define type Weekend using useful type DaysOfTheWeek:
Weekend ::= DaysOfTheWeek (saturday | sunday)
Symbol '|' is used to separate entries, it is usually pronounciated as 'or'. Now we can extend this subtype to specify a LongWeekend, which sometimes appears, by adding a free Friday to weekend:
LongWeekend ::= DaysOfTheWeek (INCLUDES Weekend | friday)
Here we used special keyword INCLUDE to include weekend days as mentioned above. This technique is called contained subtyping. But be aware, it is impossible to define for example type RandezvousDay by using assignment:
RandezvousDay ::= DaysOfTheWeek(INCLUDE Weekend | INCLUDE HolidayDay)
unless type HolidayDay is subtype of DaysOfTheWeek.
One could !!!namietat!!! that day names should begin with capital letter. Sorry, but it is not possible because of naming conventions. It will be described on next page.
Probably if designed subtype is based on some ordered type, like Integer, you would not like to enumerate it (except the bra number, it's not too many numbers, but worth...). Here are other notations to help with it:
So, this is the typical subtype specification way - select just range of valid numbers. Example
NormalBraNumber ::= INTEGER (1..5)
Of course, if you think that also daddy-like girls (which is also very sexy) should wear it, no problem:
AllGirlsBraNumber ::= INTEGER (INCLUDE NormalBraNumber | 0)
There was a joke about changing the bra numbers into letter which symbolize by some kind of fruit suitable to its size. It fits to first five letters (in slovak language only, sorry), thus one can specify a subtype BraSize another way:
BraSize ::= VisibleString("A".."E")
Sometimes it is desired to use bit- or octet-strings with limited lenght or defined size. That's why you can easily find a subtype definition like:
MotherInLawSpeech ::= BIT STREAM (SIZE (0..256))
Happy guy having a mother-in-law speech limited, but if he want to give her a chance to pronounciate also smaller streams of words, it's better to define:
MotherInLawSpeech ::= BIT STREAM (SIZE (1 | 3 | 5 | 7 | 8))
This a special tool to define value sets from structured types, which are not yet well defined, that's why, you have to look for an example later in the text.
Once specified, subtype can be used wherever a type is alowed and given range is useful. Thus it can serve as a parent to specify another subtype. Who is now thinking about endles loop of nested subtypes will get a bier from me. Next page - Naming conventions.