Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
spark.GenericScanner Class Reference
Inheritance diagram for spark.GenericScanner:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def makeRE
def reflect
def error
def tokenize
def t_default

Public Attributes

 re
 index2func

Detailed Description

Definition at line 49 of file spark.py.


Constructor & Destructor Documentation

def spark.GenericScanner.__init__ (   self,
  flags = 0 
)

Definition at line 50 of file spark.py.

00050 
00051     def __init__(self, flags=0):
00052         pattern = self.reflect()
00053         self.re = re.compile(pattern, re.VERBOSE|flags)
00054 
00055         self.index2func = {}
00056         for name, number in self.re.groupindex.items():
00057             self.index2func[number-1] = getattr(self, 't_' + name)

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

def spark.GenericScanner.error (   self,
  s,
  pos 
)

Definition at line 72 of file spark.py.

00072 
00073     def error(self, s, pos):
00074         output("Lexical error at position %s" % pos)
00075         raise SystemExit

Here is the call graph for this function:

Here is the caller graph for this function:

def spark.GenericScanner.makeRE (   self,
  name 
)

Definition at line 58 of file spark.py.

00058 
00059     def makeRE(self, name):
00060         doc = getattr(self, name).__doc__
00061         rv = '(?P<%s>%s)' % (name[2:], doc)
00062         return rv

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 63 of file spark.py.

00063 
00064     def reflect(self):
00065         rv = []
00066         for name in _namelist(self):
00067             if name[:2] == 't_' and name != 't_default':
00068                 rv.append(self.makeRE(name))
00069 
00070         rv.append(self.makeRE('t_default'))
00071         return '|'.join(rv)

Here is the call graph for this function:

Here is the caller graph for this function:

def spark.GenericScanner.t_default (   self,
  s 
)

Reimplemented in asdl.ASDLScanner.

Definition at line 90 of file spark.py.

00090 
00091     def t_default(self, s):
00092         r'( . | \n )+'
00093         output("Specification error: unmatched input")
00094         raise SystemExit
00095 
00096 #
00097 #  Extracted from GenericParser and made global so that [un]picking works.
#

Here is the call graph for this function:

def spark.GenericScanner.tokenize (   self,
  s 
)

Reimplemented in asdl.ASDLScanner.

Definition at line 76 of file spark.py.

00076 
00077     def tokenize(self, s):
00078         pos = 0
00079         n = len(s)
00080         while pos < n:
00081             m = self.re.match(s, pos)
00082             if m is None:
00083                 self.error(s, pos)
00084 
00085             groups = m.groups()
00086             for i in range(len(groups)):
00087                 if groups[i] and i in self.index2func:
00088                     self.index2func[i](groups[i])
00089             pos = m.end()

Here is the call graph for this function:


Member Data Documentation

Definition at line 54 of file spark.py.

Definition at line 52 of file spark.py.


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