From a3cb4c5d02f0ee75094fc27814c71f8a025d034b Mon Sep 17 00:00:00 2001 From: sbrandt Date: Wed, 3 Apr 2013 19:12:46 +0000 Subject: Add the basic grammar files, and the changes to the piraha code necessary to parse all of Cactus. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4990 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/piraha/Piraha.hpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/piraha/Piraha.hpp') diff --git a/src/piraha/Piraha.hpp b/src/piraha/Piraha.hpp index 4308b1fc..b8af3b7a 100644 --- a/src/piraha/Piraha.hpp +++ b/src/piraha/Piraha.hpp @@ -35,6 +35,10 @@ public: int start_,end_; vector > children; + Group(const char *p,const char *value) + : pattern(p), input(value), start_(0) { + for(end_=0;value[end_] != '\0';end_++); + } Group(std::string p,const char *input_) : pattern(p), input(input_), start_(0), end_(0), children() {} Group(std::string p,const char *input_,int s,int e, @@ -49,7 +53,10 @@ public: std::string getPatternName(); std::string substring(); smart_ptr child(int i); - void dump(int indent=0); + void dump(std::ostream& o=std::cout); + void dump(int n,std::ostream& o,int indent=0); + void dumpPerl(std::ostream&o=std::cout); + void dumpPerl(std::ostream&o,int indent); int groupCount() { return children.size(); } smart_ptr group(int i) { return children[i]; } smart_ptr group(const char *nm,int ix=0) { @@ -134,7 +141,7 @@ public: virtual ~Seq() {} bool match(Matcher *m); virtual void insert(std::ostream& o) { - for(int i=0;i 0) o << "|"; o << *patterns[i]; } @@ -304,7 +311,7 @@ public: smart_ptr pattern; NegLookAhead(smart_ptr p) : pattern(p) {} virtual ~NegLookAhead() {} - bool match(Matcher *m) { return true; }//TODO: Fill in + bool match(Matcher *m); }; class LookAhead : public Pattern { @@ -312,15 +319,15 @@ public: smart_ptr pattern; LookAhead(smart_ptr p) : pattern(p) {} virtual ~LookAhead() {} - bool match(Matcher *m) { return true; }//TODO: Fill in + bool match(Matcher *m) { assert(false); }//TODO: Fill in }; class Boundary : public Pattern { - bool match(Matcher *m) { return true; }//TODO: Fill in + virtual bool match(Matcher *m); }; class Break : public Pattern { - bool match(Matcher *m) { return true; }//TODO: Fill in + virtual bool match(Matcher *m) { assert(false); }//TODO: Fill in }; class BackRef : public Pattern { @@ -328,7 +335,7 @@ public: int index; bool ignCase; BackRef(int in,bool ign) : index(in), ignCase(ign) {} - bool match(Matcher *m) { return true; }//TODO: Fill in + virtual bool match(Matcher *m) { assert(false); }//TODO: Fill in }; class AutoGrammar { @@ -362,6 +369,7 @@ extern smart_ptr compile(smart_ptr g,bool ignCase,smart_ptr g,const char *buffer,signed long buffersize=-1); void compile(smart_ptr thisg,std::string name,std::string pattern); void compile(smart_ptr thisg,std::string name,smart_ptr pattern); +void insertc(std::ostream& o,char c); } -- cgit v1.2.3