#ifndef _REPP_H_ #define _REPP_H_ #include #include #include #include #include #include "tToken.h" typedef boost::u32regex tRegex; class tReppRule; //forward declaration of REPP rule class typedef std::vector tReppGroup; class tRepp { bool _quiet; //turn off all informational messages std::map _repps; //conditional includes std::map _groups; //iterative groups std::vector _rules; //repp rules in file order tRegex _tokenizer; // tokenisation pattern std::string _version; std::string _id; //repp name std::string _path; //path that included repps will be relative to void read_file(const char *fname) {}; //included files, unimplemented public: tRepp(const std::string path, const std::string fname, bool q=false); ~tRepp(); std::vector tokenize(const std::string item, std::vector &calls); tReppGroup *getGroup(int id){return _groups[id];} tRepp *getRepp(std::string name){return _repps[name];} std::vector &rules(){return _rules;} std::vector *> startmap; std::vector *> endmap; }; class tReppRule { protected: std::string _type; public: tReppRule(std::string type):_type(type){}; std::string get_type() { return _type; }; virtual std::string name() { return _type; }; virtual std::string apply(tRepp *r, std::string item){ return std::string(); }; }; class tReppFSRule: public tReppRule { tRegex _target; //lhs of rule std::string _targetstr; //mostly for debugging std::string _format; //rhs of rule std::vector _cgroups; //offsets of capture groups in format public: tReppFSRule(std::string type, const char *target, const char *format); std::string apply(tRepp *r, std::string item); std::string name() { return _targetstr; }; }; class tReppGroupRule: public tReppRule { int _group_id; public: tReppGroupRule(std::string type, int group) :tReppRule(type), _group_id(group){}; std::string apply(tRepp *r, std::string item); std::string name(); }; class tReppIncludeRule: public tReppRule { std::string _iname; public: tReppIncludeRule(std::string type, std::string iname) :tReppRule(type), _iname(iname){}; std::string apply(tRepp *r, std::string item); std::string name() {return _iname;}; }; #endif