我刚开始使用 LISP,具有 C 语言背景。到目前为止它很有趣,尽管学习曲线令人难以置信(我也是 emacs 新手)。
无论如何,我在解析来自 c 源代码的 include 语句时遇到了一个愚蠢的问题——如果有人可以对此发表评论并提出解决方案,那将大有帮助。
(defun include-start ( line )
(search "#include " line))
(defun get-include( line )
(let ((s (include-start line)))
(if (not (eq NIL s))
(subseq line s (length line)))))
(get-include "#include <stdio.h>")
我希望最后一行返回
"<stdio.h>"
然而实际结果却是
"#include <stdio.h>"
有什么想法吗?
(defun include-start (line)
"returns the string position after the '#include ' directive or nil if none"
(let ((search-string "#include "))
(when (search search-string line)
(length search-string))))
(defun get-include (line)
(let ((s (include-start line)))
(when s
(subseq line s))))
我是一名优秀的程序员,十分优秀!