
-- OK: Everything is fine

-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
-- .spelio.software.asn1c.test (9363.1.5.1)
-- .50 1
-- .50 2

ModuleNestedConstraintsCheck
	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
		spelio(9363) software(1) asn1c(5) test(1) 50 1 }
	DEFINITIONS ::=
BEGIN
	IMPORTS Identifier FROM IdentifierModule;

	Int1 ::= INTEGER
	Int2 ::= Int1 (0..MAX)		-- X.680-0207::41.4.4
	Int3 ::= Int2 (MIN..ten)	-- Means (0..10)
	Int4 ::= Int3 (5..MAX,...,1..4)	-- Means (1..10,...)
	Int5 ::= Int4 (MIN..5)		-- Means (5)
	-- Int6 ::= INTEGER (Int5) -- -- Not yet supported

	ten Int1 ::= other-ten
	other-ten Int2 ::= 10

	-- G.4.3.4
	ExtensibleExtensions ::= INTEGER ((1..256,...) INTERSECTION (1..256))  

	Str1 ::= IA5String
	Str2 ::= Str1 (SIZE(MIN..20 | 25..30))	
					-- Means (SIZE(0..20 | 25..30))
	Str3 ::= Str2 (SIZE(10..27))(FROM("ABC"|"def"))
					-- (SIZE(10..20,25..27))(FROM("ABCdef"))
	Str4 ::= IA5String ("ABCD"|SIZE(4))
					-- Not PER-visible

	PER-Visible ::= IA5String (FROM("A".."F"))
	PER-Visible-2 ::= PER-Visible (FROM("E".."F"))	-- Means (FROM("EF"))
	-- The following maintain parent permitted alphabet constraint
	Not-PER-Visible-1 ::= PER-Visible (FROM("AB") | SIZE(1..2))
	Not-PER-Visible-2 ::= PER-Visible (FROM("AB",...))
	Not-PER-Visible-3 ::= PER-Visible (FROM("AB"),...)

	SIZE-but-not-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD",...))
	SIZE-and-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD"))
	Neither-SIZE-nor-FROM ::= PER-Visible (SIZE(1..4) | FROM("ABCD",...))

	Utf8-4 ::= UTF8String (FROM("A".."Z"))		-- Alphabet
	Utf8-3 ::= Utf8-2 (FROM("A".."Z"|"a".."z"))	-- Alphabet and size
	Utf8-2 ::= Utf8-1 (SIZE(1..2))			-- Size
	Utf8-1 ::= UTF8String

	VisibleIdentifier ::= Identifier

	Sequence ::= SEQUENCE {
		int1-c	Int1	(-2..MAX) DEFAULT 3,
		int4	[2] Int4,
		int4-c	Int4	(MIN..7),
		bool	BOOLEAN	DEFAULT 1,
		enum-c	ENUMERATED { one(1), two(2), ..., three(3) },
		...,
		int5-c	Int5 (5) OPTIONAL,
		...,
		null	NULL OPTIONAL
	}

	SequenceOf ::= SEQUENCE (SIZE(1..2)) OF Sequence

	Enum0	::= ENUMERATED { one, two }
	Enum1	::= ENUMERATED { one, two }	(one)

END


IdentifierModule
	{ iso org(3) dod(6) internet (1) private(4) enterprise(1)
		spelio(9363) software(1) asn1c(5) test(1) 50 2 }
	DEFINITIONS ::=
BEGIN
	EXPORTS Identifier;

	maxIdentifier INTEGER ::= 32

	Identifier ::=
	    VisibleString ( FROM
	   ("A"|"a"|"B"|"b"|"C"|"c"|"D"|"d"|"E"|"e"|"F"|"f"|
	   "G"|"g"|"H"|"h"|"I"|"i"|"J"|"j"|"K"|"k"|"L"|"l"|
	   "M"|"m"|"N"|"n"|"O"|"o"|"P"|"p"|"Q"|"q"|"R"|"r"|
	   "S"|"s"|"T"|"t"|"U"|"u"|"V"|"v"|"W"|"w"|"X"|"x"|
	   "Y"|"y"|"Z"|"z"|"$"|"_"|"0"|"1"|"2"|"3"|"4"|"5"|
	   "6"|"7"|"8"|"9") ) (SIZE(1..maxIdentifier))

END
