equal
deleted
inserted
replaced
14 # elements is a mapping of types to binding strength, primary, prefix, infix |
14 # elements is a mapping of types to binding strength, primary, prefix, infix |
15 # and suffix actions |
15 # and suffix actions |
16 # an action is a tree node name, a tree label, and an optional match |
16 # an action is a tree node name, a tree label, and an optional match |
17 # __call__(program) parses program into a labeled tree |
17 # __call__(program) parses program into a labeled tree |
18 |
18 |
19 from __future__ import absolute_import, print_function |
|
20 |
19 |
21 from .i18n import _ |
20 from .i18n import _ |
22 from . import ( |
21 from . import ( |
23 error, |
22 error, |
24 util, |
23 util, |
25 ) |
24 ) |
26 from .utils import stringutil |
25 from .utils import stringutil |
27 |
26 |
28 |
27 |
29 class parser(object): |
28 class parser: |
30 def __init__(self, elements, methods=None): |
29 def __init__(self, elements, methods=None): |
31 self._elements = elements |
30 self._elements = elements |
32 self._methods = methods |
31 self._methods = methods |
33 self.current = None |
32 self.current = None |
34 |
33 |
414 return _(b'at %d: %s') % (inst.location, inst.message) |
413 return _(b'at %d: %s') % (inst.location, inst.message) |
415 else: |
414 else: |
416 return inst.message |
415 return inst.message |
417 |
416 |
418 |
417 |
419 class alias(object): |
418 class alias: |
420 """Parsed result of alias""" |
419 """Parsed result of alias""" |
421 |
420 |
422 def __init__(self, name, args, err, replacement): |
421 def __init__(self, name, args, err, replacement): |
423 self.name = name |
422 self.name = name |
424 self.args = args |
423 self.args = args |
428 # this avoids showing same warning multiple times at each |
427 # this avoids showing same warning multiple times at each |
429 # `expandaliases`. |
428 # `expandaliases`. |
430 self.warned = False |
429 self.warned = False |
431 |
430 |
432 |
431 |
433 class basealiasrules(object): |
432 class basealiasrules: |
434 """Parsing and expansion rule set of aliases |
433 """Parsing and expansion rule set of aliases |
435 |
434 |
436 This is a helper for fileset/revset/template aliases. A concrete rule set |
435 This is a helper for fileset/revset/template aliases. A concrete rule set |
437 should be made by sub-classing this and implementing class/static methods. |
436 should be made by sub-classing this and implementing class/static methods. |
438 |
437 |