X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Fmathml_editor%2Fsrc%2FTDictionary.hh;fp=helm%2FDEVEL%2Fmathml_editor%2Fsrc%2FTDictionary.hh;h=44c020cbe1796fd1fe77bdabc8ef419e297b8e4c;hb=89262281b6e83bd2321150f81f1a0583645eb0c8;hp=0000000000000000000000000000000000000000;hpb=b1fb6b8e1767d775bc452303629e95941d142bea;p=helm.git diff --git a/helm/DEVEL/mathml_editor/src/TDictionary.hh b/helm/DEVEL/mathml_editor/src/TDictionary.hh new file mode 100644 index 000000000..44c020cbe --- /dev/null +++ b/helm/DEVEL/mathml_editor/src/TDictionary.hh @@ -0,0 +1,78 @@ + +#ifndef __TDictionary_hh__ +#define __TDictionary_hh__ + +#include +#include +#include + +#include "TToken.hh" + +class TDictionary +{ +public: + TDictionary(void) { }; + ~TDictionary() { }; + + enum Form + { + INFIX, + PREFIX, + POSTFIX + }; + + enum EntryClass + { + UNDEFINED, + MACRO, + OPERATOR, + IDENTIFIER, + NUMBER + }; + + struct Entry + { + Entry(void) + { + cls = UNDEFINED; + infix = prefix = postfix = 0; + delimiter = limits = embellishment = leftOpen = rightOpen = 0; + }; + + std::vector pattern; + std::string value; + + bool defined(void) const { return cls != UNDEFINED; }; + bool hasArguments(void) const { return !pattern.empty(); }; + bool paramDelimited(unsigned) const; + + EntryClass cls; + unsigned infix : 8; + unsigned prefix : 8; + unsigned postfix : 8; + unsigned delimiter : 1; + unsigned limits : 1; + unsigned embellishment : 1; + unsigned leftOpen : 1; + unsigned rightOpen : 1; + unsigned table : 1; + }; + + void load(const char* uri); + const Entry& find(const std::string&) const; + +private: + struct StringHash : public std::unary_function< std::string, size_t > + { size_t operator()(const std::string& s) const { return hash()(s.c_str()); } }; + +#if 0 + struct StringEq : public std::binary_function< std::string, std::string, bool > + { bool operator()(const std::string&, const class String*) const; }; +#endif + + typedef std::hash_map< std::string, Entry, StringHash > Dictionary; + Dictionary entries; +}; + +#endif // __TDictionary_hh__ +