ThirdParty/Pygments/pygments/scanner.py

changeset 5713
6762afd9f963
parent 4697
c2e9bf425554
equal deleted inserted replaced
5712:f0d08bdeacf4 5713:6762afd9f963
10 `RegexLexer`. 10 `RegexLexer`.
11 11
12 Have a look at the `DelphiLexer` to get an idea of how to use 12 Have a look at the `DelphiLexer` to get an idea of how to use
13 this scanner. 13 this scanner.
14 14
15 :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS. 15 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
16 :license: BSD, see LICENSE for details. 16 :license: BSD, see LICENSE for details.
17 """ 17 """
18 import re 18 import re
19 19
20 20
64 self._re_cache[pattern] = re.compile(pattern, self.flags) 64 self._re_cache[pattern] = re.compile(pattern, self.flags)
65 return self._re_cache[pattern].match(self.data, self.pos) 65 return self._re_cache[pattern].match(self.data, self.pos)
66 66
67 def test(self, pattern): 67 def test(self, pattern):
68 """Apply a pattern on the current position and check 68 """Apply a pattern on the current position and check
69 if it patches. Doesn't touch pos.""" 69 if it patches. Doesn't touch pos.
70 """
70 return self.check(pattern) is not None 71 return self.check(pattern) is not None
71 72
72 def scan(self, pattern): 73 def scan(self, pattern):
73 """ 74 """
74 Scan the text for the given pattern and update pos/match 75 Scan the text for the given pattern and update pos/match

eric ide

mercurial