parser: allow passing a lookup function to a tokenizer
This will allow us to dynamically handle hyphenated symbols in revsets.
--- a/mercurial/parser.py Sat Mar 15 18:11:51 2014 -0700
+++ b/mercurial/parser.py Tue Mar 18 17:17:23 2014 -0500
@@ -75,9 +75,12 @@
if len(infix) == 3:
self._match(infix[2], pos)
return expr
- def parse(self, message):
+ def parse(self, message, lookup=None):
'generate a parse tree from a message'
- self._iter = self._tokenizer(message)
+ if lookup:
+ self._iter = self._tokenizer(message, lookup)
+ else:
+ self._iter = self._tokenizer(message)
self._advance()
res = self._parse()
token, value, pos = self.current