/******************************************************************************
 * Copyright (c) 2000-2025 Ericsson Telecom AB
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
 *
 * Contributors:
 *   Balasko, Jeno
 *   Baranyi, Botond
 *
 ******************************************************************************/

module SubType {

const integer ZERO := 0;

type integer PosInt (!ZERO..infinity);

type PosInt PosIntValues (1, 5, 7, 10);

type record Rec {
  PosIntValues val optional,
  Int i (0..6-3),
  octetstring os ('1010'O, '1001'O, '1100'O) optional,
  boolean b optional
}
with {
  variant(val) "JSON: name as posInt";
  variant(i) "JSON: name as int";
}

type Rec RecValues (
  { 1, 0, '1010'O, false },
  { 5, 0, '1001'O, true },
  { 7, 2, omit, true },
  { omit, 1, omit, omit }
);

type integer Int;

type PosInt PosIntCopy;

type enumerated Size { Small, Medium, Large };

type Size LargeSize ( Large );

type charstring CapitalLetters ("A".."Z") length (1..6);

type float NegFloat (-infinity..0.0);

type float NegFloatExcl (!-infinity..!0.0);

type float SpecialFloat (-infinity, infinity, not_a_number);

type record length (3..infinity) of PosInt PosIntList;

type set length (2) of CapitalLetters CapitalStringList;

type record of integer OnesAndTwos ( 1, 2 );

type OnesAndTwos OneTwo (
  { 1, 2 },
  { [3] := 2, [0] := 1, [2] := 1, [1] := 2 }
);

type verdicttype SimpleVerdict (pass, fail, error);

type union RegularUnion {
  Int i,
  charstring str
}
with {
  variant(i) "JSON: name as int";
}

type RegularUnion RegularUnionValues (
  { i := 3 },
  { str := "abc" }
);

type union AsValueUnion {
  Int i,
  charstring str
}
with {
  variant "JSON: as value";
}

type AsValueUnion AsValueUnionValues (
  { i := 3 },
  { str := "abc" }
);

type AsValueUnion MoreAsValueUnionValues (
  AsValueUnionValues,
  { i := 6 }
);

type anytype AnyTypeValues (
  { integer := 5 },
  { boolean := false },
  { bitstring := '0011'B },
  { charstring := "mine" }
);

type universal charstring StringValues ( "almafa", "áram", "űrhajó" );

type charstring Alphanumeric ( "a".."z", "A".."Z", "0".."9" ) ;

type integer NonZero (-infinity..!0, !0..infinity);

type float ItsComplicated (-infinity..-1.0, 0.0, 0.5, 1.0, 3.14, not_a_number);

type universal charstring UnicodeStringRanges ( char(0, 0, 1, 81)..char(0, 0, 1, 113), char(0, 0, 1, 66)..char(0, 0, 1, 97) );

type charstring CharstringPattern (pattern "abc*xyz");

type charstring CharstringPatternLong (pattern "*ab?\*\?\(\+[0-9a-fA-F*?\n]#(2,4)xx([^abc]+)|([abc]+)xx\d\dx\wx\nx\rx\sx\"x""x\\d");

const charstring ConstRef := "ab?c";

type charstring CharstringPatternRef (pattern "x{ConstRef}x");

type universal charstring UnicodePattern (pattern "abc?\q{ 0, 0, 1, 113}z\\q1\q{0,0,0,2}");

type union U {
  integer i,
  charstring c,
  integer j
}
with {
  variant "JSON: as value";
}

type U Uwithvalue (
  { i := 1 },
  { c := "zssfss" },
  { j := 2 }
);

type union U2 {
  integer i,
  Rec r
}
with {
  variant "JSON: as value";
}

type U2 U2Values (
  { i := 8 },
  { r := { 7, 1, omit, true } }
);

type set ComplexSet {
  Rec r,
  record of Rec ro,
  integer i optional
}

type ComplexSet ComplexSetValues (
  { r := { omit, 0, omit, false }, ro := { { 7, 1, omit, true }, { omit, 2, '1001'O, true } }, i := omit }
);

type record of U2 U2List;

type U2List U2ListValues (
  { { r := { 7, 1, omit, false } }, { i := 8 } },
  { { r := { 5, 0, '1001'O, true } }, { i := 2 } }
);

type set SetWithAsValues {
  integer num,
  U2List u2s
}

type SetWithAsValues RestrictedSetWithAsValues (
  { num := 6, u2s := { { r := { 7, 1, omit, false } }, { i := 8 } } },
  { num := 1, u2s := { { r := { 5, 0, '1001'O, true } }, { i := 2 } } }
);

}
with {
  extension "anytype integer, boolean, bitstring, charstring"
}
