Merge pull request #80 from olasd/bugfix/unbalanced-expressions
Correctly handle unbalanced expressions
This commit is contained in:
commit
48ae1b1e26
@ -161,6 +161,9 @@ class ListeyThing(State):
|
|||||||
if char == self.end_char:
|
if char == self.end_char:
|
||||||
return Idle
|
return Idle
|
||||||
|
|
||||||
|
if char in ")]}":
|
||||||
|
raise LexException("Unexpected closing character: `%s'" % (char))
|
||||||
|
|
||||||
if char in WHITESPACE:
|
if char in WHITESPACE:
|
||||||
self.commit()
|
self.commit()
|
||||||
return
|
return
|
||||||
|
@ -44,6 +44,21 @@ def test_lex_exception():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_unbalanced_exception():
|
||||||
|
"""Ensure the tokenization fails on unbalanced expressions"""
|
||||||
|
try:
|
||||||
|
tokenize("(bar))")
|
||||||
|
assert True is False
|
||||||
|
except LexException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
tokenize("(baz [quux]])")
|
||||||
|
assert True is False
|
||||||
|
except LexException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def test_lex_expression_symbols():
|
def test_lex_expression_symbols():
|
||||||
""" Make sure that expressions produce symbols """
|
""" Make sure that expressions produce symbols """
|
||||||
objs = tokenize("(foo bar)")
|
objs = tokenize("(foo bar)")
|
||||||
|
Loading…
Reference in New Issue
Block a user