00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00026 #ifndef BOSS_FSA_H
00027 #define BOSS_FSA_H
00028
00029 using namespace std;
00030
00031 #include "boss_types.h"
00032 #include "boss_exceptions.h"
00033 #include <regex.h>
00034 #include <iterator>
00035
00036 namespace BOSS
00037 {
00042 struct NoRegexMatch {
00043 string name;
00044 string inf;
00045 NoRegexMatch(const string & N, const string & I, const bool f = false) :
00046 name(N), inf(I) { if(f) printError(false); }
00047 void printError(const bool & fatal = false) const
00048 {
00049 if(fatal) {
00050 cerr << name << " : Fatal: Unknown phone symbol in: " << inf << endl; exit(-1);
00051 }
00052 else {
00053 cerr << name << " : Unknown phone symbol in: " << inf << ". Ignoring!" << endl;
00054 }
00055 }
00056 };
00057 }
00058
00059 namespace BOSS
00060 {
00061
00076 class FSA {
00077
00078 protected:
00079 regex_t preg;
00080 FSA() {}
00081
00082 public:
00084 FSA(const string & filename) throw(BOSS::FileOpenError, BOSS::FileFormatError);
00085
00087 FSA(const BOSS::t_SVector & expressions) throw(BOSS::FileFormatError);
00088
00092 ~FSA();
00093
00095 BOSS::t_SVector parse(const string & trans) const throw(BOSS::NoRegexMatch);
00096 };
00097 }
00098 #endif