I just started using LISP, coming from a background in C. So far its been fun, although with an incredible learning curve (I'm an emacs newbie too).
Anyway, I'm having a silly issue with the following code to parse include statements from c source - if anyone can comment on this and suggest a solution, it would help a lot.
(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>")
I expect the last line to return
"<stdio.h>"
However the actual result is
"#include <stdio.h>"
Any thoughts?
(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))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With