Mercurial > hg
changeset 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 | 5834e79b24f7 |
children | 4c1fe996838c |
files | mercurial/parser.py |
diffstat | 1 files changed, 3 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/parser.py Sat Jun 19 12:51:57 2010 +0200 +++ b/mercurial/parser.py Sat Jun 19 17:56:52 2010 -0500 @@ -62,13 +62,13 @@ expr = (suffix[0], expr) else: # handle infix rules - infix = self._elements[token][2] + if len(e) < 3 or not e[2]: + raise error.ParseError("not an infix: %s" % token, pos) + infix = e[2] if len(infix) == 3 and infix[2] == self.current[0]: self._match(infix[2], pos) expr = (infix[0], expr, (None)) else: - if not infix[0]: - raise error.ParseError("not an infix: %s" % token, pos) expr = (infix[0], expr, self._parse(infix[1])) if len(infix) == 3: self._match(infix[2], pos)