comparison mercurial/fileset.py @ 25654:af329a84310c

parser: accept iterator of tokens instead of tokenizer function and program This can simplify the interface of parse() function. Our tokenizer tends to have optional arguments other than the message to be parsed. Before this patch, the "lookup" argument existed only for the revset, and the templater had to pack [program, start, end] to be passed to its tokenizer.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 21 Jun 2015 00:49:26 +0900
parents 0f44d35731d6
children 328739ea70c3
comparison
equal deleted inserted replaced
25653:9d1e04f5dca7 25654:af329a84310c
78 raise error.ParseError(_("syntax error"), pos) 78 raise error.ParseError(_("syntax error"), pos)
79 pos += 1 79 pos += 1
80 yield ('end', None, pos) 80 yield ('end', None, pos)
81 81
82 def parse(expr): 82 def parse(expr):
83 p = parser.parser(tokenize, elements) 83 p = parser.parser(elements)
84 tree, pos = p.parse(expr) 84 tree, pos = p.parse(tokenize(expr))
85 if pos != len(expr): 85 if pos != len(expr):
86 raise error.ParseError(_("invalid token"), pos) 86 raise error.ParseError(_("invalid token"), pos)
87 return tree 87 return tree
88 88
89 def getstring(x, err): 89 def getstring(x, err):