diff --git a/asn1-iterators/README.md b/asn1-iterators/README.md index f6e12e7fd9e3a7389d57e8b26ba69d97151a5643..5bca87dcf5fd210a5521fa1514faae29e41fd0d6 100644 --- a/asn1-iterators/README.md +++ b/asn1-iterators/README.md @@ -1,17 +1,46 @@ asn1-iterators ============== -(c) 2016-2017 European Space Agency +(c) 2016-2018 European Space Agency Author/Contact: Maxime.Perrotin@esa.int Generic iterator functions in Ada for generating all combinations of values of ASN.1 data types -v0.1 support for INTEGER with a range and SEQUENCE OF INTEGER (fixed and variable size arrays) +This is a work in progress in early stage of development. -test: +The iterators support integer (signed and unsigned), enumerations, and arrays of these types. - cd src - make +To work with the iterators you need an ASN.1 grammar. You can look at the one in the `test` folder: -Work in progress... Part of the TASTE project. +``` +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).