README.md 1.32 KB
Newer Older
1 2 3
asn1-iterators
==============

4
(c) 2016-2018 European Space Agency
5 6 7 8
Author/Contact: Maxime.Perrotin@esa.int

Generic iterator functions in Ada for generating all combinations of values of ASN.1 data types

9
This is a work in progress in early stage of development.
10

11
The iterators support integer (signed and unsigned), enumerations, and arrays of these types.
12

13
To work with the iterators you need an ASN.1 grammar. You can look at the one in the `test` folder:
14

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
```
TASTE-Dataview DEFINITIONS ::=
BEGIN

MyInteger   ::= INTEGER  (1..4)
MySeqOf     ::= SEQUENCE (SIZE (3))    OF MyInteger
MyVarSeqOf  ::= SEQUENCE (SIZE (1..4)) OF MyInteger
MyEnum      ::= ENUMERATED { hello, world, how-are-you }
MySeqOfEnum ::= SEQUENCE (SIZE (3))    OF MyEnum

END
```

The tool generates Ada iterators for all these types, allowing you to use a syntax like this:

```
declare
   My_Enum : MyEnum_Iterator;
begin
   for Each of My_Enum loop
      Put_Line (Each'Img);
   end loop;
end;

# will print:
# hello
# world
# how_are_you
```

This is a primary feature needed to build up the model checker. It must be possible to iterate on the parameter functions without pre-calculating all possible values in advance. This iteration does not use any memory as the values are computed on the fly (this is similar to Python's iterators, when you use the `yield` keyword).
46