/
usr
/
lib
/
python2.6
/
site-packages
/
pygments
/
/usr/lib/python2.6/site-packages/pygments
mkdir
upload
Name
Size
Mode
Actions
filters/
-
0755
rm
formatters/
-
0755
rm
lexers/
-
0755
rm
styles/
-
0755
rm
cmdline.py
13055
0644
edit
dl
rm
cmdline.pyc
10443
0644
edit
dl
rm
cmdline.pyo
10443
0644
edit
dl
rm
console.py
1850
0644
edit
dl
rm
console.pyc
2340
0644
edit
dl
rm
console.pyo
2340
0644
edit
dl
rm
filter.py
2071
0644
edit
dl
rm
filter.pyc
3184
0644
edit
dl
rm
filter.pyo
3184
0644
edit
dl
rm
formatter.py
2790
0644
edit
dl
rm
formatter.pyc
3344
0644
edit
dl
rm
formatter.pyo
3344
0644
edit
dl
rm
lexer.py
22625
0644
edit
dl
rm
lexer.pyc
20971
0644
edit
dl
rm
lexer.pyo
20204
0644
edit
dl
rm
plugin.py
1862
0644
edit
dl
rm
plugin.pyc
2373
0644
edit
dl
rm
plugin.pyo
2373
0644
edit
dl
rm
scanner.py
3114
0644
edit
dl
rm
scanner.pyc
4174
0644
edit
dl
rm
scanner.pyo
4174
0644
edit
dl
rm
style.py
3745
0644
edit
dl
rm
style.pyc
3943
0644
edit
dl
rm
style.pyo
3867
0644
edit
dl
rm
token.py
5784
0644
edit
dl
rm
token.pyc
5408
0644
edit
dl
rm
token.pyo
5408
0644
edit
dl
rm
unistring.py
404249
0644
edit
dl
rm
unistring.pyc
208515
0644
edit
dl
rm
unistring.pyo
208515
0644
edit
dl
rm
util.py
6577
0644
edit
dl
rm
util.pyc
7797
0644
edit
dl
rm
util.pyo
7797
0644
edit
dl
rm
__init__.py
2935
0644
edit
dl
rm
__init__.pyc
3334
0644
edit
dl
rm
__init__.pyo
3334
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/pygments/scanner.py
(3114B)
# -*- coding: utf-8 -*- """ pygments.scanner ~~~~~~~~~~~~~~~~ This library implements a regex based scanner. Some languages like Pascal are easy to parse but have some keywords that depend on the context. Because of this it's impossible to lex that just by using a regular expression lexer like the `RegexLexer`. Have a look at the `DelphiLexer` to get an idea of how to use this scanner. :copyright: Copyright 2006-2009 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ import re class EndOfText(RuntimeError): """ Raise if end of text is reached and the user tried to call a match function. """ class Scanner(object): """ Simple scanner All method patterns are regular expression strings (not compiled expressions!) """ def __init__(self, text, flags=0): """ :param text: The text which should be scanned :param flags: default regular expression flags """ self.data = text self.data_length = len(text) self.start_pos = 0 self.pos = 0 self.flags = flags self.last = None self.match = None self._re_cache = {} def eos(self): """`True` if the scanner reached the end of text.""" return self.pos >= self.data_length eos = property(eos, eos.__doc__) def check(self, pattern): """ Apply `pattern` on the current position and return the match object. (Doesn't touch pos). Use this for lookahead. """ if self.eos: raise EndOfText() if pattern not in self._re_cache: self._re_cache[pattern] = re.compile(pattern, self.flags) return self._re_cache[pattern].match(self.data, self.pos) def test(self, pattern): """Apply a pattern on the current position and check if it patches. Doesn't touch pos.""" return self.check(pattern) is not None def 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. """ if self.eos: raise EndOfText() if pattern not in self._re_cache: self._re_cache[pattern] = re.compile(pattern, self.flags) self.last = self.match m = self._re_cache[pattern].match(self.data, self.pos) if m is None: return False self.start_pos = m.start() self.pos = m.end() self.match = m.group() return True def get_char(self): """Scan exactly one char.""" self.scan('.') def __repr__(self): return '<%s %d/%d>' % ( self.__class__.__name__, self.pos, self.data_length )
Save
cmd:
run