##// END OF EJS Templates
parser: make _getalias() return (alias, pattern-args) pair...
Yuya Nishihara -
r28909:edbffdc7 default
parent child Browse files
Show More
@@ -473,8 +473,8 b' class basealiasrules(object):'
473
473
474 @classmethod
474 @classmethod
475 def _getalias(cls, aliases, tree):
475 def _getalias(cls, aliases, tree):
476 """If tree looks like an unexpanded alias, return it. Return None
476 """If tree looks like an unexpanded alias, return (alias, pattern-args)
477 otherwise.
477 pair. Return None otherwise.
478 """
478 """
479 if not isinstance(tree, tuple):
479 if not isinstance(tree, tuple):
480 return None
480 return None
@@ -482,12 +482,12 b' class basealiasrules(object):'
482 name = tree[1]
482 name = tree[1]
483 a = aliases.get(name)
483 a = aliases.get(name)
484 if a and a.args is None:
484 if a and a.args is None:
485 return a
485 return a, None
486 if tree[0] == cls._funcnode and tree[1][0] == cls._symbolnode:
486 if tree[0] == cls._funcnode and tree[1][0] == cls._symbolnode:
487 name = tree[1][1]
487 name = tree[1][1]
488 a = aliases.get(name)
488 a = aliases.get(name)
489 if a and a.args is not None:
489 if a and a.args is not None:
490 return a
490 return a, cls._getlist(tree[2])
491 return None
491 return None
492
492
493 @classmethod
493 @classmethod
@@ -506,10 +506,11 b' class basealiasrules(object):'
506 def _expand(cls, aliases, tree, expanding, cache):
506 def _expand(cls, aliases, tree, expanding, cache):
507 if not isinstance(tree, tuple):
507 if not isinstance(tree, tuple):
508 return tree
508 return tree
509 a = cls._getalias(aliases, tree)
509 r = cls._getalias(aliases, tree)
510 if a is None:
510 if r is None:
511 return tuple(cls._expand(aliases, t, expanding, cache)
511 return tuple(cls._expand(aliases, t, expanding, cache)
512 for t in tree)
512 for t in tree)
513 a, l = r
513 if a.error:
514 if a.error:
514 raise error.Abort(a.error)
515 raise error.Abort(a.error)
515 if a in expanding:
516 if a in expanding:
@@ -526,7 +527,6 b' class basealiasrules(object):'
526 if a.args is None:
527 if a.args is None:
527 return result
528 return result
528 # substitute function arguments in replacement tree
529 # substitute function arguments in replacement tree
529 l = cls._getlist(tree[2])
530 if len(l) != len(a.args):
530 if len(l) != len(a.args):
531 raise error.ParseError(_('invalid number of arguments: %d')
531 raise error.ParseError(_('invalid number of arguments: %d')
532 % len(l))
532 % len(l))
General Comments 0
You need to be logged in to leave comments. Login now