1 /* methods for implementation of automaton from promela description */
3 /* Copyright (c) 2011. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #include "xbt/automatonparse_promela.h"
11 xbt_automaton_t automaton;
15 automaton = xbt_automaton_new_automaton();
18 void new_state(char* id, int src){
20 char* id_state = strdup(id);
21 char* first_part = strtok(id,"_");
22 int type = 0 ; // -1=état initial, 0=état intermédiaire, 1=état final
24 if(strcmp(first_part,"accept")==0){
27 char* second_part = strtok(NULL,"_");
28 if(strcmp(second_part,"init")==0){
33 xbt_state_t state = NULL;
34 state = xbt_automaton_state_exists(automaton, id_state);
36 state = xbt_automaton_new_state(automaton, type, id_state);
40 automaton->current_state = state;
43 state_id_src = strdup(id_state);
47 void new_transition(char* id, xbt_exp_label_t label){
49 char* id_state = strdup(id);
50 xbt_state_t state_dst = NULL;
52 state_dst = xbt_automaton_state_exists(automaton, id_state);
53 xbt_state_t state_src = xbt_automaton_state_exists(automaton, state_id_src);
55 //xbt_transition_t trans = NULL;
56 xbt_automaton_new_transition(automaton, state_src, state_dst, label);
60 xbt_exp_label_t new_label(int type, ...){
61 xbt_exp_label_t label = NULL;
66 xbt_exp_label_t left = va_arg(ap, xbt_exp_label_t);
67 xbt_exp_label_t right = va_arg(ap, xbt_exp_label_t);
68 label = xbt_automaton_new_label(type, left, right);
72 xbt_exp_label_t left = va_arg(ap, xbt_exp_label_t);
73 xbt_exp_label_t right = va_arg(ap, xbt_exp_label_t);
74 label = xbt_automaton_new_label(type, left, right);
78 xbt_exp_label_t exp_not = va_arg(ap, xbt_exp_label_t);
79 label = xbt_automaton_new_label(type, exp_not);
83 char* p = va_arg(ap, char*);
84 label = xbt_automaton_new_label(type, p);
88 label = xbt_automaton_new_label(type);
96 xbt_automaton_t get_automaton(){