Boolean literals.

This commit is contained in:
Simon Forman 2022-09-07 11:13:12 -07:00
parent 9fbcab6896
commit acd0424287
1 changed files with 6 additions and 5 deletions

View File

@ -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: