-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextract_events_transitively_and_group.ceps
More file actions
81 lines (74 loc) · 1.73 KB
/
extract_events_transitively_and_group.ceps
File metadata and controls
81 lines (74 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
macro extract_in_events_inner{
for (a_machine:arglist.sm){
for (a_transition:a_machine.t){
for(an_event : a_transition.content().symbol("Event")){
an_event;
}
}
extract_in_events_inner{a_machine.sm;};
}
};
macro extract_events {
for (a_machine:arglist.sm){
comp{
name{a_machine.content().at(0);};
in_ev_pre{
for (a_transition:a_machine.t){
for(an_event : a_transition.content().symbol("Event")){
an_event;
}
}
extract_in_events_inner{a_machine.sm;};
};
in_ev{
predecessor().content().symbol("Event").sort().unique();
};
out_ev_pre{
for (an_action:a_machine.Actions.content().is_struct()){
an_action.fetch_recursively_symbols().symbol("Event");
}
};
out_ev{
predecessor().content().symbol("Event").sort().unique();
};
};
}
};
extract_events{root.sm;};
val endl="\n";
val blank = " ";
val blank4 = " ";
val comma = ",";
val quotes = "\"";
val out_ev_field = " \"out_events\":";
val in_ev_field = " \"in_events\":";
val name_field = " \"name\":";
val lbrace = "{";
val rbrace = "}";
json{
"{";endl;
" \"components\":";endl;
" [";
for(c:root.comp){
endl;
blank4;lbrace;
name_field; quotes; c.name.content(); quotes; comma;
in_ev_field; "[";
for(e:c.in_ev.content().symbol()) {
quotes; e; quotes; if(!last){comma;}
}
"]";comma;
out_ev_field; "[";
for(e:c.out_ev.content().symbol()) {
quotes; e; quotes; if(!last){comma;}
}
"]";
rbrace;
if(!last){comma;};
}
endl;
" ]";
endl;
rbrace;endl;
};
print(root.json.content());