From 7b6a86190ffc33ab8a719aea98a3b46c3a800613 Mon Sep 17 00:00:00 2001 From: petr000 Date: Sat, 30 Apr 2011 16:36:45 +0200 Subject: [PATCH] Add creation of the transition table. Now the program can show the state machine in two different ways. --- src/iooper.h | 138 +++++++++++++++++++++++++++++++++++++++------ src/visualizer.cpp | 5 +- 2 files changed, 122 insertions(+), 21 deletions(-) diff --git a/src/iooper.h b/src/iooper.h index acd72c7..6a28b41 100644 --- a/src/iooper.h +++ b/src/iooper.h @@ -20,6 +20,7 @@ #include #include +#include #include "stringoper.h" @@ -33,6 +34,25 @@ class IO_operations string outputFilename; string name_of_machine; string name_of_first_state; + string *table; + int nState; + int cols, rows; + int find_place(string model, int type) + { + if(type == 1) + { + for(unsigned i = 3;i events) { @@ -81,9 +104,13 @@ class IO_operations void write_states(ofstream& filestr) // write states { int pos1, pos2, cnt, subs; - string context, state, ctx; + nState = 1; + string context, state, ctx, sState, str; list nstates = states; context = name_of_machine; + table[0] = "S"; + table[1] = "Context"; + table[2] = "State"; for(list::iterator i = nstates.begin();i!=nstates.end();i++) // write all states in the context of the automaton { state = *i; @@ -94,9 +121,14 @@ class IO_operations ctx = cut_namespaces(state.substr(pos1+1)); if(ctx.compare(0,context.length(),context)==0) { - filestr<::iterator i = nstates.begin();i!=nstates.end();i++) { state = *i; @@ -132,9 +170,14 @@ class IO_operations ctx = cut_namespaces(state.substr(pos1+1)); if(ctx.compare(0,context.length(),context)==0) { - filestr<::iterator i = transitions.begin();i!=transitions.end();i++) // write all transitions { - state = *i; - pos1 = state.find(","); - filestr<"; - pos2 = state.rfind(","); - filestr<"; + pos2 = params.rfind(","); + dest = cut_namespaces(params.substr(pos2+1)); + filestr<::iterator i = events.begin();i!=events.end();i++) + { + table[j] = *i; + j++; + } + } + void save_to_file() // save state automaton to file { if(!name_of_first_state.empty()) { ofstream filestr(outputFilename.c_str()); filestr<<"digraph "<< name_of_machine<< " {\n"; - filestr<getLocation(); if(loc.isValid()) { - //cout<getKind()<<"ss\n"; if(decl->getKind()==35) { method_decl(decl); @@ -222,7 +221,7 @@ class FindStates : public ASTConsumer line = get_line_of_code(x.str()); output = ""; int pos; - const NamedDecl *namedDecl = dyn_cast(decl); + const NamedDecl *namedDecl = dyn_cast(decl); if(is_derived(line)) { const CXXRecordDecl *cRecDecl = dyn_cast(decl); @@ -456,7 +455,7 @@ int main(int argc, char **argv) mdc->BeginSourceFile(lang, &pp);//start using diagnostic ParseAST(pp, &c, ctx, false, false); mdc->EndSourceFile(); //end using diagnostic - IO_operations *io = new IO_operations(outputFilename, c.getStateMachine(), c.getNameOfFirstState(), c.getTransitions(), c.getStates(), c.getEvents()); + IO_operations *io = new IO_operations(outputFilename, c.getStateMachine(), c.getNameOfFirstState(), c.getTransitions(), c.getStates(), c.getEvents()); io->save_to_file(); io->print_stats(); mdc->print_stats(); -- 2.39.2