Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/parser.py @ 11412:51ceb1571805
parser: improve infix error checking
(spotted by timeless)
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 19 Jun 2010 17:56:52 -0500 |
parents | 9d1cf337a78d |
children | 05af334bac05 |
comparison
equal
deleted
inserted
replaced
11411:5834e79b24f7 | 11412:51ceb1571805 |
---|---|
60 if len(e) == 4 and not self._elements[self.current[0]][1]: | 60 if len(e) == 4 and not self._elements[self.current[0]][1]: |
61 suffix = e[3] | 61 suffix = e[3] |
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 if len(e) < 3 or not e[2]: |
66 raise error.ParseError("not an infix: %s" % token, pos) | |
67 infix = e[2] | |
66 if len(infix) == 3 and infix[2] == self.current[0]: | 68 if len(infix) == 3 and infix[2] == self.current[0]: |
67 self._match(infix[2], pos) | 69 self._match(infix[2], pos) |
68 expr = (infix[0], expr, (None)) | 70 expr = (infix[0], expr, (None)) |
69 else: | 71 else: |
70 if not infix[0]: | |
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], pos) | 74 self._match(infix[2], pos) |
75 return expr | 75 return expr |
76 def parse(self, message): | 76 def parse(self, message): |