Mercurial > hg > Members > shinya > pyrect
changeset 81:3dc381c90870
improve booster's routine.
author | Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 10 Nov 2010 22:00:24 +0900 |
parents | 53c3ce58fc8a |
children | f3cbc5d373f8 68cefeb3bee1 |
files | pyrect/translator/grep_translator.py |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pyrect/translator/grep_translator.py Wed Nov 10 19:15:03 2010 +0900 +++ b/pyrect/translator/grep_translator.py Wed Nov 10 22:00:24 2010 +0900 @@ -191,14 +191,15 @@ def emit_booster(self, min_len, chars): self.emiti("void booster(%s) {" % self.interface) + self.emit( "UCHARP end_ = end - %d;" % (min_len-1)) + self.emit( "if (buf > end_) return;") self.emiti( "do {") - self.emit( "if (buf > end) return;") self.emiti( "switch (buf[%d]) {" % (min_len-1)) for c in chars: self.emit( "case %d: /* %s */" % (ord(c), Character.ascii(c))) self.emit( "goto ret;") self.emitd( "}") - self.emitd( "} while(buf += %d);" % min_len) + self.emitd( "} while((buf += %d) <= end_);" % min_len) self.emit( "ret: return %s(%s);" % (self.state_name(self.cg.start) , self.args)) self.emitd("}", 2)