##// END OF EJS Templates
parsers: fix localization markup of parser errors
Mads Kiilerich -
r14701:4b93bd04 stable
parent child Browse files
Show More
@@ -402,7 +402,7 b' def _intree(funcs, tree):'
402 def getfileset(ctx, expr):
402 def getfileset(ctx, expr):
403 tree, pos = parse(expr)
403 tree, pos = parse(expr)
404 if (pos != len(expr)):
404 if (pos != len(expr)):
405 raise error.ParseError("invalid token", pos)
405 raise error.ParseError(_("invalid token"), pos)
406
406
407 # do we need status info?
407 # do we need status info?
408 if _intree(['modified', 'added', 'removed', 'deleted',
408 if _intree(['modified', 'added', 'removed', 'deleted',
@@ -16,6 +16,7 b''
16 # __call__(program) parses program into a labelled tree
16 # __call__(program) parses program into a labelled tree
17
17
18 import error
18 import error
19 from i18n import _
19
20
20 class parser(object):
21 class parser(object):
21 def __init__(self, tokenizer, elements, methods=None):
22 def __init__(self, tokenizer, elements, methods=None):
@@ -34,7 +35,7 b' class parser(object):'
34 def _match(self, m, pos):
35 def _match(self, m, pos):
35 'make sure the tokenizer matches an end condition'
36 'make sure the tokenizer matches an end condition'
36 if self.current[0] != m:
37 if self.current[0] != m:
37 raise error.ParseError("unexpected token: %s" % self.current[0],
38 raise error.ParseError(_("unexpected token: %s") % self.current[0],
38 self.current[2])
39 self.current[2])
39 self._advance()
40 self._advance()
40 def _parse(self, bind=0):
41 def _parse(self, bind=0):
@@ -42,7 +43,7 b' class parser(object):'
42 # handle prefix rules on current token
43 # handle prefix rules on current token
43 prefix = self._elements[token][1]
44 prefix = self._elements[token][1]
44 if not prefix:
45 if not prefix:
45 raise error.ParseError("not a prefix: %s" % token, pos)
46 raise error.ParseError(_("not a prefix: %s") % token, pos)
46 if len(prefix) == 1:
47 if len(prefix) == 1:
47 expr = (prefix[0], value)
48 expr = (prefix[0], value)
48 else:
49 else:
@@ -64,7 +65,7 b' class parser(object):'
64 else:
65 else:
65 # handle infix rules
66 # handle infix rules
66 if len(e) < 3 or not e[2]:
67 if len(e) < 3 or not e[2]:
67 raise error.ParseError("not an infix: %s" % token, pos)
68 raise error.ParseError(_("not an infix: %s") % token, pos)
68 infix = e[2]
69 infix = e[2]
69 if len(infix) == 3 and infix[2] == self.current[0]:
70 if len(infix) == 3 and infix[2] == self.current[0]:
70 self._match(infix[2], pos)
71 self._match(infix[2], pos)
@@ -979,7 +979,7 b' class revsetalias(object):'
979 value = value.replace(arg, repr(arg))
979 value = value.replace(arg, repr(arg))
980 self.replacement, pos = parse(value)
980 self.replacement, pos = parse(value)
981 if pos != len(value):
981 if pos != len(value):
982 raise error.ParseError('invalid token', pos)
982 raise error.ParseError(_('invalid token'), pos)
983 else:
983 else:
984 self.replacement = value
984 self.replacement = value
985
985
@@ -997,7 +997,8 b' class revsetalias(object):'
997 (len(self.args) == 1 and tree[2][0] == 'list') or
997 (len(self.args) == 1 and tree[2][0] == 'list') or
998 (len(self.args) > 1 and (tree[2][0] != 'list' or
998 (len(self.args) > 1 and (tree[2][0] != 'list' or
999 len(tree[2]) - 1 != len(self.args)))):
999 len(tree[2]) - 1 != len(self.args)))):
1000 raise error.ParseError('invalid amount of arguments', len(tree) - 2)
1000 raise error.ParseError(_('invalid amount of arguments'),
1001 len(tree) - 2)
1001 return True
1002 return True
1002
1003
1003 def replace(self, tree):
1004 def replace(self, tree):
@@ -1033,7 +1034,7 b' def match(ui, spec):'
1033 raise error.ParseError(_("empty query"))
1034 raise error.ParseError(_("empty query"))
1034 tree, pos = parse(spec)
1035 tree, pos = parse(spec)
1035 if (pos != len(spec)):
1036 if (pos != len(spec)):
1036 raise error.ParseError("invalid token", pos)
1037 raise error.ParseError(_("invalid token"), pos)
1037 tree = findaliases(ui, tree)
1038 tree = findaliases(ui, tree)
1038 weight, tree = optimize(tree, True)
1039 weight, tree = optimize(tree, True)
1039 def mfunc(repo, subset):
1040 def mfunc(repo, subset):
General Comments 0
You need to be logged in to leave comments. Login now