Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/parser.py @ 25802:cc741c76b26a
parser: remove unused parameter 'pos' from _match()
This backs out 9d1cf337a78d. The issue spotted by that changeset was addressed
earlier by d4cafcb63f77.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 05 Jul 2015 17:50:35 +0900 |
parents | 272ff3680bf3 |
children | b3004d273874 |
comparison
equal
deleted
inserted
replaced
25801:272ff3680bf3 | 25802:cc741c76b26a |
---|---|
27 def _advance(self): | 27 def _advance(self): |
28 'advance the tokenizer' | 28 'advance the tokenizer' |
29 t = self.current | 29 t = self.current |
30 self.current = next(self._iter, None) | 30 self.current = next(self._iter, None) |
31 return t | 31 return t |
32 def _match(self, m, pos): | 32 def _match(self, m): |
33 'make sure the tokenizer matches an end condition' | 33 'make sure the tokenizer matches an end condition' |
34 if self.current[0] != m: | 34 if self.current[0] != m: |
35 raise error.ParseError(_("unexpected token: %s") % self.current[0], | 35 raise error.ParseError(_("unexpected token: %s") % self.current[0], |
36 self.current[2]) | 36 self.current[2]) |
37 self._advance() | 37 self._advance() |
43 raise error.ParseError(_("not a prefix: %s") % token, pos) | 43 raise error.ParseError(_("not a prefix: %s") % token, pos) |
44 if len(prefix) == 1: | 44 if len(prefix) == 1: |
45 expr = (prefix[0], value) | 45 expr = (prefix[0], value) |
46 else: | 46 else: |
47 if len(prefix) > 2 and prefix[2] == self.current[0]: | 47 if len(prefix) > 2 and prefix[2] == self.current[0]: |
48 self._match(prefix[2], pos) | 48 self._match(prefix[2]) |
49 expr = (prefix[0], None) | 49 expr = (prefix[0], None) |
50 else: | 50 else: |
51 expr = (prefix[0], self._parse(prefix[1])) | 51 expr = (prefix[0], self._parse(prefix[1])) |
52 if len(prefix) > 2: | 52 if len(prefix) > 2: |
53 self._match(prefix[2], pos) | 53 self._match(prefix[2]) |
54 # gather tokens until we meet a lower binding strength | 54 # gather tokens until we meet a lower binding strength |
55 while bind < self._elements[self.current[0]][0]: | 55 while bind < self._elements[self.current[0]][0]: |
56 token, value, pos = self._advance() | 56 token, value, pos = self._advance() |
57 infix, suffix = self._elements[token][2:] | 57 infix, suffix = self._elements[token][2:] |
58 # check for suffix - next token isn't a valid prefix | 58 # check for suffix - next token isn't a valid prefix |
61 else: | 61 else: |
62 # handle infix rules | 62 # handle infix rules |
63 if not infix: | 63 if not infix: |
64 raise error.ParseError(_("not an infix: %s") % token, pos) | 64 raise error.ParseError(_("not an infix: %s") % token, pos) |
65 if len(infix) == 3 and infix[2] == self.current[0]: | 65 if len(infix) == 3 and infix[2] == self.current[0]: |
66 self._match(infix[2], pos) | 66 self._match(infix[2]) |
67 expr = (infix[0], expr, (None)) | 67 expr = (infix[0], expr, (None)) |
68 else: | 68 else: |
69 expr = (infix[0], expr, self._parse(infix[1])) | 69 expr = (infix[0], expr, self._parse(infix[1])) |
70 if len(infix) == 3: | 70 if len(infix) == 3: |
71 self._match(infix[2], pos) | 71 self._match(infix[2]) |
72 return expr | 72 return expr |
73 def parse(self, tokeniter): | 73 def parse(self, tokeniter): |
74 'generate a parse tree from tokens' | 74 'generate a parse tree from tokens' |
75 self._iter = tokeniter | 75 self._iter = tokeniter |
76 self._advance() | 76 self._advance() |