Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
re.Scanner Class Reference

List of all members.

Public Member Functions

def __init__
def scan

Public Attributes

 lexicon
 scanner
 match

Detailed Description

Definition at line 301 of file re.py.


Constructor & Destructor Documentation

def re.Scanner.__init__ (   self,
  lexicon,
  flags = 0 
)

Definition at line 302 of file re.py.

00302 
00303     def __init__(self, lexicon, flags=0):
00304         from sre_constants import BRANCH, SUBPATTERN
00305         self.lexicon = lexicon
00306         # combine phrases into a compound pattern
00307         p = []
00308         s = sre_parse.Pattern()
00309         s.flags = flags
00310         for phrase, action in lexicon:
00311             p.append(sre_parse.SubPattern(s, [
00312                 (SUBPATTERN, (len(p)+1, sre_parse.parse(phrase, flags))),
00313                 ]))
00314         s.groups = len(p)+1
00315         p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
        self.scanner = sre_compile.compile(p)

Here is the caller graph for this function:


Member Function Documentation

def re.Scanner.scan (   self,
  string 
)

Definition at line 316 of file re.py.

00316 
00317     def scan(self, string):
00318         result = []
00319         append = result.append
00320         match = self.scanner.scanner(string).match
00321         i = 0
00322         while 1:
00323             m = match()
00324             if not m:
00325                 break
00326             j = m.end()
00327             if i == j:
00328                 break
00329             action = self.lexicon[m.lastindex-1][1]
00330             if hasattr(action, "__call__"):
00331                 self.match = m
00332                 action = action(self, m.group())
00333             if action is not None:
00334                 append(action)
00335             i = j
00336         return result, string[i:]

Here is the caller graph for this function:


Member Data Documentation

Definition at line 304 of file re.py.

Definition at line 330 of file re.py.

Definition at line 315 of file re.py.


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