:1:42: 字符串常量中的文件结尾,scheme,guile"/>

首页 > 解决方案 > 在程序 scm_lreadr: #:1:42: 字符串常量中的文件结尾

问题描述

我正在使用 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)
)))))

标签: schemeguile

解决方案


推荐阅读