diff options
-rw-r--r-- | src/piraha/AutoGrammar.cc | 2 | ||||
-rw-r--r-- | src/piraha/Bracket.cc | 4 | ||||
-rw-r--r-- | src/piraha/Call.cc | 13 | ||||
-rw-r--r-- | src/piraha/Dot.cc | 2 | ||||
-rw-r--r-- | src/piraha/End.cc | 2 | ||||
-rw-r--r-- | src/piraha/Grammar.cc | 2 | ||||
-rw-r--r-- | src/piraha/Group.cc | 2 | ||||
-rw-r--r-- | src/piraha/ILiteral.cc | 2 | ||||
-rw-r--r-- | src/piraha/Literal.cc | 2 | ||||
-rw-r--r-- | src/piraha/Lookup.cc | 2 | ||||
-rw-r--r-- | src/piraha/Matcher.cc | 2 | ||||
-rw-r--r-- | src/piraha/Multi.cc | 2 | ||||
-rw-r--r-- | src/piraha/Or.cc | 2 | ||||
-rw-r--r-- | src/piraha/Piraha.hpp | 4 | ||||
-rw-r--r-- | src/piraha/ReParse.cc | 6 | ||||
-rw-r--r-- | src/piraha/Seq.cc | 2 | ||||
-rw-r--r-- | src/piraha/Start.cc | 2 | ||||
-rw-r--r-- | src/piraha/size.py | 7 | ||||
-rw-r--r-- | src/piraha/smart_ptr.hpp | 6 | ||||
-rw-r--r-- | src/util/ParseFile.c | 4 |
20 files changed, 51 insertions, 19 deletions
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<Grammar> AutoGrammar::reparserGenerator() { smart_ptr<Grammar> 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<smart_ptr<Range> >::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 <map> #include <math.h> +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<Group> 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<Group> 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<Grammar> 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<Pattern> compile(smart_ptr<Group> g,bool ignCase,smart_ptr<Grammar> gram); smart_ptr<Grammar> 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;i<indent;i++) std::cout << ' '; diff --git a/src/piraha/ILiteral.cc b/src/piraha/ILiteral.cc index f56d4414..a01c48fd 100644 --- a/src/piraha/ILiteral.cc +++ b/src/piraha/ILiteral.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + ILiteral::ILiteral(char b) : lc(lc_(b)), uc(uc_(b)) {} bool ILiteral::match(Matcher *m) { diff --git a/src/piraha/Literal.cc b/src/piraha/Literal.cc index eedae466..f19f7455 100644 --- a/src/piraha/Literal.cc +++ b/src/piraha/Literal.cc @@ -1,5 +1,7 @@ #include "Piraha.hpp" +using namespace piraha; + bool Literal::match(Matcher *m) { if(m->pos - 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<Grammar> 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 <string.h> #include "Piraha.hpp" +using namespace piraha; + Matcher::Matcher(smart_ptr<Grammar> 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 <iostream> #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 <stdarg.h> #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 <iostream> #include <smart_ptr.hpp> +namespace piraha { + const int max_int = 10000; using std::map; @@ -291,4 +293,6 @@ extern smart_ptr<Grammar> pegGrammar; extern smart_ptr<Pattern> compile(smart_ptr<Group> g,bool ignCase,smart_ptr<Grammar> gram); extern void compileFile(smart_ptr<Grammar> 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 <stdlib.h> #include <string.h> +namespace piraha { + char getChar(smart_ptr<Group> gr) { if(gr->groupCount()==1) { std::string sub = gr->group(0)->substring(); @@ -73,7 +75,7 @@ void compileFile(smart_ptr<Grammar> g,const char *buffer,signed long buffersize) for(int i=0;i<m->groupCount();i++) { smart_ptr<Group> rule = m->group(i); - smart_ptr<Pattern> ptmp = ::compile(rule->group(1), false, g); + smart_ptr<Pattern> 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<Pattern> compile(smart_ptr<Group> g,bool ignCase,smart_ptr<Grammar> 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 <stdarg.h> #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<void*> ptrs; inline void add(std::vector<void*>& v,void *t) { if(t == NULL) return; - typedef typename std::vector<void*>::iterator iter; - for(iter i=v.begin();i != v.end();++i) { + for(std::vector<void*>::iterator i=v.begin();i != v.end();++i) { assert(*i != t); } v.push_back(t); @@ -30,8 +29,7 @@ inline void add(std::vector<void*>& v,void *t) { inline void remove(std::vector<void*>& v,void* t) { if(t == NULL) return; - typedef typename std::vector<void*>::iterator iter; - for(iter i=v.begin();i != v.end();++i) { + for(std::vector<void*>::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 */ |