1 #include "automatonparse_promela.h"
6 automaton = xbt_automaton_new_automaton();
9 void new_state(char* id, int src){
11 char* id_state = strdup(id);
12 char* first_part = strtok(id,"_");
13 int type = 0 ; // -1=état initial, 0=état intermédiaire, 1=état final, 2=état initial/final
15 if(strcmp(first_part,"accept")==0){
16 char* second_part = strtok(NULL,"_");
17 if(strcmp(second_part,"init")==0){
24 char* second_part = strtok(NULL,"_");
25 if(strcmp(second_part,"init")==0){
30 xbt_state_t state = NULL;
31 state = xbt_automaton_state_exists(automaton, id_state);
33 state = xbt_automaton_new_state(automaton, type, id_state);
36 if(type==-1 || type==2)
37 automaton->current_state = state;
40 state_id_src = strdup(id_state);
44 void new_transition(char* id, xbt_exp_label_t label){
46 char* id_state = strdup(id);
47 xbt_state_t state_dst = NULL;
49 state_dst = xbt_automaton_state_exists(automaton, id_state);
50 xbt_state_t state_src = xbt_automaton_state_exists(automaton, state_id_src);
52 xbt_transition_t trans = NULL;
53 trans = xbt_automaton_new_transition(automaton, state_src, state_dst, label);
57 xbt_exp_label_t new_label(int type, ...){
58 xbt_exp_label_t label = NULL;
63 xbt_exp_label_t left = va_arg(ap, xbt_exp_label_t);
64 xbt_exp_label_t right = va_arg(ap, xbt_exp_label_t);
65 label = xbt_automaton_new_label(type, left, right);
69 xbt_exp_label_t left = va_arg(ap, xbt_exp_label_t);
70 xbt_exp_label_t right = va_arg(ap, xbt_exp_label_t);
71 label = xbt_automaton_new_label(type, left, right);
75 xbt_exp_label_t exp_not = va_arg(ap, xbt_exp_label_t);
76 label = xbt_automaton_new_label(type, exp_not);
80 char* p = va_arg(ap, char*);
81 label = xbt_automaton_new_label(type, p);
85 label = xbt_automaton_new_label(type);
93 xbt_automaton_t get_automaton(){
97 void display_automaton(){
98 xbt_automaton_display(automaton);