Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
SubPattern Class Reference

Public Member Functions

def __init__
 
def dump
 
def __repr__
 
def __len__
 
def __delitem__
 
def __getitem__
 
def __setitem__
 
def __getslice__
 
def insert
 
def append
 
def getwidth
 

Data Fields

 pattern
 
 data
 
 width
 

Detailed Description

Definition at line 96 of file sre_parse.py.

Constructor & Destructor Documentation

def __init__ (   self,
  pattern,
  data = None 
)

Definition at line 98 of file sre_parse.py.

98 
99  def __init__(self, pattern, data=None):
100  self.pattern = pattern
101  if not data:
102  data = []
103  self.data = data
self.width = None

Member Function Documentation

def __delitem__ (   self,
  index 
)
def __getitem__ (   self,
  index 
)

Definition at line 137 of file sre_parse.py.

References _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, simple_producer.data, _Environ.data, and FormContentDict.data.

138  def __getitem__(self, index):
return self.data[index]
def __getslice__ (   self,
  start,
  stop 
)

Definition at line 141 of file sre_parse.py.

References _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, simple_producer.data, _Environ.data, FormContentDict.data, SubPattern.pattern, and RegexObject.pattern.

142  def __getslice__(self, start, stop):
return SubPattern(self.pattern, self.data[start:stop])
def __len__ (   self)

Definition at line 133 of file sre_parse.py.

References _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, simple_producer.data, _Environ.data, and FormContentDict.data.

134  def __len__(self):
return len(self.data)
def __repr__ (   self)

Definition at line 131 of file sre_parse.py.

References _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, simple_producer.data, _Environ.data, and FormContentDict.data.

132  def __repr__(self):
return repr(self.data)
def __setitem__ (   self,
  index,
  code 
)

Definition at line 139 of file sre_parse.py.

References _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, simple_producer.data, _Environ.data, and FormContentDict.data.

140  def __setitem__(self, index, code):
self.data[index] = code
def append (   self,
  code 
)

Definition at line 145 of file sre_parse.py.

146  def append(self, code):
self.data.append(code)
def dump (   self,
  level = 0 
)

Definition at line 104 of file sre_parse.py.

References _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, simple_producer.data, _Environ.data, and FormContentDict.data.

105  def dump(self, level=0):
106  nl = 1
107  for op, av in self.data:
108  print level*" " + op,; nl = 0
109  if op == "in":
110  # member sublanguage
111  print; nl = 1
112  for op, a in av:
113  print (level+1)*" " + op, a
114  elif op == "branch":
115  print; nl = 1
116  i = 0
117  for a in av[1]:
118  if i > 0:
119  print level*" " + "or"
120  a.dump(level+1); nl = 1
121  i = i + 1
122  elif type(av) in (type(()), type([])):
123  for a in av:
124  if isinstance(a, SubPattern):
125  if not nl: print
126  a.dump(level+1); nl = 1
127  else:
128  print a, ; nl = 0
129  else:
130  print av, ; nl = 0
if not nl: print
def getwidth (   self)

Definition at line 147 of file sre_parse.py.

References _localized_month.data, _localized_day.data, SubPattern.data, _Hqxcoderengine.data, _Rlecoderengine.data, simple_producer.data, _Environ.data, FormContentDict.data, sre_parse.max, sre_parse.min, and SubPattern.width.

148  def getwidth(self):
149  # determine the width (min, max) for this subpattern
150  if self.width:
151  return self.width
152  lo = hi = 0L
153  for op, av in self.data:
154  if op is BRANCH:
155  i = sys.maxint
156  j = 0
157  for av in av[1]:
158  l, h = av.getwidth()
159  i = min(i, l)
160  j = max(j, h)
161  lo = lo + i
162  hi = hi + j
163  elif op is CALL:
164  i, j = av.getwidth()
165  lo = lo + i
166  hi = hi + j
167  elif op is SUBPATTERN:
168  i, j = av[1].getwidth()
169  lo = lo + i
170  hi = hi + j
171  elif op in (MIN_REPEAT, MAX_REPEAT):
172  i, j = av[2].getwidth()
173  lo = lo + long(i) * av[0]
174  hi = hi + long(j) * av[1]
175  elif op in (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY):
176  lo = lo + 1
177  hi = hi + 1
178  elif op == SUCCESS:
179  break
180  self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint))
181  return self.width
def insert (   self,
  index,
  code 
)

Definition at line 143 of file sre_parse.py.

144  def insert(self, index, code):
self.data.insert(index, code)

Field Documentation

data

Definition at line 102 of file sre_parse.py.

pattern

Definition at line 99 of file sre_parse.py.

width

Definition at line 103 of file sre_parse.py.


The documentation for this class was generated from the following file: