Mercurial > hg
comparison mercurial/parser.py @ 11319:9d1cf337a78d
parser: fix missing param in _match
author | Peter Arrenbrecht <peter.arrenbrecht@gmail.com> |
---|---|
date | Tue, 08 Jun 2010 16:27:59 +0200 |
parents | d4cafcb63f77 |
children | 51ceb1571805 |
comparison
equal
deleted
inserted
replaced
11318:7d780c04f074 | 11319:9d1cf337a78d |
---|---|
28 try: | 28 try: |
29 self.current = self._iter.next() | 29 self.current = self._iter.next() |
30 except StopIteration: | 30 except StopIteration: |
31 pass | 31 pass |
32 return t | 32 return t |
33 def _match(self, m): | 33 def _match(self, m, pos): |
34 'make sure the tokenizer matches an end condition' | 34 'make sure the tokenizer matches an end condition' |
35 if self.current[0] != m: | 35 if self.current[0] != m: |
36 raise error.ParseError("unexpected token: %s" % self.current[0], | 36 raise error.ParseError("unexpected token: %s" % self.current[0], |
37 self.current[2]) | 37 self.current[2]) |
38 self._advance() | 38 self._advance() |
44 raise error.ParseError("not a prefix: %s" % token, pos) | 44 raise error.ParseError("not a prefix: %s" % token, pos) |
45 if len(prefix) == 1: | 45 if len(prefix) == 1: |
46 expr = (prefix[0], value) | 46 expr = (prefix[0], value) |
47 else: | 47 else: |
48 if len(prefix) > 2 and prefix[2] == self.current[0]: | 48 if len(prefix) > 2 and prefix[2] == self.current[0]: |
49 self._match(prefix[2]) | 49 self._match(prefix[2], pos) |
50 expr = (prefix[0], None) | 50 expr = (prefix[0], None) |
51 else: | 51 else: |
52 expr = (prefix[0], self._parse(prefix[1])) | 52 expr = (prefix[0], self._parse(prefix[1])) |
53 if len(prefix) > 2: | 53 if len(prefix) > 2: |
54 self._match(prefix[2]) | 54 self._match(prefix[2], pos) |
55 # gather tokens until we meet a lower binding strength | 55 # gather tokens until we meet a lower binding strength |
56 while bind < self._elements[self.current[0]][0]: | 56 while bind < self._elements[self.current[0]][0]: |
57 token, value, pos = self._advance() | 57 token, value, pos = self._advance() |
58 e = self._elements[token] | 58 e = self._elements[token] |
59 # check for suffix - next token isn't a valid prefix | 59 # check for suffix - next token isn't a valid prefix |
62 expr = (suffix[0], expr) | 62 expr = (suffix[0], expr) |
63 else: | 63 else: |
64 # handle infix rules | 64 # handle infix rules |
65 infix = self._elements[token][2] | 65 infix = self._elements[token][2] |
66 if len(infix) == 3 and infix[2] == self.current[0]: | 66 if len(infix) == 3 and infix[2] == self.current[0]: |
67 self._match(infix[2]) | 67 self._match(infix[2], pos) |
68 expr = (infix[0], expr, (None)) | 68 expr = (infix[0], expr, (None)) |
69 else: | 69 else: |
70 if not infix[0]: | 70 if not infix[0]: |
71 raise error.ParseError("not an infix: %s" % token, pos) | 71 raise error.ParseError("not an infix: %s" % token, pos) |
72 expr = (infix[0], expr, self._parse(infix[1])) | 72 expr = (infix[0], expr, self._parse(infix[1])) |
73 if len(infix) == 3: | 73 if len(infix) == 3: |
74 self._match(infix[2]) | 74 self._match(infix[2], pos) |
75 return expr | 75 return expr |
76 def parse(self, message): | 76 def parse(self, message): |
77 'generate a parse tree from a message' | 77 'generate a parse tree from a message' |
78 self._iter = self._tokenizer(message) | 78 self._iter = self._tokenizer(message) |
79 self.current = self._iter.next() | 79 self.current = self._iter.next() |