From acd0424287c2c0899dd9b78f1fea5f9b5adde93d Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Wed, 7 Sep 2022 11:13:12 -0700 Subject: [PATCH] Boolean literals. --- implementations/Python/simplejoy.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/implementations/Python/simplejoy.py b/implementations/Python/simplejoy.py index 9ce3d38..d6e2847 100644 --- a/implementations/Python/simplejoy.py +++ b/implementations/Python/simplejoy.py @@ -34,9 +34,6 @@ from traceback import print_exc import operator -JOY_BOOL_LITERALS = 'false', 'true' - - class NotAListError(Exception): pass @@ -117,6 +114,10 @@ brackets. Terms must be separated by blanks, which can be omitted around square brackets. ''' + +JOY_BOOL_LITERALS = _T, _F = 'false', 'true' + + BRACKETS = r'\[|\]' # Left or right square bracket. BLANKS = r'\s+' # One-or-more blankspace. WORDS = ( @@ -195,9 +196,9 @@ def _parse(tokens): except IndexError: raise ParseError('Extra closing bracket.') from None frame.append(list_to_stack(v)) - elif tok == 'true': + elif tok == _T: frame.append(True) - elif tok == 'false': + elif tok == _F: frame.append(False) else: try: