Mercurial > hg > Members > shinya > pyrect
changeset 107:492daa4d7fa5
add regexp-file option to converter.
author | Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 21 Dec 2010 00:44:53 +0900 |
parents | 8102bf4bbec6 |
children | 2632b963e441 |
files | pyrect/converter.py |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/pyrect/converter.py Tue Dec 14 15:02:25 2010 +0900 +++ b/pyrect/converter.py Tue Dec 21 00:44:53 2010 +0900 @@ -18,14 +18,21 @@ psr.add_option("--from-snfa", action="store_true", dest="snfa", default=False, help="translate from SuffixNFA") psr.add_option("--from-sdfa", action="store_true", dest="sdfa", default=False, help="translate from SuffixDFA") psr.add_option("--from-trie", action="store_true", dest="trie", default=False, help="translate from Trie") + psr.add_option("--regex", action="store", type="string", dest="regex", default=False, help="regexp file", metavar="FILE") psr.add_option("-o", action="store", type="string", dest="output", default=False, help="output file", metavar="FILE") psr.add_option("-O", action="store_true", dest="optimize", default=False, help="do optimization (only in llvm).") psr.add_option("-g", action="store_true", dest="debug", default=False, help="embed debug info") (opts, args) = psr.parse_args(sys.argv) if len(args) == 1: - psr.print_help() - exit() - reg = Regexp(args[1]) + if opts.regex: + file = open(opts.regex, 'r') + reg = Regexp(file.read().rstrip()) + file.close() + else: + psr.print_help() + exit() + else: + reg = Regexp(args[1]) if not opts.output: output = sys.stdout else: