Bring it inline with Nim version.
See https://git.sr.ht/~sforman/joytest
This commit is contained in:
parent
49bcab2e91
commit
810a6afdbb
|
|
@ -140,8 +140,8 @@ def interp(stack=(), dictionary=None):
|
||||||
print('Not enough values on stack.')
|
print('Not enough values on stack.')
|
||||||
except NotAnIntError:
|
except NotAnIntError:
|
||||||
print('Not an integer.')
|
print('Not an integer.')
|
||||||
except NotAListError:
|
except NotAListError as e:
|
||||||
print('Not a list.')
|
print(e) # 'Not a list.'
|
||||||
except:
|
except:
|
||||||
print_exc()
|
print_exc()
|
||||||
print(stack_to_string(stack))
|
print(stack_to_string(stack))
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,11 @@ import operator, math
|
||||||
|
|
||||||
from .parser import text_to_expression, Symbol
|
from .parser import text_to_expression, Symbol
|
||||||
from .utils import generated_library as genlib
|
from .utils import generated_library as genlib
|
||||||
from .utils.errors import NotAnIntError, StackUnderflowError
|
from .utils.errors import (
|
||||||
|
NotAListError,
|
||||||
|
NotAnIntError,
|
||||||
|
StackUnderflowError,
|
||||||
|
)
|
||||||
from .utils.stack import (
|
from .utils.stack import (
|
||||||
concat,
|
concat,
|
||||||
expression_to_string,
|
expression_to_string,
|
||||||
|
|
@ -1371,7 +1375,16 @@ def loop(stack, expression, dictionary):
|
||||||
...
|
...
|
||||||
|
|
||||||
'''
|
'''
|
||||||
quote, (flag, stack) = stack
|
try:
|
||||||
|
quote, stack = stack
|
||||||
|
except ValueError:
|
||||||
|
raise StackUnderflowError
|
||||||
|
if not isinstance(quote, tuple):
|
||||||
|
raise NotAListError('Loop body not a list.')
|
||||||
|
try:
|
||||||
|
(flag, stack) = stack
|
||||||
|
except ValueError:
|
||||||
|
raise StackUnderflowError
|
||||||
if flag:
|
if flag:
|
||||||
expression = concat(quote, (quote, (S_loop, expression)))
|
expression = concat(quote, (quote, (S_loop, expression)))
|
||||||
return stack, expression, dictionary
|
return stack, expression, dictionary
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue