Move ParseError to parser section; add a few type guards.

This commit is contained in:
Simon Forman 2022-09-08 20:59:12 -07:00
parent f08db94db1
commit f2791c02c3
1 changed files with 8 additions and 6 deletions

View File

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