changeset 20778:7c4778bc29f0

parser: allow passing a lookup function to a tokenizer This will allow us to dynamically handle hyphenated symbols in revsets.
author Matt Mackall <mpm@selenic.com>
date Tue, 18 Mar 2014 17:17:23 -0500
parents 77318d3c3b24
children ffc2295c6b80
files mercurial/parser.py
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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