我正在使用guile / scheme编写测试代码,我试图将文本文件的每一行提取为字符串,并使用(eval-string str)
来评估字符串中的表达式。但是,我收到了In procedure scm_lreadr: #<unknown port>:1:42: end of file in string constant
错误。因此,如何从要使用#<eof>
评估的字符串的末尾删除文件(eval-string str)
对象的末尾。这是示例代码
(define (test-func)
(call-with-input-file "tests.txt"
(lambda (port)
(while #t
(let ((line (get-line port)))
(if (eof-object? line) (break))
(set! line (string-trim line))
(display (format #f "-> ~a\n"line))
(set! line (string-trim (substring line 1)))
(display (format #f "~a\n" line))
(eval-string line)
)))))