Make read read line-wise and don't ignore Lexer Errors

This allows us to react to things like "(foo))" being passed in instead of
looping until kingdom come. Also makes tokenizing things that are not
expressions easier:

    => (read)
    "foo"
    u'foo'
    =>
This commit is contained in:
Gregor Best 2015-07-28 16:57:50 +02:00
parent 4fe67c11a4
commit 1de5513e48

View File

@ -371,13 +371,13 @@
Can take a given input buffer to read from"
(def buff "")
(while true
(def inn (str (.read from-file 1)))
(def inn (str (.readline from-file)))
(if (= inn eof)
(throw (EOFError "Reached end of file" )))
(setv buff (+ buff inn))
(try
(def parsed (first (tokenize buff)))
(except [e [LexException PrematureEndOfInput IndexError]])
(except [e [PrematureEndOfInput IndexError]])
(else (if parsed (break)))))
parsed)