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
15 if(strcmp(first_part,"accept")==0){
18 char* second_part = strtok(NULL,"_");
19 if(strcmp(second_part,"init")==0){
24 xbt_state_t state = NULL;
25 state = xbt_automaton_state_exists(automaton, id_state);
27 state = xbt_automaton_new_state(automaton, type, id_state);
31 automaton->current_state = state;
34 state_id_src = strdup(id_state);
38 void new_transition(char* id, xbt_exp_label_t label){
40 char* id_state = strdup(id);
41 xbt_state_t state_dst = NULL;
43 state_dst = xbt_automaton_state_exists(automaton, id_state);
44 xbt_state_t state_src = xbt_automaton_state_exists(automaton, state_id_src);
46 xbt_transition_t trans = NULL;
47 trans = xbt_automaton_new_transition(automaton, state_src, state_dst, label);
51 xbt_exp_label_t new_label(int type, ...){
52 xbt_exp_label_t label = NULL;
57 xbt_exp_label_t left = va_arg(ap, xbt_exp_label_t);
58 xbt_exp_label_t right = va_arg(ap, xbt_exp_label_t);
59 label = xbt_automaton_new_label(type, left, right);
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 exp_not = va_arg(ap, xbt_exp_label_t);
70 label = xbt_automaton_new_label(type, exp_not);
74 char* p = va_arg(ap, char*);
75 label = xbt_automaton_new_label(type, p);
79 label = xbt_automaton_new_label(type);
87 xbt_automaton_t get_automaton(){
91 void display_automaton(){
92 xbt_automaton_display(automaton);