mirror of
https://github.com/lloeki/wasp.git
synced 2025-12-06 10:44:39 +01:00
pos might be undefined
This commit is contained in:
parent
457e24fb31
commit
ba160588a0
2 changed files with 8 additions and 2 deletions
3
test.py
3
test.py
|
|
@ -36,6 +36,9 @@ class TestParser(TestCase):
|
|||
self.assertEqual(str(parser.parse("(+ '1 (* 3 2))")),
|
||||
"(+ . ('1 . ((* . (3 . (2 . NIL))) . NIL)))")
|
||||
|
||||
def test_error_unclosed_list(self):
|
||||
self.assertRaises(ValueError, parser.parse("(42"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ pg = ParserGenerator(["QUOTE", "LPAREN", "RPAREN", "ATOM"],
|
|||
def error_handler(token):
|
||||
type = token.gettokentype()
|
||||
pos = token.getsourcepos()
|
||||
if pos is None:
|
||||
raise ValueError("unexpected %s" % type)
|
||||
else:
|
||||
raise ValueError("unexpected %s at (%s, %s)" %
|
||||
(type, pos.lineno, pos.colno))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue