Go to the documentation of this file.00001 #ifndef PROCEDURE_NWAS_HPP
00002 #define PROCEDURE_NWAS_HPP
00003
00004 #include "Nwa.hpp"
00005
00006 #include <map>
00007 #include <string>
00008
00009 #include <boost/function.hpp>
00010
00011 namespace opennwa {
00012
00013
00014 typedef std::map<std::string, NwaRefPtr> ProcedureMap;
00015
00016
00017 struct CallReturnTransitionInserter {
00018 const Symbol call_symbol;
00019 const Symbol return_symbol;
00020
00021 CallReturnTransitionInserter(Symbol _call_symbol,
00022 Symbol _return_symbol)
00023 : call_symbol(_call_symbol)
00024 , return_symbol(_return_symbol)
00025 {}
00026
00027 void operator() (Nwa & nwa, State source, State target) {
00028 nwa.addCallTrans(source, call_symbol, target);
00029 }
00030
00031 void operator() (Nwa & nwa, State source, State pred, State target) {
00032 nwa.addReturnTrans(source, pred, return_symbol, target);
00033 }
00034 };
00035
00036
00037 struct EpsilonTransitionInserter {
00038 void operator() (Nwa & nwa, State source, State target) {
00039 nwa.addInternalTrans(source, EPSILON, target);
00040 }
00041
00042 void operator() (Nwa & nwa, State source, State pred, State target) {
00043 (void) pred;
00044 nwa.addInternalTrans(source, EPSILON, target);
00045 }
00046 };
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 NwaRefPtr
00061 assemble_nwa(ProcedureMap const & procedures,
00062 boost::function<void (Nwa &, State, State)> call_inserter,
00063 boost::function<void (Nwa &, State, State, State)> return_inserter);
00064
00065
00066 }
00067
00068
00069
00070
00071
00072
00073
00074
00075 #endif