parser: allow passing a lookup function to a tokenizer
authorMatt Mackall <mpm@selenic.com>
Tue, 18 Mar 2014 17:17:23 -0500
changeset 20778 7c4778bc29f0
parent 20777 77318d3c3b24
child 20779 ffc2295c6b80
parser: allow passing a lookup function to a tokenizer This will allow us to dynamically handle hyphenated symbols in revsets.
mercurial/parser.py
--- 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