#include "Piraha.hpp" namespace cctki_piraha { extern smart_ptr compile(smart_ptr g,bool ignCase,smart_ptr gram); smart_ptr pegGrammar = AutoGrammar::reparserGenerator(); void compile(smart_ptr thisg,std::string name,smart_ptr g) { thisg->default_rule = name; smart_ptr p = cctki_piraha::compile(g,false,thisg); thisg->patterns.put(name,p); } void compile(smart_ptr thisg,std::string name,std::string pattern) { thisg->default_rule = name; smart_ptr m = new Matcher(pegGrammar,"pattern",pattern.c_str()); smart_ptr g = m.dup(); if(m->matches()) { smart_ptr p = cctki_piraha::compile(g,false,thisg); thisg->patterns.put(name,p); } else { std::cout << "Could not compile(" << name << "," << pattern << ")" << std::endl; std::cout << "pos = " << m->pos << std::endl; assert(false); } } }