43c9ba4bd6d469ce7c0657cf5e9db78872d817f9
[com/asn1c.git] / tests / tests-asn1c-compiler / 50-constraint-OK.asn1
1
2 -- OK: Everything is fine
3
4 -- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
5 -- .spelio.software.asn1c.test (9363.1.5.1)
6 -- .50 1
7 -- .50 2
8
9 ModuleNestedConstraintsCheck
10         { iso org(3) dod(6) internet (1) private(4) enterprise(1)
11                 spelio(9363) software(1) asn1c(5) test(1) 50 1 }
12         DEFINITIONS ::=
13 BEGIN
14         IMPORTS Identifier FROM IdentifierModule;
15
16         Int1 ::= INTEGER
17         Int2 ::= Int1 (0..MAX)          -- X.680-0207::41.4.4
18         Int3 ::= Int2 (MIN..ten)        -- Means (0..10)
19         Int4 ::= Int3 (5..MAX,...,1..4) -- Means (1..10,...)
20         Int5 ::= Int4 (MIN..5)          -- Means (5)
21         -- Int6 ::= INTEGER (Int5) -- -- Not yet supported
22
23         ten Int1 ::= other-ten
24         other-ten Int2 ::= 10
25
26         -- G.4.3.4
27         ExtensibleExtensions ::= INTEGER (1..256) (1..255,...)
28
29         Str1 ::= IA5String
30         Str2 ::= Str1 (SIZE(MIN..20 | 25..30))  
31                                         -- Means (SIZE(0..20 | 25..30))
32         Str3 ::= Str2 (SIZE(10..27))(FROM("ABC"|"def"))
33                                         -- (SIZE(10..20,25..27))(FROM("ABCdef"))
34         Str4 ::= IA5String ("ABCD"|SIZE(4))
35                                         -- Not PER-visible
36
37         PER-Visible ::= IA5String (FROM("A".."F"))
38         PER-Visible-2 ::= PER-Visible (FROM("E".."F"))  -- Means (FROM("EF"))
39         -- The following maintain parent permitted alphabet constraint
40         Not-PER-Visible-1 ::= PER-Visible (FROM("AB") | SIZE(1..2))
41         Not-PER-Visible-2 ::= PER-Visible (FROM("AB",...))
42         Not-PER-Visible-3 ::= PER-Visible (FROM("AB"),...)
43
44         SIZE-but-not-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD",...))
45         SIZE-and-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD"))
46         Neither-SIZE-nor-FROM ::= PER-Visible (SIZE(1..4) | FROM("ABCD",...))
47
48         Utf8-4 ::= UTF8String (FROM("A".."Z"))          -- Alphabet
49         Utf8-3 ::= Utf8-2 (FROM("A".."Z"|"a".."z"))     -- Alphabet and size
50         Utf8-2 ::= Utf8-1 (SIZE(1..2))                  -- Size
51         Utf8-1 ::= UTF8String
52
53         VisibleIdentifier ::= Identifier
54
55         Sequence ::= SEQUENCE {
56                 int1-c  Int1    (-2..MAX) DEFAULT 3,
57                 int4    [2] Int4,
58                 int4-c  Int4    (MIN..7),
59                 bool    BOOLEAN DEFAULT 1,
60                 enum-c  ENUMERATED { one(1), two(2), ..., three(3) },
61                 ...,
62                 int5-c  Int5 (5) OPTIONAL,
63                 ...,
64                 null    NULL OPTIONAL
65         }
66
67         SequenceOf ::= SEQUENCE (SIZE(1..2)) OF Sequence
68
69         Enum0   ::= ENUMERATED { one, two }
70         Enum1   ::= ENUMERATED { one, two }     (one)
71
72 END
73
74
75 IdentifierModule
76         { iso org(3) dod(6) internet (1) private(4) enterprise(1)
77                 spelio(9363) software(1) asn1c(5) test(1) 50 2 }
78         DEFINITIONS ::=
79 BEGIN
80         EXPORTS Identifier;
81
82         maxIdentifier INTEGER ::= 32
83
84         Identifier ::=
85             VisibleString ( FROM
86            ("A"|"a"|"B"|"b"|"C"|"c"|"D"|"d"|"E"|"e"|"F"|"f"|
87            "G"|"g"|"H"|"h"|"I"|"i"|"J"|"j"|"K"|"k"|"L"|"l"|
88            "M"|"m"|"N"|"n"|"O"|"o"|"P"|"p"|"Q"|"q"|"R"|"r"|
89            "S"|"s"|"T"|"t"|"U"|"u"|"V"|"v"|"W"|"w"|"X"|"x"|
90            "Y"|"y"|"Z"|"z"|"$"|"_"|"0"|"1"|"2"|"3"|"4"|"5"|
91            "6"|"7"|"8"|"9") ) (SIZE(1..maxIdentifier))
92
93 END