From f2791c02c3f66617bd840b13a7f5a2b8b9066f45 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Thu, 8 Sep 2022 20:59:12 -0700 Subject: [PATCH] Move ParseError to parser section; add a few type guards. --- implementations/Python/simplejoy.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/implementations/Python/simplejoy.py b/implementations/Python/simplejoy.py index 35d99ae..6c8118c 100755 --- a/implementations/Python/simplejoy.py +++ b/implementations/Python/simplejoy.py @@ -323,6 +323,12 @@ token_scanner = Scanner( ) +class ParseError(ValueError): + ''' + Raised when there is a error while parsing text. + ''' + + class Symbol(str): ''' A string class that represents Joy function names. @@ -681,6 +687,7 @@ def dip(stack, expr, dictionary): ''' quote, x, stack = get_n_items(2, stack) + isnt_stack(quote) expr.prepend((x, ())) expr.prepend(quote) return stack, expr, dictionary @@ -699,6 +706,7 @@ def i(stack, expr, dictionary): ''' quote, stack = get_n_items(1, stack) + isnt_stack(quote) expr.prepend(quote) return stack, expr, dictionary @@ -1312,12 +1320,6 @@ class NotABoolError(Exception): pass -class ParseError(ValueError): - ''' - Raised when there is a error while parsing text. - ''' - - class StackUnderflowError(Exception): pass -- 2.11.0