Mercurial > hg > Members > shinya > pyrect
comparison pyrect/regexp/ast.py @ 62:a05baa7dc7ba
modify I/O routine. use mmap. it's really faster than fgets ;-)
author | Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 05 Nov 2010 01:37:35 +0900 |
parents | fd3d0b8326fe |
children | 4de11d799dee |
comparison
equal
deleted
inserted
replaced
60:5ab54a732ddb | 62:a05baa7dc7ba |
---|---|
111 return 1 | 111 return 1 |
112 else: | 112 else: |
113 return -1 | 113 return -1 |
114 | 114 |
115 class Character(InputNode): | 115 class Character(InputNode): |
116 import curses.ascii as ascii | |
117 ASCII = ascii.controlnames + \ | |
118 ["'"+chr(c)+"'" for c in range(33, 127)]\ | |
119 + ['DEL'] + [r"\x%x" % c for c in range(128, 256)] | |
120 | |
116 def __init__(self, char): | 121 def __init__(self, char): |
117 self.char = ord(char) | 122 self.char = ord(char) |
118 | 123 |
119 def __str__(self): | 124 def __str__(self): |
120 if not self.char in range(33, 127): # not Ascii | 125 return self.ASCII[self.char] |
121 c = r"\\x%x" % self.char | |
122 else: | |
123 c = chr(self.char) | |
124 return "'" + c + "'" | |
125 | 126 |
126 def __hash__(self): | 127 def __hash__(self): |
127 return self.char.__hash__() | 128 return self.char.__hash__() |
128 | 129 |
129 class MBCharacter(Character): | 130 class MBCharacter(Character): |