diff --git a/tmpl/parser.cc b/tmpl/parser.cc index 2b7625a..38b81bb 100644 --- a/tmpl/parser.cc +++ b/tmpl/parser.cc @@ -136,6 +136,35 @@ refptr Node::operator[](const std::string & index) : NULL; } +void Token::process() +{ +} + +MatchSet::MatchSet(const char * data, int * ovector, int ovec_size) + : m_data(data), m_ovector(ovector), m_ovec_size(ovec_size) +{ +} + +std::string MatchSet::operator[](int index) +{ + if (0 <= index && index < (m_ovec_size / 3)) + { + int idx = 2 * index; + if (m_ovector[idx] >= 0 && m_ovector[idx + 1] >= 0) + { + return string(m_data, m_ovector[idx], + m_ovector[idx + 1] - m_ovector[idx]); + } + } + return ""; +} + +std::string MatchSet::operator[](const std::string & index) +{ + /* FIXME */ + return ""; +} + #ifdef I_NAMESPACE }; #endif diff --git a/tmpl/parser.h b/tmpl/parser.h index 6aa8cac..6118daf 100644 --- a/tmpl/parser.h +++ b/tmpl/parser.h @@ -121,6 +121,20 @@ class I_CLASSNAME const char * m_errstr; }; +class MatchSet +{ + public: + MatchSet(const char * data, int * ovector, int ovec_size); + std::string operator[](int index); + std::string operator[](const std::string & index); + + protected: + const char * m_data; + int * m_ovector; + int m_ovec_size; +}; +typedef refptr MatchSetRef; + class Node { public: @@ -131,14 +145,16 @@ class Node std::map< std::string, refptr > m_named_children; std::vector< refptr > m_indexed_children; }; - typedef refptr NodeRef; class Token : public Node { public: + virtual void process(); + protected: }; +typedef refptr TokenRef; #ifdef I_NAMESPACE };