1 #include "xbt/automatonparse_promela.h"
3 xbt_automaton_t automaton;
7 automaton = xbt_automaton_new_automaton();
10 void new_state(char* id, int src){
12 char* id_state = strdup(id);
13 char* first_part = strtok(id,"_");
14 int type = 0 ; // -1=état initial, 0=état intermédiaire, 1=état final
16 if(strcmp(first_part,"accept")==0){
19 char* second_part = strtok(NULL,"_");
20 if(strcmp(second_part,"init")==0){
25 xbt_state_t state = NULL;
26 state = xbt_automaton_state_exists(automaton, id_state);
28 state = xbt_automaton_new_state(automaton, type, id_state);
32 automaton->current_state = state;
35 state_id_src = strdup(id_state);
39 void new_transition(char* id, xbt_exp_label_t label){
41 char* id_state = strdup(id);
42 xbt_state_t state_dst = NULL;
44 state_dst = xbt_automaton_state_exists(automaton, id_state);
45 xbt_state_t state_src = xbt_automaton_state_exists(automaton, state_id_src);
47 //xbt_transition_t trans = NULL;
48 xbt_automaton_new_transition(automaton, state_src, state_dst, label);
52 xbt_exp_label_t new_label(int type, ...){
53 xbt_exp_label_t label = NULL;
58 xbt_exp_label_t left = va_arg(ap, xbt_exp_label_t);
59 xbt_exp_label_t right = va_arg(ap, xbt_exp_label_t);
60 label = xbt_automaton_new_label(type, left, right);
64 xbt_exp_label_t left = va_arg(ap, xbt_exp_label_t);
65 xbt_exp_label_t right = va_arg(ap, xbt_exp_label_t);
66 label = xbt_automaton_new_label(type, left, right);
70 xbt_exp_label_t exp_not = va_arg(ap, xbt_exp_label_t);
71 label = xbt_automaton_new_label(type, exp_not);
75 char* p = va_arg(ap, char*);
76 label = xbt_automaton_new_label(type, p);
80 label = xbt_automaton_new_label(type);
88 xbt_automaton_t get_automaton(){