我想使用elisp来标记化以下内容:
variable := "The symbol \" delimits strings"; (* Comments go here *)作为:
<variable> <:=> <The symbol \" delimits strings> <;>基于来自缓冲区的syntax-table的信息。
我已经正确地设置了symbol-table,并且目前正在使用以下函数,除了字符串常量(如果point不在标识符或正则表达式中的某个运算符上,则返回token或nil ),该函数运行正常。
(defun forward-token ()
(forward-comment (point-max))
(cond
((looking-at (regexp-opt '("=" ":=" "," ";")))
(goto-char (match-end 0))
(match-string-no-properties 0))
(t (buffer-substring-no-properties
(point)
(progn (skip-syntax-forward "w_")
(point))))))我是一个elisp新手,所以任何指针都是非常感谢的。
发布于 2013-03-13 23:20:05
我不认为您的skip-syntax-forward使用字符串是正确的。我认为您需要添加一个cond子句,如下所示:
((looking-at "\"")
(let* ((here (point)) (there (scan-sexps here 1)))
(goto-char there)
(buffer-substring-no-properties
(1+ here) (1- there))))来处理字符串文字。
https://stackoverflow.com/questions/15387155
复制相似问题