Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Properties | Private Attributes
MoinMoin.support.pygments.scanner.Scanner Class Reference

List of all members.

Public Member Functions

def __init__
def eos
def check
def test
def scan
def get_char
def __repr__

Public Attributes

 data
 data_length
 start_pos
 pos
 flags
 last
 match

Properties

 eos = property(eos, eos.__doc__)

Private Attributes

 _re_cache

Detailed Description

Simple scanner

All method patterns are regular expression strings (not
compiled expressions!)

Definition at line 28 of file scanner.py.


Constructor & Destructor Documentation

def MoinMoin.support.pygments.scanner.Scanner.__init__ (   self,
  text,
  flags = 0 
)
:param text:    The text which should be scanned
:param flags:   default regular expression flags

Definition at line 36 of file scanner.py.

00036 
00037     def __init__(self, text, flags=0):
00038         """
00039         :param text:    The text which should be scanned
00040         :param flags:   default regular expression flags
00041         """
00042         self.data = text
00043         self.data_length = len(text)
00044         self.start_pos = 0
00045         self.pos = 0
00046         self.flags = flags
00047         self.last = None
00048         self.match = None
00049         self._re_cache = {}


Member Function Documentation

Definition at line 99 of file scanner.py.

00099 
00100     def __repr__(self):
00101         return '<%s %d/%d>' % (
00102             self.__class__.__name__,
00103             self.pos,
00104             self.data_length
00105         )
def MoinMoin.support.pygments.scanner.Scanner.check (   self,
  pattern 
)
Apply `pattern` on the current position and return
the match object. (Doesn't touch pos). Use this for
lookahead.

Definition at line 55 of file scanner.py.

00055 
00056     def check(self, pattern):
00057         """
00058         Apply `pattern` on the current position and return
00059         the match object. (Doesn't touch pos). Use this for
00060         lookahead.
00061         """
00062         if self.eos:
00063             raise EndOfText()
00064         if pattern not in self._re_cache:
00065             self._re_cache[pattern] = re.compile(pattern, self.flags)
00066         return self._re_cache[pattern].match(self.data, self.pos)

Here is the caller graph for this function:

`True` if the scanner reached the end of text.

Definition at line 50 of file scanner.py.

00050 
00051     def eos(self):
00052         """`True` if the scanner reached the end of text."""
        return self.pos >= self.data_length
Scan exactly one char.

Definition at line 95 of file scanner.py.

00095 
00096     def get_char(self):
00097         """Scan exactly one char."""
00098         self.scan('.')

Here is the call graph for this function:

def MoinMoin.support.pygments.scanner.Scanner.scan (   self,
  pattern 
)
Scan the text for the given pattern and update pos/match
and related fields. The return value is a boolen that
indicates if the pattern matched. The matched value is
stored on the instance as ``match``, the last value is
stored as ``last``. ``start_pos`` is the position of the
pointer before the pattern was matched, ``pos`` is the
end position.

Definition at line 72 of file scanner.py.

00072 
00073     def scan(self, pattern):
00074         """
00075         Scan the text for the given pattern and update pos/match
00076         and related fields. The return value is a boolen that
00077         indicates if the pattern matched. The matched value is
00078         stored on the instance as ``match``, the last value is
00079         stored as ``last``. ``start_pos`` is the position of the
00080         pointer before the pattern was matched, ``pos`` is the
00081         end position.
00082         """
00083         if self.eos:
00084             raise EndOfText()
00085         if pattern not in self._re_cache:
00086             self._re_cache[pattern] = re.compile(pattern, self.flags)
00087         self.last = self.match
00088         m = self._re_cache[pattern].match(self.data, self.pos)
00089         if m is None:
00090             return False
00091         self.start_pos = m.start()
00092         self.pos = m.end()
00093         self.match = m.group()
00094         return True

Here is the caller graph for this function:

def MoinMoin.support.pygments.scanner.Scanner.test (   self,
  pattern 
)
Apply a pattern on the current position and check
if it patches. Doesn't touch pos.

Definition at line 67 of file scanner.py.

00067 
00068     def test(self, pattern):
00069         """Apply a pattern on the current position and check
00070         if it patches. Doesn't touch pos."""
00071         return self.check(pattern) is not None

Here is the call graph for this function:


Member Data Documentation

Definition at line 48 of file scanner.py.

Definition at line 41 of file scanner.py.

Definition at line 42 of file scanner.py.

Definition at line 45 of file scanner.py.

Definition at line 46 of file scanner.py.

Definition at line 47 of file scanner.py.

Definition at line 44 of file scanner.py.

Definition at line 43 of file scanner.py.


Property Documentation

MoinMoin.support.pygments.scanner.Scanner.eos = property(eos, eos.__doc__) [static]

Definition at line 53 of file scanner.py.


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