ETSI's Bug Tracker - Ext Pack: Advanced Matching (ES 203 022)
View Issue Details

ID | Project | Category | View Status | Date Submitted | Last Update
0007167 | Ext Pack: Advanced Matching (ES 203 022) | New Feature | public | 07-09-2015 10:53 | 24-12-2016 12:59

Reporter | Tomas Urban |
Assigned To | Jens Grabowski |
Priority | normal | Severity | minor | Reproducibility | have not tried
Status | closed | Resolution | fixed |
Platform |  | OS |  | OS Version |
Product Version |  |
Target Version | v1.1.1 (published 2017-07) | Fixed in Version | v1.1.1 (published 2017-07) |
Clause Reference(s) | B.1.3
Source (company - Author) | Elvior
TS version |

Summary | 0007167: Matching mechanism to match multiple items in arrays, records and sets of single types

Description

I one of our projects we had an interesting problems with matching incoming messages. The message contained a record of complex record entries and one of the string fields of each record element was required to contain a certain pattern.
We ended up with using a rather complicated solution containing a check procedure (for general acceptance), for-loop for element check and continue statement + some guards for flow control.
However, it would be nice if TTCN-3 contained a matching mechanism that would allow to specify properties of SEVERAL record of, set of or array items. Such a mechanism would be generally similar to AnyElementsOrNone with that difference that it would impose additional restrictions on the element content. Similarly to the AnyElementsOrNone, it could be optionaly ammended with a length restriction.
Possible syntactical solutions:
The following type is used in examples:
type record of record {
integer field1,
charstring field2
} RoR;
1. Extension of the AnyElementsOrNone mechanism:
a. using the with keyword:
{
// standard field match (fixed values)
{ field1 := 3, field2 := pattern "test" },
// 0..N matches where field2 of each element has to start with "abc"
* with { field1 := ?, field2 := pattern "abc*" }
}
b. using the pattern keyword:
{
// standard field match (fixed values)
{ field1 := 3, field2 := pattern "test" },
// 0..N matches where field2 of each element has to start with "abc"
* pattern { field1 := ?, field2 := pattern "abc*" }
}
2. Using the any keyword:
{
// standard field match (fixed values)
{ field1 := 3, field2 := pattern "test" },
// 0..N matches where field2 of each element has to start with "abc"
any { field1 := ?, field2 := pattern "abc*" }
}

Steps To Reproduce |
Additional Information |
Tags | technically agreed

Relationships

related to | 0007174 | closed | Jens Grabowski | New matching mechanism: matching by function
related to | 0007494 | closed | Jens Grabowski | TRI and TCI extensions for advanced matching

Attached Files | CR7167-1.docx (170,009) 15-11-2016 14:49 http://oldforge.etsi.org/mantis/file_download.php?file_id=3523&type=bug CR7167-2.docx (156,818) 17-11-2016 09:54 http://oldforge.etsi.org/mantis/file_download.php?file_id=3548&type=bug

Issue History
Date Modified | Username | Field | Change
07-09-2015 10:53 | Tomas Urban | New Issue |
07-09-2015 16:23 | Jacob Wieland - Spirent | Note Added: 0013193 |
21-09-2015 10:27 | Gyorgy Rethy | Target Version | => v4.8.1 (ongoing)
21-09-2015 11:11 | Gyorgy Rethy | Relationship added | related to 0007174
21-09-2015 11:49 | Gyorgy Rethy | Note Added: 0013200 |
21-09-2015 11:50 | Gyorgy Rethy | Note Edited: 0013200 | bug_revision_view_page.php?bugnote_id=13200#r167
22-09-2015 09:35 | Gyorgy Rethy | Tag Attached: technically agreed |
22-09-2015 09:38 | Gyorgy Rethy | Note Added: 0013232 |
22-09-2015 09:38 | Gyorgy Rethy | Assigned To | => Jacob Wieland - Spirent
22-09-2015 09:38 | Gyorgy Rethy | Status | new => assigned
23-09-2015 15:15 | Jacob Wieland - Spirent | Note Added: 0013275 |
23-09-2015 15:27 | Jacob Wieland - Spirent | Note Added: 0013276 |
23-09-2015 15:27 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Gyorgy Rethy
23-09-2015 15:27 | Jacob Wieland - Spirent | Status | assigned => confirmed
03-11-2015 11:58 | Gyorgy Rethy | Note Added: 0013466 |
03-11-2015 11:58 | Gyorgy Rethy | Target Version | v4.8.1 (ongoing) => Next version (to be defined)
05-11-2015 11:05 | Gyorgy Rethy | Project | Part 01: TTCN-3 Core Language => Ext Pack: Advanced Matching (ES 203 022)
05-11-2015 11:05 | Gyorgy Rethy | Product Version | v4.7.1 (published 2015-06) =>
05-11-2015 11:05 | Gyorgy Rethy | Target Version | Next version (to be defined) => v1.1.1 (published 2017-07)
15-12-2015 10:40 | Gyorgy Rethy | Status | confirmed => assigned
18-07-2016 14:52 | Jens Grabowski | Assigned To | Gyorgy Rethy => KristÃ³f Szabados
20-07-2016 14:32 | Jens Grabowski | Assigned To | KristÃ³f Szabados => Jens Grabowski
15-08-2016 13:17 | Jens Grabowski | Assigned To | Jens Grabowski => Tomas Urban
15-11-2016 14:49 | Tomas Urban | File Added: CR7167-1.docx |
15-11-2016 14:50 | Tomas Urban | Note Added: 0014251 |
15-11-2016 14:50 | Tomas Urban | Assigned To | Tomas Urban => Jacob Wieland - Spirent
15-11-2016 14:50 | Tomas Urban | Status | assigned => confirmed
16-11-2016 14:39 | Tomas Urban | Relationship added | related to 0007494
17-11-2016 09:54 | Jacob Wieland - Spirent | File Added: CR7167-2.docx |
17-11-2016 09:55 | Jacob Wieland - Spirent | Status | confirmed => assigned
17-11-2016 09:55 | Jacob Wieland - Spirent | Note Added: 0014290 |
17-11-2016 09:55 | Jacob Wieland - Spirent | Assigned To | Jacob Wieland - Spirent => Jens Grabowski
17-11-2016 09:55 | Jacob Wieland - Spirent | Status | assigned => confirmed
17-11-2016 12:36 | Jens Grabowski | Status | confirmed => resolved
17-11-2016 12:36 | Jens Grabowski | Resolution | open => fixed
24-12-2016 12:59 | Jens Grabowski | Status | resolved => closed
24-12-2016 12:59 | Jens Grabowski | Fixed in Version | => v1.1.1 (published 2017-07)

Notes

(0013193)
Jacob Wieland - Spirent
07-09-2015 16:23

Obviously, every idea has its time. I have been pondering the same problem for a while and wanted to propose some sort of repeat-statement (where * is just a very special repeat of ? with no length restriction.
Ideas of mine were:
A * [length(L..U)] (where A is a matching mechanism) - similar to BNF
or
A repeat [length(L .. U)]
or
repeat (A1, ..., An) [length(L .. U)]
The existing AnyElementsOrNone (*) would then just be a shorthand of ? * (or the other ways).
We could also borrow the #-repetition from the pattern-language (to have in-language-familiarity for similar constructs), i.e.
A # ([lower], [upper]) with A #(,) being the same as A*.

(0013200)
Gyorgy Rethy
21-09-2015 11:49 (edited on: 21-09-2015 11:50)

alternatively repetition of a template element could be allowed, like:
{{field1 := 3, field2 := pattern "test" }} this will match a record/set of with one element only
{{ field1 := 3, field2 := pattern "test"} length(0..infinity)} this will match a record/set of with any number of elements, each obeying the inline template.
Please note, the syntax is already allowed, in this case we need to amend only the text in clause B.1.4.1, especially Restriction a).

(0013232)
Gyorgy Rethy
22-09-2015 09:38

STF discussion: to specify repetitions of record/set of elements we shall reuse the #(n,m) [#(), #(n,)...) syntax from patterns. This will be language consistent and also allows defining different "subsets" of element repetitoons within a list. Exanmples of the syntax to be prepared for te different cases, e.g. record of record of record, combinations with length() etc.

(0013275)
Jacob Wieland - Spirent
23-09-2015 15:15

Syntactical Structure shall be:
ArrayElementSpec ::= Minus |
PermutationMatch |
TemplateBody [Repetition]
Repetition ::= "#" "(" [SingleExpression] ["," [SingleExpression]] ")"
If Repetition is present, the TemplateBody must be of the same root record of type as the surrounding template (i.e. if it is of root type record of T, the repeated template must also be of root type record of T).
This allows (for the Repetition part):
#() - 0 .. infinity,
#(x) - x .. x,
#(x,) - x .. infinity,
#(x,y) - x .. y,
#(,y) - 0 .. y,
#(,) - 0 .. infinity (if we want to exclude this possibility, the rule becomes more complicated)
The special BNF constructs {}, [] and {}+ can be modeled with #(), #(,1) and #(1,) respectively.
EXAMPLE:
type record of T S;
template T a, b, c;
template S s1 := { a, b, c }
template S s2 := { permutation(a, *, c) length(5) }
var integer x, y;
template S t1 := { {a, b, c} #(x,y) }
// matches any record of repeating elements matching a, b, c consecutively
// for at least x, at most y times.
template S t2 := { s1 #(x,y) } // same as t1
template S t3 := { { (a, b, c) } # (x) }
// matches any repetition of length x where each element conforms to
// (a, b, c) (i.e. a or b or c).
template S t4 := { (s1, s2) #(x,y) }
// matches a sequence that can be partitioned into x up to y
// sub-sequences where each sub-sequence matches s1 or s2.
template S t5 := { p, {s1 #(0,1), s2 #(1,)} #(x), q }
// matches a record of where first element matches p,
// then is followed by a repetition of length x of a
// repetition of an optional s1-sub-sequence followed by
// a non-empty repetition of s2-sub-sequences and finally followed by
// an element matching q.
template S t6 := { s1 & s2 #(5) }
// matches a record of which can be partititioned into 5 sub-sequences
// where each-sub-sequence matches the concatenation-template s1 & s2.
As we can see, it is very easy to compose such templates from other templates and to combine it with existing matching mechanisms.

(0013276)
Jacob Wieland - Spirent
23-09-2015 15:27

please review examples in my last note

(0013466)
Gyorgy Rethy
03-11-2015 11:58

To be part of the new extension on advanced matching mechanisms.

(0014251)
Tomas Urban
15-11-2016 14:50

Proposal uploaded. Please check.

(0014290)
Jacob Wieland - Spirent
17-11-2016 09:55

Please review.