Mercurial > hg
diff mercurial/revset.py @ 29072:f86fa7168059
revset: inline _tokenizealias() into _parsealias()
This helps factoring out common part between _parsealias() and parse().
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 17 Apr 2016 12:57:27 +0900 |
parents | ea794f2eb19d |
children | 81bac118f9e2 |
line wrap: on
line diff
--- a/mercurial/revset.py Sun Apr 10 07:28:26 2016 +0000 +++ b/mercurial/revset.py Sun Apr 17 12:57:27 2016 +0900 @@ -2217,18 +2217,12 @@ _aliassyminitletters = set(c for c in [chr(i) for i in xrange(256)] if c.isalnum() or c in '._@$' or ord(c) > 127) -def _tokenizealias(program, lookup=None): - """Parse alias declaration/definition into a stream of tokens +def _parsealias(spec): + """Parse alias declaration/definition ``spec`` This allows symbol names to use also ``$`` as an initial letter (for backward compatibility), and callers of this function should examine whether ``$`` is used also for unexpected symbols or not. - """ - return tokenize(program, lookup=lookup, - syminitletters=_aliassyminitletters) - -def _parsealias(spec): - """Parse alias declaration/definition ``spec`` >>> _parsealias('foo($1)') ('func', ('symbol', 'foo'), ('symbol', '$1')) @@ -2238,7 +2232,7 @@ ParseError: ('invalid token', 4) """ p = parser.parser(elements) - tree, pos = p.parse(_tokenizealias(spec)) + tree, pos = p.parse(tokenize(spec, syminitletters=_aliassyminitletters)) if pos != len(spec): raise error.ParseError(_('invalid token'), pos) return parser.simplifyinfixops(tree, ('list', 'or'))