00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00032 #ifndef _moot_FSM_GFSM_H
00033 #define _moot_FSM_GFSM_H
00034
00035 #ifdef HAVE_CONFIG_H
00036 # include <mootmUnConfig.h>
00037 # include <mootmConfig.h>
00038 #endif
00039
00040 #if defined(USE_FSM_GFSM)
00041
00042 #include <mootFSMBase.h>
00043
00044 extern "C" {
00045 #include <gfsm.h>
00046 }
00047
00048 namespace mootm {
00049 using namespace std;
00050 using namespace moot;
00051
00053 typedef class mootFSMgfsm mootFSM;
00054
00055
00056
00057
00058
00059
00061 struct _mootFSMgfsm_analyze_token_params {
00062 gfsmAlphabet *abet;
00063 gboolean warn_on_undefined;
00064 gboolean att_style;
00065 mootToken *tokp;
00066 GString *gstr;
00067 };
00068
00070 gboolean _mootFSMgfsm_analyze_token_foreach_func(gfsmPath *path,
00071 gpointer value_dummy,
00072 struct _mootFSMgfsm_analyze_token_params *params);
00073
00074
00078 class mootFSMgfsm : public mootFSMBase {
00079 protected:
00080
00081
00082
00083 gfsmAlphabet *abet_lo;
00084 gfsmAlphabet *abet_hi;
00085 gfsmAutomaton *mfst;
00087 gfsmLabelVector *tlabs;
00088 gfsmAutomaton *result;
00089 gfsmSet *paths;
00090 struct _mootFSMgfsm_analyze_token_params analyze_params;
00092 public:
00093
00094
00095
00097 mootFSMgfsm(void)
00098 : abet_lo(NULL),
00099 abet_hi(NULL),
00100 mfst(NULL),
00101 tlabs(NULL),
00102 result(NULL),
00103 paths(NULL)
00104 {
00105 analyze_params.abet=NULL;
00106 analyze_params.warn_on_undefined=TRUE;
00107 analyze_params.att_style=TRUE;
00108 analyze_params.tokp=NULL;
00109 analyze_params.gstr=g_string_new("");
00110 };
00111
00113 ~mootFSMgfsm(void) {
00114 if (abet_lo) gfsm_alphabet_free(abet_lo);
00115 if (abet_hi && abet_hi != abet_lo) gfsm_alphabet_free(abet_hi);
00116 if (mfst) gfsm_automaton_free(mfst);
00117 if (tlabs) g_ptr_array_free(tlabs,TRUE);
00118 if (result) gfsm_automaton_free(result);
00119 if (paths) gfsm_set_free(paths);
00120 if (analyze_params.gstr) { g_string_free(analyze_params.gstr,TRUE); }
00121 };
00122
00126 virtual bool load(const string &fstfile, const string &symfile="");
00127
00129 virtual bool valid(void) const
00130 { return abet_lo && abet_hi && mfst; }
00131
00133 virtual mootToken& analyze_token(mootToken &tok, bool want_avm=true, bool want_warnings=true);
00134
00135 };
00136
00137
00138
00139 };
00140
00141 #endif
00142
00143
00144 #ifdef HAVE_CONFIG_H
00145 # include <mootmUnConfig.h>
00146 #endif
00147
00148
00149 #endif