###############################################################################
# Copyright (c) 2000-2021 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
#
###############################################################################

[DEFINE]
MACRO_CS := "macro"
MACRO_INT := 1

[MODULE_PARAMETERS]

# integer
mp1 := +1;
mp1 := mp1 + 1;
mp2 := mp1 - mp2 + 10 / mp1;
mp3 := (mp1 + 2) * 5;
mp3 := mp3 + mplist2[mp1 - 1 - ${MACRO_INT, integer}];

# float
mp4 := -3.0;
mp5 := +mp4 / 0.5 - 1.5 * (mp5 + 1.0);

# bitstring
mpbs1 &= '1101'B & mpbs2 & '01'B;
mpbs2 := mpbs2 & mpbs1;
mpbs1 &= mpbs2;

# hexstring
mphs1 := '77FF'H & mphs1 & mphs2;
mphs2 &= 'EE'H;

# octetstring
mpos1 := 'DEAD'O;
mpos2 := 'A22C'O & mpos1 & 'C22A'O;

# charstring
mpcs1 &= mpcs2;
mpcs1 := mpcs1 & "ghi";
mpcs2 := "xx" & mpcs1 & "xx" & mpcs2;
mpcs3 := mpucs1 & "xx";

# universal charstring
mpucs1 := "a" & mpucs2;
mpucs2 := "űrhajó" & mpcs1 & char(mp1 + 1, 5, mp1 * 5, 5) & "x";

# boolean
mpb1 := mpb2;
mpb2 := mpuni2.bval;
#mpb2 := not mpb2; #not works, not required

# objid
mpobjid2 := mpobjid1;

# verdicttype
mpvt2 := mpvt1;

# component
mpcomp2 := mpcomp1;

# default
mpdef2 := mpdef1;

# enumerated
mpenum2 := references.mpenum1;
mpenum1 := Large;

# record of
mplist1 := mplist2;
mplist2 := { [mp1 / 2] := 3, [0] := mprec1.num };
mplist2 &= mplist1;

# record
mprec3 := mprec1;
mprec1 := mprec2;
mprec2 := mprec3;
mprec3 := { mplist1[0], mpcs1 };

# empty record
mpemptyrec2 := mpemptyrec1;

# union
mpuni3 := mpuni1;
mpuni1 := mpuni2;
mpuni2 := mpuni3;
mpuni3 := { osval := mpos1 & mpos2 };

# array
mparray1 := { mparray2[0], mpcs1 & "xx" };
mparray2 := mparray1;

# integer template
mptint1 := mptint2;
mptint2 := (mp1 + 6, mp2, - mp3, - ${MACRO_INT, integer});
mptint4 := mptint3;

# float template
mptf1 := mptf2 ifpresent;
mptf2 := (mp4 / 2.0, mp5 * 1.5);

# charstring template
mptcs1 := mptcs1 length(2 .. mp2 - 1);
mptcs2 := "xx" & mptcs2 & "xx" ifpresent;
mptcs3 := mptcs3 & "d" & mptarray2[1];

# universal charstring template
mptucs3 := (mptucs1, ("a".."z"));
mptucs2 := "zz" & mpucs2 & "zz";
mptucs1 := pattern "a??b" & ${MACRO_CS} & char(1, 2, 3, 4) & mpucs1;

# bitstring template
mptbs1 := '110'B & mpbs1 & '011'B;
mptbs2 := mptbs2 ifpresent;
mptbs3 := mptbs3;

# hexstring template
mpths1 := 'AB'H & mphs1 & 'BA'H;
mpths2 := mpths2;
mpths3 := mpths3 length (7..infinity);

# octetstring template
mptos1 := '01'O & mpos1 & '10'O;
mptos2 := mptos2;
mptos3 := mptos3;

# boolean template
mptb1 := (mptb1, mptb2);
mptb2 := mptuni3.bval;

# component template
mptcomp2 := mptcomp1;

# default template
mptdef2 := mptdef1;

# verdicttype template
mptvt1 := mptvt2;
mptvt2 := mpvt2;
mptvt3 := inconc;

# enumerated template
mptenum1 = mptenum2;
mptenum2 := mpenum2;
mptenum3 := Medium;

# objid template
mptobjid1 := mptobjid2;
mptobjid2 := mpobjid1;

# record template
mptrec1 := mptrec2;
mptrec2 := { num := mptrec2.num, str := mptcs1 };
mptrec3 := ( mptrec3, mprec1, mprec2, mprec3 );

# empty record template
mptemptyrec1 := mptemptyrec2;
mptemptyrec2 := mpemptyrec1;

# record of template
mptlist1 := { [2] := mptlist2[0], [1] := mptlist2[1], [0] := mptlist2[2] } length (1..4);
mptlist2 := mptlist3;
mptlist3 := complement ( mptlist2, mplist1, mplist2 );

# union template
mptuni1 := mptuni2;
mptuni2 := { ival := mptint2 };
mptuni3 := ( mpuni1, mpuni2, mpuni3 );

# array template
mptarray1 := mptarray2 ifpresent;
mptarray2 := mptarray3;
mptarray3 := mparray1;

##### asn1 #########
tsp_TRUE := tsp_FALSE;
tsp_FALSE := false;
#tsp3_RESULT1 := tsp_TRUE or tsp_FALSE; not required
#tsp3_RESULT2 := tsp_TRUE and tsp_FALSE; not required
tsp_asnbitstr1 := '0'B
tsp_asnbitstr2 := '01'B
tsp_asnbitstr3 := tsp_asnbitstr1 & tsp_asnbitstr2 & '0101'B;
tsp_asnos1 := '12'O
tsp_asnos2 := 'EF'O
tsp_asnos3 := tsp_asnos1 & tsp_asnos2 & '0123456789'O
tsp_asnstr1 :="Laci"
tsp_asnstr2 :="1()"
tsp_asnstr3 := tsp_asnstr1 & tsp_asnstr2 & "tail"

tsp_asnint1 := +1
tsp_asnint2 := 2*tsp_asnint1
tsp_asnint3 := tsp_asnint1 + tsp_asnint2
tsp_asnint3 := (tsp_asnint1 + tsp_asnint2)*2-10/tsp_asnint1  #3*2 -10/1=-4

tsp_asnreal1 := +1.0
tsp_asnreal2 := 2.0 * tsp_asnreal1
tsp_asnreal3 := (tsp_asnreal1 + tsp_asnreal2)*2.0- 10.0/tsp_asnreal1 #= -4.0
#tsp_asnreal3 := (tsp_asnreal1 + tsp_asnreal2)*2.0-10.0/tsp_asnreal1 #FIXME: This line is not accepted by the executor 
[EXECUTE]
references.control
#references.tc_asn1_bool
#references.tc_asn1_bitstr
