From 2808b605fea61bbd9ff50a46020061579fb19f41 Mon Sep 17 00:00:00 2001 From: sbrandt Date: Tue, 26 Feb 2013 22:08:02 +0000 Subject: (1) Fix compilation issues on Pandora (2) Disallow setting multiple parameters on one line (3) Allow sign in floating point format to be optional (4) Use package piraha (5) change PirahaParser to cctk_PirahaParser (6) remove size.py git-svn-id: http://svn.cactuscode.org/flesh/trunk@4966 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/piraha/AutoGrammar.cc | 2 ++ src/piraha/Bracket.cc | 4 +++- src/piraha/Call.cc | 13 +++++++++---- src/piraha/Dot.cc | 2 ++ src/piraha/End.cc | 2 ++ src/piraha/Grammar.cc | 2 ++ src/piraha/Group.cc | 2 ++ src/piraha/ILiteral.cc | 2 ++ src/piraha/Literal.cc | 2 ++ src/piraha/Lookup.cc | 2 ++ src/piraha/Matcher.cc | 2 ++ src/piraha/Multi.cc | 2 ++ src/piraha/Or.cc | 2 ++ src/piraha/Piraha.hpp | 4 ++++ src/piraha/ReParse.cc | 6 +++++- src/piraha/Seq.cc | 2 ++ src/piraha/Start.cc | 2 ++ src/piraha/size.py | 7 ------- src/piraha/smart_ptr.hpp | 6 ++---- src/util/ParseFile.c | 4 ++-- 20 files changed, 51 insertions(+), 19 deletions(-) delete mode 100644 src/piraha/size.py (limited to 'src') diff --git a/src/piraha/AutoGrammar.cc b/src/piraha/AutoGrammar.cc index 2ecfb741..26789e28 100644 --- a/src/piraha/AutoGrammar.cc +++ b/src/piraha/AutoGrammar.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + smart_ptr AutoGrammar::reparserGenerator() { smart_ptr g = new Grammar(); g->patterns.put("named",new Seq( diff --git a/src/piraha/Bracket.cc b/src/piraha/Bracket.cc index 2856a670..d1c52632 100644 --- a/src/piraha/Bracket.cc +++ b/src/piraha/Bracket.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + typedef vector >::iterator range_iter; bool Range::match(Matcher *m) { @@ -91,7 +93,7 @@ bool Bracket::match(Matcher *m) { } } -std::ostream& operator<<(std::ostream& o,Bracket& b) { +std::ostream& piraha::operator<<(std::ostream& o,Bracket& b) { for(range_iter r = b.ranges.begin();r != b.ranges.end(); ++r) { char lo = (*r)->lo, hi = (*r)->hi; if(lo == hi) { diff --git a/src/piraha/Call.cc b/src/piraha/Call.cc index 0ccce795..9df8fd10 100644 --- a/src/piraha/Call.cc +++ b/src/piraha/Call.cc @@ -7,6 +7,8 @@ #include #include +namespace piraha { + #define VAR(X) " " #X "=" << X extern "C" int CCTK_ParameterFilename(int len, char *filename); @@ -58,7 +60,7 @@ bool lookup_var(smart_ptr gr,std::string& res) { return true; } else if(gr->group(0)->substring() == "pi") { std::ostringstream ostr; - ostr << (4.0*atan2(1,1)) << std::flush; + ostr << (4.0*atan2(1.,1.)) << std::flush; res = ostr.str(); return true; } @@ -176,9 +178,10 @@ void meval(smart_ptr gr,std::string& val) { } } -extern "C" int PirahaParser(const char *buffer,unsigned long buffersize,int (*set_function)(const char *, const char *, int)) { +extern "C" int cctk_PirahaParser(const char *buffer,unsigned long buffersize,int (*set_function)(const char *, const char *, int)) { const char *par_file_src = "skipper = ([ \\t\\r\\n]|\\#.*)*\n" + "skipeol = ([ \\t\\r]|\\#.*)*\\n\n" "# Note that / occurs in some par files. It is my\n" "# feeling that this should require quote marks.\n" @@ -187,7 +190,7 @@ extern "C" int PirahaParser(const char *buffer,unsigned long buffersize,int (*se "inquot = ({var}|\\\\.|[^\\\\\"])*\n" "fname = \\.?/[-\\./0-9a-zA-Z_]+\n" "quot = \"{inquot}\"|{fname}\n" - "num = [-+]?([0-9]+(\\.[0-9]*|)|\\.[0-9]+)(e[+-][0-9]+|)\n" + "num = [-+]?([0-9]+(\\.[0-9]*|)|\\.[0-9]+)(e[+-]?[0-9]+|)\n" "env = ENV\\{{name}\\}\n" "var = \\$({env}|{name}|\\{{name}\\})\n" @@ -205,7 +208,7 @@ extern "C" int PirahaParser(const char *buffer,unsigned long buffersize,int (*se "int = [0-9]+\n" "index = \\[ {int} \\]\n" "active = (?i:ActiveThorns)\n" - "set = ({active}|{par}( {index}|)) = ({array}|{aexpr})\n" + "set = ({active}|{par}( {index}|)) = ({array}|{aexpr}){-skipeol}\n" "file = ( !DESC {quot}|)( ({set} )*)$\n"; smart_ptr g = new Grammar(); @@ -279,3 +282,5 @@ extern "C" int PirahaParser(const char *buffer,unsigned long buffersize,int (*se } return 0; } + +} diff --git a/src/piraha/Dot.cc b/src/piraha/Dot.cc index be0a6e75..8f1b0396 100644 --- a/src/piraha/Dot.cc +++ b/src/piraha/Dot.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + bool Dot::match(Matcher *m) { if(m->pos - m->input_size >= 0) return false; diff --git a/src/piraha/End.cc b/src/piraha/End.cc index 815f9bc7..2c76dceb 100644 --- a/src/piraha/End.cc +++ b/src/piraha/End.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + bool End::match(Matcher *m) { return m->pos == (int)m->input_size; } diff --git a/src/piraha/Grammar.cc b/src/piraha/Grammar.cc index 9cb7f0b0..b222a34a 100644 --- a/src/piraha/Grammar.cc +++ b/src/piraha/Grammar.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + extern smart_ptr compile(smart_ptr g,bool ignCase,smart_ptr gram); smart_ptr pegGrammar = AutoGrammar::reparserGenerator(); diff --git a/src/piraha/Group.cc b/src/piraha/Group.cc index 732a637a..544e12be 100644 --- a/src/piraha/Group.cc +++ b/src/piraha/Group.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + void Group::dump(int indent) { for(int i=0;ipos - m->input_size >= 0) return false; diff --git a/src/piraha/Lookup.cc b/src/piraha/Lookup.cc index ed42e1d1..d2394c2a 100644 --- a/src/piraha/Lookup.cc +++ b/src/piraha/Lookup.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + Lookup::Lookup(std::string name_,smart_ptr g) : gram(g), name(name_), capture(true) { if(name[0] == '-') { capture = false; diff --git a/src/piraha/Matcher.cc b/src/piraha/Matcher.cc index f1a24750..dad67a67 100644 --- a/src/piraha/Matcher.cc +++ b/src/piraha/Matcher.cc @@ -1,6 +1,8 @@ #include #include "Piraha.hpp" +using namespace piraha; + Matcher::Matcher(smart_ptr g_,const char *pat_,const char *input_,int input_size_) : Group(pat_,input_), input(input_), g(g_), input_size(input_size_), diff --git a/src/piraha/Multi.cc b/src/piraha/Multi.cc index c7cfa447..4d718d59 100644 --- a/src/piraha/Multi.cc +++ b/src/piraha/Multi.cc @@ -1,6 +1,8 @@ #include #include "Piraha.hpp" +using namespace piraha; + bool Multi::match(Matcher *m) { unsigned int save; int iter = 0; diff --git a/src/piraha/Or.cc b/src/piraha/Or.cc index eebf2e74..c5caec00 100644 --- a/src/piraha/Or.cc +++ b/src/piraha/Or.cc @@ -2,6 +2,8 @@ #include #include "Piraha.hpp" +using namespace piraha; + Or::Or(Pattern *p,...) : patterns() { va_list ap; va_start(ap,p); diff --git a/src/piraha/Piraha.hpp b/src/piraha/Piraha.hpp index 3ff07d6d..25892fbc 100644 --- a/src/piraha/Piraha.hpp +++ b/src/piraha/Piraha.hpp @@ -7,6 +7,8 @@ #include #include +namespace piraha { + const int max_int = 10000; using std::map; @@ -291,4 +293,6 @@ extern smart_ptr pegGrammar; extern smart_ptr compile(smart_ptr g,bool ignCase,smart_ptr gram); extern void compileFile(smart_ptr g,const char *buffer,signed long buffersize=-1); +} + #endif diff --git a/src/piraha/ReParse.cc b/src/piraha/ReParse.cc index 634e1f10..295b0b29 100644 --- a/src/piraha/ReParse.cc +++ b/src/piraha/ReParse.cc @@ -2,6 +2,8 @@ #include #include +namespace piraha { + char getChar(smart_ptr gr) { if(gr->groupCount()==1) { std::string sub = gr->group(0)->substring(); @@ -73,7 +75,7 @@ void compileFile(smart_ptr g,const char *buffer,signed long buffersize) for(int i=0;igroupCount();i++) { smart_ptr rule = m->group(i); - smart_ptr ptmp = ::compile(rule->group(1), false, g); + smart_ptr ptmp = compile(rule->group(1), false, g); std::string nm = rule->group(0)->substring(); g->patterns.put(nm,ptmp); g->default_rule = nm; @@ -188,3 +190,5 @@ smart_ptr compile(smart_ptr g,bool ignCase,smart_ptr gr } return NULL; } + +} diff --git a/src/piraha/Seq.cc b/src/piraha/Seq.cc index 971c3e44..c0b697bc 100644 --- a/src/piraha/Seq.cc +++ b/src/piraha/Seq.cc @@ -2,6 +2,8 @@ #include #include "Piraha.hpp" +using namespace piraha; + Seq::Seq(Pattern *p,...) { va_list ap; va_start(ap,p); diff --git a/src/piraha/Start.cc b/src/piraha/Start.cc index 527a1b93..52e3cf40 100644 --- a/src/piraha/Start.cc +++ b/src/piraha/Start.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + bool Start::match(Matcher *m) { return m->pos == 0; } diff --git a/src/piraha/size.py b/src/piraha/size.py deleted file mode 100644 index e81a2214..00000000 --- a/src/piraha/size.py +++ /dev/null @@ -1,7 +0,0 @@ -fac = 1+1/4.+1/16. -diff = 1+fac - fac**3 -print diff -init = 16 -nextv = init + (init>>2) + (init>>4) -print nextv -print 1.0*nextv/init diff --git a/src/piraha/smart_ptr.hpp b/src/piraha/smart_ptr.hpp index 0994a821..0ac761b3 100644 --- a/src/piraha/smart_ptr.hpp +++ b/src/piraha/smart_ptr.hpp @@ -20,8 +20,7 @@ extern std::vector ptrs; inline void add(std::vector& v,void *t) { if(t == NULL) return; - typedef typename std::vector::iterator iter; - for(iter i=v.begin();i != v.end();++i) { + for(std::vector::iterator i=v.begin();i != v.end();++i) { assert(*i != t); } v.push_back(t); @@ -30,8 +29,7 @@ inline void add(std::vector& v,void *t) { inline void remove(std::vector& v,void* t) { if(t == NULL) return; - typedef typename std::vector::iterator iter; - for(iter i=v.begin();i != v.end();++i) { + for(std::vector::iterator i=v.begin();i != v.end();++i) { if(*i == t) { v.erase(i); return; diff --git a/src/util/ParseFile.c b/src/util/ParseFile.c index 3d17e787..c35c5037 100644 --- a/src/util/ParseFile.c +++ b/src/util/ParseFile.c @@ -119,7 +119,7 @@ static int lineno = 1; @endreturndesc @@*/ -int PirahaParser(const char *buffer,unsigned long buffersize,int (*set_function)(const char *, const char *, int)); +int cctk_PirahaParser(const char *buffer,unsigned long buffersize,int (*set_function)(const char *, const char *, int)); int ParseFile(FILE *ifp, int (*set_function)(const char *, const char *, int), @@ -137,7 +137,7 @@ int ParseFile(FILE *ifp, // the new way buffersize = strlen(buffer); - retval = PirahaParser(buffer,buffersize,set_function); + retval = cctk_PirahaParser(buffer,buffersize,set_function); } else { // The old way /* Ensure Unix line endings */ -- cgit v1.2.3