Package Martel :: Module convert_re
[show private | hide private]
[frames | no frames]

Module Martel.convert_re

Converts a regular expression pattern string into an Expression tree.

This is not meant to be an externally usable module.

This works by using msre_parse.py to parse the pattern. The result is a tree data structure, where the nodes in the tree are tuples. The first element of the tuple is the name of the node type. The format of the other elements depends on the type.

The conversion routine is pretty simple - convert each msre_parse tuple node into a Martel Expression node. It's a recusive implementation.

'msre_parse.py' is a modified version of Secret Labs' 'sre_parse.py'
Classes
GroupNames  

Function Summary
  convert_any(group_names, name, ignore)
  convert_assert(group_names, name, (direction, terms))
  convert_assert_not(group_names, name, (direction, terms))
  convert_at(group_names, name, where)
  convert_branch(group_names, name, (ignore, branches))
  convert_groupref(group_names, name, id)
  convert_in(group_names, name, terms)
  convert_list(group_names, terms)
  convert_literal(group_names, name, val)
  convert_max_repeat(group_names, name, (min_count, max_count, terms))
  convert_newline(group_names, name, ignore)
  convert_not_literal(group_names, name, val)
  convert_subpattern(group_names, name, (id, terms))
  invert(s)
s -> a string containing all the characters not present in s
  make_expression(pattern)
pattern -> the Expression tree for the given pattern string

Variable Summary
dict categories = {'category_space': '\t\n\x0b\x0c\r ', 'cate...
dict converter_table = {'max_repeat': <function convert_max_r...

Function Details

invert(s)

s -> a string containing all the characters not present in s

make_expression(pattern)

pattern -> the Expression tree for the given pattern string

Variable Details

categories

Type:
dict
Value:
{'category_digit': '0123456789',
 'category_newline': '\n\r',
 'category_not_digit': '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x\
0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x\
1e\x1f !"#$%&\'()*+,-./:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefg\
hijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8\
a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\\
x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xa\
...                                                                    

converter_table

Type:
dict
Value:
{'any': <function convert_any at 0x2aaaada85de8>,
 'assert': <function convert_assert at 0x2aaaada85e60>,
 'assert_not': <function convert_assert_not at 0x2aaaada85ed8>,
 'at': <function convert_at at 0x2aaaada85d70>,
 'branch': <function convert_branch at 0x2aaaada85f50>,
 'groupref': <function convert_groupref at 0x2aaaada892a8>,
 'in': <function convert_in at 0x2aaaada890c8>,
 'literal': <function convert_literal at 0x2aaaada85a28>,
...                                                                    

Generated by Epydoc 2.1 on Thu Jun 30 22:05:39 2005 http://epydoc.sf.net