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:
parent
691f3fb547
commit
6a29277db4
6 changed files with 851 additions and 185 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue