Move ParseError to parser section; add a few type guards.
This commit is contained in:
parent
f08db94db1
commit
f2791c02c3
|
|
@ -323,6 +323,12 @@ token_scanner = Scanner(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ParseError(ValueError):
|
||||||
|
'''
|
||||||
|
Raised when there is a error while parsing text.
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
class Symbol(str):
|
class Symbol(str):
|
||||||
'''
|
'''
|
||||||
A string class that represents Joy function names.
|
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)
|
quote, x, stack = get_n_items(2, stack)
|
||||||
|
isnt_stack(quote)
|
||||||
expr.prepend((x, ()))
|
expr.prepend((x, ()))
|
||||||
expr.prepend(quote)
|
expr.prepend(quote)
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
@ -699,6 +706,7 @@ def i(stack, expr, dictionary):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
quote, stack = get_n_items(1, stack)
|
quote, stack = get_n_items(1, stack)
|
||||||
|
isnt_stack(quote)
|
||||||
expr.prepend(quote)
|
expr.prepend(quote)
|
||||||
return stack, expr, dictionary
|
return stack, expr, dictionary
|
||||||
|
|
||||||
|
|
@ -1312,12 +1320,6 @@ class NotABoolError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ParseError(ValueError):
|
|
||||||
'''
|
|
||||||
Raised when there is a error while parsing text.
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
class StackUnderflowError(Exception):
|
class StackUnderflowError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue