Commit 5d8963df authored by Matthias Simon's avatar Matthias Simon
Browse files

Import the version 5 chapters from SharePoint into src.

Re-imported from Version_5_Content with the import skill, then formatted
with t3s format. Blocks that do not parse are left as they are.

Co-authored-by: default avatarCursor <cursoragent@cursor.com>
parent 589da5cc
Loading
Loading
Loading
Loading
Loading
+2 −0
Changes for src/00-ttcn-3-overview.md: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
# TTCN-3 overview

## Mapping to the Standard (Better title required)
+0 −4
Changes for src/06-types-and-values.md: 0 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -2108,7 +2108,6 @@ the following restrictions shall apply:
//BUT:
v_age := "young"; // is an error, as textualDescription is not the default field


v_oneYearOlder := v_age+1; // implicit selection of the default field: the union
// default field is compatible with integer, so that it
// can be used as an integer expression; this is equivalent to:
@@ -3806,7 +3805,6 @@ type record REType { // type with an extra field d
	boolean f
}


var RAType v_myVarRA;
var RBType v_myVarRB := { omit, 2, true};
var RCType v_myVarRC := { 3, omit, true};
@@ -3827,7 +3825,6 @@ type record REType { // type with an extra field d
v_myVarRA := v_myVarRC    // is NOT a valid assignment because field 'd' of MyVarRC violates
// subtyping of field 'a' of RAType


var SFType v_myVarSF := { a := 1, c := true };
var SGType v_myVarSG := { f := true, d := 7};

@@ -4118,7 +4115,6 @@ type enumerated ESimpleValues {
	e_hex_conv (172)
}


var EWeekDays v_myWeekDayMon := Mon
var EWeekDays v_myWeekDaySun := Sun
var EWorkDays v_myWorkDayMon := Mon
+112 −146
Changes for src/07-expressions.md: 112 added lines, 146 removed lines.
Original line number Diff line number Diff line
@@ -163,44 +163,44 @@ the following restrictions shall apply:
   an operand of an expression shall not evaluate to the special value `null` (see
   clause 7.1.3).

> NOTE: `   `EXAMPLE:`   `

> NOTE: `type record``  MyRecord { `\
> `    ``integer``  a, `\
> `    ``integer``  b `\
> `}`\
> \
> `const integer``  c_a := 10; `\
> `const integer``  c_b := 5; `\
> `const integer``  c_c := 2; `\
> \
> `const``  MyRecord c_record := { a := 3, b := 4 }; `\
> `const integer``  c_values[3] := { 10, 20, 30 }; `\
> \
> `// Operator precedence`\
> `const integer``  c_result1 := c_a + c_b * c_c;       // 20 `\
> `const integer``  c_result2 := (c_a + c_b) * c_c;     // 30 `\
> \
> `// Equal precedence: left-to-right grouping`\
> `const integer``  c_result3 := c_a - c_b + c_c;       // 7 `\
> `const integer``  c_result4 := c_a - (c_b + c_c);     // 3 `\
> \
> `// Nested parentheses`\
> `const integer``  c_result5 := ((c_a + c_b) * c_c);   // 30 `\
> \
> `// Dot notation`\
> `const integer``  c_result6 := c_record.a + c_record.b * 2; // 11 `\
> \
> `// Index notation`\
> `const integer``  c_result7 := c_values[0] + c_values[1];   // 30 `\
> \
> `// Combined dot and index notation`\
> `const``  MyRecord c_records[2] := { `\
> `   { a := 1, b := 2 }, `\
> `   { a := 3, b := 4 } `\
> `};`\
> \
> `const integer``  c_result8 := c_records[1].a * 2;   // 6 `
```ttcn3 example
type record MyRecord {
	integer a,
	integer b
}

const integer c_a := 10;
const integer c_b := 5;
const integer c_c := 2;

const MyRecord c_record := { a := 3, b := 4 };
const integer c_values[3] := { 10, 20, 30 };

// Operator precedence
const integer c_result1 := c_a + c_b * c_c;   // 20
const integer c_result2 := (c_a + c_b) * c_c; // 30

// Equal precedence: left-to-right grouping
const integer c_result3 := c_a - c_b + c_c;   // 7
const integer c_result4 := c_a - (c_b + c_c); // 3

// Nested parentheses
const integer c_result5 := ((c_a + c_b) * c_c); // 30

// Dot notation
const integer c_result6 := c_record.a + c_record.b * 2; // 11

// Index notation
const integer c_result7 := c_values[0] + c_values[1]; // 30

// Combined dot and index notation
const MyRecord c_records[2] := {
	{ a := 1, b := 2 },
	{ a := 3, b := 4 }
};

const integer c_result8 := c_records[1].a * 2; // 6
```

### Arithmetic operators

@@ -608,37 +608,22 @@ For such comparisons,
the array shall be considered as a value of its corresponding `record` `of`
type.

EXAMPLE: 

`type record of integer RoI;`

`type integer IntArray[2];`

`const RoI c_roi1 := {1, 2};`

`const RoI c_roi2 := {1, 2};`

`const RoI c_roi3 := {2, 1};`

`const RoI c_roi4 := {1, 2, 3};`

`const IntArray c_array := {1, 2};`

`var boolean v_result;`

`v_result := c_roi1 == c_roi2;`

`// true: same number of elements and equal elements at corresponding positions`

`v_result := c_roi1 == c_roi3;`

`// false: elements at corresponding positions differ`

`v_result := c_roi1 == c_roi4;`

`// false: different numbers of elements`

```ttcn3 example="v_result := c_roi1 == c_array;"
```ttcn3 example
type record of integer RoI;
type integer IntArray[2];
const RoI c_roi1 := {1, 2};
const RoI c_roi2 := {1, 2};
const RoI c_roi3 := {2, 1};
const RoI c_roi4 := {1, 2, 3};
const IntArray c_array := {1, 2};
var boolean v_result;
v_result := c_roi1 == c_roi2;
// true: same number of elements and equal elements at corresponding positions
v_result := c_roi1 == c_roi3;
// false: elements at corresponding positions differ
v_result := c_roi1 == c_roi4;
// false: different numbers of elements
v_result := c_roi1 == c_array;
// true: the array and record of values have equal elements at corresponding positions
```

@@ -649,45 +634,27 @@ EXAMPLE:
  and each element of one value can be paired with a distinct equal element of
  the other value, regardless of their positions.

EXAMPLE:

`type set of integer SoI;`

`const SoI c_soi1 := {1, 2};`

`const SoI c_soi2 := {1, 2};`

`const SoI c_soi3 := {2, 1};`

`const SoI c_soi4 := {1, 2, 3};`

`const SoI c_soi5 := {1, 1, 2};`

`const SoI c_soi6 := {2, 1, 1};`

`const SoI c_soi7 := {1, 2, 2};`

`var boolean v_result;`

`v_result := c_soi1 == c_soi2;`

`// true: same number of elements and all elements can be paired`

`v_result := c_soi1 == c_soi3;`

`// true: the order of elements is irrelevant`

`v_result := c_soi1 == c_soi4;`

`// false: different numbers of elements`

`v_result := c_soi5 == c_soi6;`

`// true: equal elements with equal multiplicities, regardless of order`

`v_result := c_soi5 == c_soi7;`

- **// false: different multiplicities of the values 1 and 2 **
```ttcn3 example
type set of integer SoI;
const SoI c_soi1 := {1, 2};
const SoI c_soi2 := {1, 2};
const SoI c_soi3 := {2, 1};
const SoI c_soi4 := {1, 2, 3};
const SoI c_soi5 := {1, 1, 2};
const SoI c_soi6 := {2, 1, 1};
const SoI c_soi7 := {1, 2, 2};
var boolean v_result;
v_result := c_soi1 == c_soi2;
// true: same number of elements and all elements can be paired
v_result := c_soi1 == c_soi3;
// true: the order of elements is irrelevant
v_result := c_soi1 == c_soi4;
// false: different numbers of elements
v_result := c_soi5 == c_soi6;
// true: equal elements with equal multiplicities, regardless of order
v_result := c_soi5 == c_soi7;
// false: different multiplicities of the values 1 and 2
```

##### Equality of union and anytype values

@@ -833,38 +800,36 @@ the same identifier in both types (see also clause 6.7.3).
  integer values (assigned either explicitly or implicitly,
  see clause 6.3) are the same.

EXAMPLE: 
```ttcn3 example
type enumerated EWeekDays {
	Mon, Tue, Wed, Thu, Fri, Sat, Sun
}

- `type enumerated``  EWeekDays { `
- `     Mon, Tue, Wed, Thu, Fri, Sat, Sun `
- `}`
-
- `type enumerated``  EWorkDays { `
- `     Mon, Tue, Wed, Thu, Fri `
- `}`
-
- `type enumerated``  EDesWeekDays { `
- `     Tue, Wed, Thu, Fri, Sat, Sun, Mon `
- `}`
-
- `var``  EWeekDays v_myWeekDayMon := Mon; `
- `var``  EWeekDays v_myWeekDaySun := Sun; `
- `var``  EWorkDays v_myWorkDayMon := Mon; `
- `var``  EDesWeekDays v_myDesWeekDayMon := Mon; `
-
- `var boolean``  v_result; `
-
- `v_result := v_myWeekDayMon == v_myWorkDayMon;`
- `// true:
  Mon has the same identifier and associated integer value in both types`
-
- `v_result := v_myWeekDaySun == v_myWorkDayMon;`
- `// false:
  the enumerated values have different identifiers and associated integer values`
-
- `v_result := v_myDesWeekDayMon == v_myWeekDayMon;`
- `// error: values of these enumerated types cannot be compared because`
- `// common integer values are associated with different identifiers`
type enumerated EWorkDays {
	Mon, Tue, Wed, Thu, Fri
}

type enumerated EDesWeekDays {
	Tue, Wed, Thu, Fri, Sat, Sun, Mon
}

var EWeekDays v_myWeekDayMon := Mon;
var EWeekDays v_myWeekDaySun := Sun;
var EWorkDays v_myWorkDayMon := Mon;
var EDesWeekDays v_myDesWeekDayMon := Mon;

var boolean v_result;

v_result := v_myWeekDayMon == v_myWorkDayMon;
// true: Mon has the same identifier and associated integer value in both types

v_result := v_myWeekDaySun == v_myWorkDayMon;
// false: the enumerated values have different identifiers and associated integer values

v_result := v_myDesWeekDayMon == v_myWeekDayMon;
// error: values of these enumerated types cannot be compared because
// common integer values are associated with different identifiers
```

##### Equality of default, port, timer and component values

@@ -925,9 +890,10 @@ values.

**_Syntactical Sturture_**

` LogicalOperation ::=  `\
` (  ``"``not`` "  `` Expression ) | ( Expression  ``(``   ``"``and``" |
"``or``" | "``xor`` " )  ``Expression )`
```ebnf
LogicalOperation ::= 
( "not" Expression ) | ( Expression ( "and" | "or" | "xor" ) Expression )
```

**_Semantic Description_**

@@ -1038,9 +1004,10 @@ individual bits of binary string values.

**_Syntactical Structure_**

` BitwiseOperation ::=  `\
` (  ``"``not4b``"``  Expression  `` ) | (  `` Expression  ``(``  
``"``and4b``" | "``or4b``" | "``xor4b`` " )  ``Expression )`
```syntax
BitwiseOperation ::= 
( "not4b" Expression ) | ( Expression ( "and4b" | "or4b" | "xor4b" ) Expression )
```

**_Semantic Description_**

@@ -1581,7 +1548,6 @@ type union MyUnion {
template MyUnion m_myUnion := { ch1 := 5 }
template MyUnion mw_myUnion := { ch1 := ? }


var boolean v_checkResult := isvalue(m_myUnion); // yields true
v_checkResult := isvalue(mw_myUnion);            // yields false
v_checkResult := isvalue(mw_myUnion.ch1);        // yields false
+0 −1
Changes for src/08-modules.md: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -718,7 +718,6 @@ module C {
	const integer enumY := 1;
	const MyEnumType2 enumX := enumY;


	modulepar MyEnumType PX_MyModulePar1 := enumY
	// the default value of the module parameter will be the value enumY, as the type of
	// PX_MyModulePar1 creates the context of MyEnumType and in this context enumerated values
+6 −0
Changes for src/10-declaring-variables-constants-and-module-parameters.md: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ and for template variables clause 15, the following restrictions apply:
1. The right-hand side of the assignment shall evaluate to a value,
   which is type compatible with the variable being declared.

-

**_Examples_**

```ttcn3
@@ -138,10 +140,14 @@ Reference source not found, the following restrictions apply:
> port or timer type or component constants of default or component types is the
> special value `null`.

-

1. If the _TypeOrNestedTypeDef_ part is missing from the declaration,
   the _ArrayDef _part shall be missing as well and the assignment part (i.e. ":="
   _ConstantExpression_) shall be present.

-

**_Examples_**

```ttcn3
Loading