mirror of
https://github.com/lloeki/wasp.git
synced 2025-12-06 10:44:39 +01:00
Ten Primitives (and more) achieved
This commit is contained in:
parent
b6560c6484
commit
cb25bf30a3
5 changed files with 232 additions and 72 deletions
13
repl.py
13
repl.py
|
|
@ -1,4 +1,5 @@
|
|||
import wasp
|
||||
import wasp.ast
|
||||
import readline
|
||||
|
||||
|
||||
|
|
@ -35,13 +36,19 @@ if __name__ == "__main__":
|
|||
continue
|
||||
|
||||
try:
|
||||
ast = context['read'](line)
|
||||
ast = context['read'](wasp.ast.String(line), context)
|
||||
except wasp.lib.ReadError, e:
|
||||
print "Parse error:", e.message
|
||||
continue
|
||||
|
||||
try:
|
||||
print context['eval'](ast, context)
|
||||
result = context['eval'](ast, context)
|
||||
except wasp.SymbolError, e:
|
||||
print "Undefined symbol:", e.message
|
||||
print "Eval error:", e.message
|
||||
continue
|
||||
|
||||
try:
|
||||
context['print'](result, context)
|
||||
except Exception, e:
|
||||
print "Print error:", e.message
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue