diff options
| -rw-r--r-- | actinide/reader.py | 6 | ||||
| -rwxr-xr-x | bin/actinide-repl | 3 |
2 files changed, 7 insertions, 2 deletions
diff --git a/actinide/reader.py b/actinide/reader.py index 0955309..f7703b5 100644 --- a/actinide/reader.py +++ b/actinide/reader.py @@ -10,6 +10,10 @@ from .types import * class SyntaxError(Exception): pass +# Returned on ``read`` if it has reached the end of the input. This is a +# special, non-interned token guaranteed to be unequal to any other token. +EOF = Symbol('#<end-of-input>') + # Reads one form from a port. This will consume all of the tokens included in # the form, but leave trailing data after the final token untouched. # @@ -23,7 +27,7 @@ class SyntaxError(Exception): def read(port, symbols): head = read_token(port) if head is None: - return None + return EOF if head == ')': raise SyntaxError("Unexpected ')'") if head == '(': diff --git a/bin/actinide-repl b/bin/actinide-repl index de19617..c4343b6 100755 --- a/bin/actinide-repl +++ b/bin/actinide-repl @@ -3,6 +3,7 @@ import sys import actinide as a +import actinide.reader as ar import actinide.ports as ap import actinide.types as at @@ -12,7 +13,7 @@ def repl(session, port): sys.stdout.write("> ") sys.stdout.flush() form = session.read(port) - if form is None: + if form is ar.EOF: print() return 0 results = session.eval(form) |
