##// END OF EJS Templates
parser: add stub class that will host alias parsing and expansion...
Yuya Nishihara -
r28870:475dad34 default
parent child Browse files
Show More
@@ -228,3 +228,39 b' def parseerrordetail(inst):'
228 228 return _('at %s: %s') % (inst.args[1], inst.args[0])
229 229 else:
230 230 return inst.args[0]
231
232 class basealiasrules(object):
233 """Parsing and expansion rule set of aliases
234
235 This is a helper for fileset/revset/template aliases. A concrete rule set
236 should be made by sub-classing this and implementing class/static methods.
237
238 It supports alias expansion of symbol and funciton-call styles::
239
240 # decl = defn
241 h = heads(default)
242 b($1) = ancestors($1) - ancestors(default)
243 """
244 # typically a config section, which will be included in error messages
245 _section = None
246 # tags of symbol and function nodes
247 _symbolnode = 'symbol'
248 _funcnode = 'func'
249
250 def __new__(cls):
251 raise TypeError("'%s' is not instantiatable" % cls.__name__)
252
253 @staticmethod
254 def _parsedecl(spec):
255 """Parse an alias name and arguments"""
256 raise NotImplementedError
257
258 @staticmethod
259 def _parsedefn(spec):
260 """Parse an alias definition"""
261 raise NotImplementedError
262
263 @staticmethod
264 def _getlist(tree):
265 """Extract a list of arguments from parsed tree"""
266 raise NotImplementedError
@@ -2366,6 +2366,11 b' def _parsealiasdefn(defn, args):'
2366 2366 tree = parser.simplifyinfixops(tree, ('list', 'or'))
2367 2367 return _relabelaliasargs(tree, args)
2368 2368
2369 class _aliasrules(parser.basealiasrules):
2370 """Parsing and expansion rule set of revset aliases"""
2371 _section = _('revset alias')
2372 _getlist = staticmethod(getlist)
2373
2369 2374 class revsetalias(object):
2370 2375 # whether own `error` information is already shown or not.
2371 2376 # this avoids showing same warning multiple times at each `findaliases`.
General Comments 0
You need to be logged in to leave comments. Login now