C++ tests set up. They probably don't compile; need to write iostream ops for prettyprinting and set up C++ build in scons.

This commit is contained in:
Meredith L. Patterson 2013-09-03 05:32:21 +02:00
parent 691f3fb547
commit 6a29277db4
6 changed files with 851 additions and 185 deletions

View file

@ -72,6 +72,8 @@ namespace hammer {
class Many1;
template<class T> class Optional;
class RepeatN;
class Ignore;
class Indirect;
template<class T> class IntRange;
template<typename T>
@ -83,8 +85,12 @@ namespace hammer {
Many<T> many();
RepeatN many(size_t n);
Optional<T> optional();
Ignore ignore();
RepeatN operator[](size_t n);
HParser* parser() { return _parser; }
int compile(HParserBackend backend, const void* params) {
return h_compile(_parser, backend, params);
}
protected:
HParser* _parser;
Parser() { }
@ -478,10 +484,17 @@ namespace hammer {
class Indirect : public Parser<T> {
public:
typedef typename T::result_type result_type;
/*
Indirect(Parser<T> &p) : _p(p) {
this->_parser = h_indirect();
h_bind_indirect(this->_parser, p.parser());
}
*/
Indirect() : _p(0) {}
bind(Parser<T> &p) {
this->_parser = h_indirect();
h_bind_indirect(this->_parser, p.parser());
}
private:
Parser<T> _p;
};