diff --git a/src/python/flowmetal/parser.py b/src/python/flowmetal/parser.py index f85cd3a..bd0ff16 100644 --- a/src/python/flowmetal/parser.py +++ b/src/python/flowmetal/parser.py @@ -265,8 +265,12 @@ class Parser(SexpParser): acc = [] while f.peek() != closec: if not f.peek(): - raise SyntaxError(f"Got end of file ({f.pos()}) while parsing {openc!r}...{closec!r} starting at {pos}") - acc.append(cls.parse(rtb)) + raise SyntaxError(f"Got end of file while parsing {openc!r}...{closec!r} starting at {pos}") + try: + acc.append(cls.parse(rtb)) + except SyntaxError as e: + raise SyntaxError(f"While parsing {openc!r}...{closec!r} starting at {pos},\n{e}") + assert rtb.read() == closec # Discard the trailing delimeter return ctor(acc, str(rtb), pos)