Commit 5141e1cf authored by Maxime Perrotin's avatar Maxime Perrotin

Added test10 (nested states)

parent 38d82a13
#!/usr/bin/env python
# ASN.1 Data model
# EXPERIMENTAL VERSION
asn1Files = []
asn1Modules = []
exportedTypes = {}
exportedVariables = {}
importedModules = {}
types = {}
asn1Files.append("dataview-uniq.asn")
asn1Modules.append("TASTE-BasicTypes")
exportedTypes["TASTE-BasicTypes"] = ["T-Int32", "T-UInt32", "T-Int8", "T-UInt8", "T-Boolean", "BitString", "OctString", "SeqBit", "SeqBit2"]
exportedVariables["TASTE-BasicTypes"] = []
importedModules["TASTE-BasicTypes"] = []
types["T-Int32"] = type("T-Int32", (object,), {
"Line": 6, "CharPositionInLine": 0, "type": type("T-Int32_type", (object,), {
"Line": 6, "CharPositionInLine": 13, "kind": "IntegerType", "Min": "-2147483648", "Max": "2147483647"
})
})
types["T-UInt32"] = type("T-UInt32", (object,), {
"Line": 8, "CharPositionInLine": 0, "type": type("T-UInt32_type", (object,), {
"Line": 8, "CharPositionInLine": 13, "kind": "IntegerType", "Min": "0", "Max": "4294967295"
})
})
types["T-Int8"] = type("T-Int8", (object,), {
"Line": 10, "CharPositionInLine": 0, "type": type("T-Int8_type", (object,), {
"Line": 10, "CharPositionInLine": 11, "kind": "IntegerType", "Min": "-128", "Max": "127"
})
})
types["T-UInt8"] = type("T-UInt8", (object,), {
"Line": 12, "CharPositionInLine": 0, "type": type("T-UInt8_type", (object,), {
"Line": 12, "CharPositionInLine": 12, "kind": "IntegerType", "Min": "0", "Max": "255"
})
})
types["T-Boolean"] = type("T-Boolean", (object,), {
"Line": 14, "CharPositionInLine": 0, "type": type("T-Boolean_type", (object,), {
"Line": 14, "CharPositionInLine": 14, "kind": "BooleanType"
})
})
types["BitString"] = type("BitString", (object,), {
"Line": 16, "CharPositionInLine": 0, "type": type("BitString_type", (object,), {
"Line": 16, "CharPositionInLine": 14, "kind": "BitStringType", "Min": "32", "Max": "32"
})
})
types["OctString"] = type("OctString", (object,), {
"Line": 17, "CharPositionInLine": 0, "type": type("OctString_type", (object,), {
"Line": 17, "CharPositionInLine": 14, "kind": "OctetStringType", "Min": "4", "Max": "4"
})
})
types["SeqBit"] = type("SeqBit", (object,), {
"Line": 18, "CharPositionInLine": 0, "type": type("SeqBit_type", (object,), {
"Line": 18, "CharPositionInLine": 11, "kind": "SequenceOfType", "Min": "32", "Max": "32", "type": type("SeqOf_type", (object,), {
"Line": 18, "CharPositionInLine": 34, "kind": "BooleanType"
})
})
})
types["SeqBit2"] = type("SeqBit2", (object,), {
"Line": 19, "CharPositionInLine": 0, "type": type("SeqBit2_type", (object,), {
"Line": 19, "CharPositionInLine": 12, "kind": "SequenceOfType", "Min": "1", "Max": "32", "type": type("SeqOf_type", (object,), {
"Line": 19, "CharPositionInLine": 38, "kind": "BooleanType"
})
})
})
asn1Modules.append("TASTE-Dataview")
exportedTypes["TASTE-Dataview"] = ["CountTab", "T-Int32", "T-UInt32", "T-Int8", "T-UInt8", "T-Boolean"]
exportedVariables["TASTE-Dataview"] = ["challenge", "bound", "nb-bit", "val-max", "count-max", "exceed-nb"]
importedModules["TASTE-Dataview"] = [{"TASTE-BasicTypes":{"ImportedTypes": ["T-Int32","T-UInt32","T-Int8","T-UInt8","T-Boolean"], "ImportedVariables": []}}]
types["CountTab"] = type("CountTab", (object,), {
"Line": 36, "CharPositionInLine": 0, "type": type("CountTab_type", (object,), {
"Line": 36, "CharPositionInLine": 13, "kind": "SequenceOfType", "Min": "20", "Max": "20", "type": type("SeqOf_type", (object,), {
"Line": 36, "CharPositionInLine": 40, "kind": "ReferenceType", "ReferencedTypeName": "T-UInt32", "Min": "0", "Max": "4294967295", "ReferencedModName": "TASTE-BasicTypes"
})
})
})
all: compile
generate-code:
../../../opengeode.py --toAda challenge.pr system_structure.pr
compile: generate-code
asn1.exe -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
gnatgcc -c challenge.adb && echo 'All OK!'
parse:
../../../opengeode.py challenge.pr system_structure.pr --check
coverage:
coverage run -p ../../../opengeode.py challenge.pr system_structure.pr --toAda
clean:
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.ali gnat.cfg examiner bin *.wrn *.gpr
PROCESS challenge;
state on;
substructure
in (via_toto);
start;
return;
start via_toto;
return;
endsubstructure;
/* CIF TEXT (-159, 1), (298, 140) */
-- This system tests nested states
/* CIF ENDTEXT */
/* CIF PROCEDURE (-70, 264), (70, 35) */
PROCEDURE toto;
/* CIF TEXT (371, 134), (298, 140) */
-- Declare your variables
-- Syntax: DCL <variable name> <type name>;
dcl i T_Int8 := 1;
/* CIF ENDTEXT */
/* CIF START (178, 86), (70, 35) */
START;
/* CIF DECISION (178, 136), (70, 50) */
DECISION i;
/* CIF ANSWER (131, 206), (73, 23) */
(1):
/* CIF TASK (127, 244), (80, 35) */
TASK i := i + 1;
/* CIF RETURN (150, 294), (35, 35) */
RETURN ;
/* CIF ANSWER (223, 206), (70, 23) */
ELSE:
/* CIF RETURN (240, 244), (35, 35) */
RETURN ;
ENDDECISION;
ENDPROCEDURE;
/* CIF START (227, -15), (68, 37) */
START;
/* CIF NEXTSTATE (226, 37), (70, 35) */
NEXTSTATE OFF;
/* CIF STATE (407, -3), (65, 35) */
STATE ON;
/* CIF INPUT (351, 52), (88, 35) */
INPUT any_one;
/* CIF NEXTSTATE (338, 102), (113, 35) */
NEXTSTATE ON;
/* CIF INPUT (455, 52), (78, 35) */
INPUT go_off;
/* CIF NEXTSTATE (459, 102), (70, 35) */
NEXTSTATE OFF;
ENDSTATE;
/* CIF STATE (226, 37), (70, 35) */
STATE OFF;
/* CIF INPUT (226, 92), (70, 35) */
INPUT run;
/* CIF PROCEDURECALL (178, 142), (166, 35) */
CALL writeln('Going ON');
/* CIF NEXTSTATE (226, 192), (70, 35) */
NEXTSTATE ON;
ENDSTATE;
ENDPROCESS challenge;
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
-- Set of TASTE predefined basic types
T-Int32 ::= INTEGER (-2147483648 .. 2147483647)
T-UInt32 ::= INTEGER (0 .. 4294967295)
T-Int8 ::= INTEGER (-128 .. 127)
T-UInt8 ::= INTEGER (0 .. 255)
T-Boolean ::= BOOLEAN
BitString ::= BIT STRING (SIZE(32))
OctString ::= OCTET STRING (SIZE(4))
SeqBit ::= SEQUENCE (SIZE(32)) OF BOOLEAN
SeqBit2 ::= SEQUENCE (SIZE(1..32)) OF BOOLEAN
END
TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
-- A few simple types to start with ASN.1
challenge T-UInt32 ::= 18
bound T-UInt32 ::= 1000000
nb-bit T-UInt32 ::= 20
val-max T-UInt32 ::= 1048575
count-max T-UInt32 ::= 524288
exceed-nb T-UInt32 ::= 48575
CountTab ::= SEQUENCE (SIZE(nb-bit)) OF T-UInt32
END
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM challenge;
PROCEDURE pow COMMENT '#c_predef';
FPAR
IN a T_UInt32,
IN b T_UInt32,
IN/OUT res T_UInt32;
EXTERNAL;
SIGNAL run;
SIGNAL go_off;
SIGNAL any_one;
signal any_two;
CHANNEL c
FROM ENV TO challenge WITH run, go_off, any_one, any_two;
ENDCHANNEL;
BLOCK challenge;
SIGNALROUTE r
FROM ENV TO challenge WITH run, go_off, any_one, any_two;
CONNECT c and r;
PROCESS challenge REFERENCED;
ENDBLOCK;
ENDSYSTEM;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment