Mercurial > hg > Members > shinya > pyrect
changeset 93:82a8232625c3
implement range. but it's not perfect.
author | Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 06 Dec 2010 04:46:38 +0900 |
parents | 87cd1db7ec3f |
children | 492f543703d5 |
files | pyrect/regexp/nfa_translator.py |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pyrect/regexp/nfa_translator.py Sun Dec 05 01:48:56 2010 +0900 +++ b/pyrect/regexp/nfa_translator.py Mon Dec 06 04:46:38 2010 +0900 @@ -114,6 +114,14 @@ return frag + def visit_Range(self, range_): + elems = range(range_.lower.char, range_.upper.char+1) + elems = map(chr, elems) + elems = map(Character, elems) + union = reduce(Union, elems) + return union.accept(self) + + def test(): import doctest doctest.testmod()