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

Public Member Functions

def __init__
 
def scan
 

Data Fields

 lexicon
 
 scanner
 
 match
 

Detailed Description

Definition at line 276 of file sre.py.

Constructor & Destructor Documentation

def __init__ (   self,
  lexicon,
  flags = 0 
)

Definition at line 277 of file sre.py.

278  def __init__(self, lexicon, flags=0):
279  from sre_constants import BRANCH, SUBPATTERN
280  self.lexicon = lexicon
281  # combine phrases into a compound pattern
282  p = []
283  s = sre_parse.Pattern()
284  s.flags = flags
285  for phrase, action in lexicon:
286  p.append(sre_parse.SubPattern(s, [
287  (SUBPATTERN, (len(p)+1, sre_parse.parse(phrase, flags))),
288  ]))
289  p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
290  s.groups = len(p)
self.scanner = sre_compile.compile(p)

Member Function Documentation

def scan (   self,
  string 
)

Definition at line 291 of file sre.py.

References Scanner.lexicon, and Scanner.match.

292  def scan(self, string):
293  result = []
294  append = result.append
295  match = self.scanner.scanner(string).match
296  i = 0
297  while 1:
298  m = match()
299  if not m:
300  break
301  j = m.end()
302  if i == j:
303  break
304  action = self.lexicon[m.lastindex-1][1]
305  if callable(action):
306  self.match = m
307  action = action(self, m.group())
308  if action is not None:
309  append(action)
310  i = j
311  return result, string[i:]

Field Documentation

lexicon

Definition at line 279 of file sre.py.

match

Definition at line 305 of file sre.py.

scanner

Definition at line 290 of file sre.py.


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