首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用elisp中的语法表信息进行标记化

使用elisp中的语法表信息进行标记化
EN

Stack Overflow用户
提问于 2013-03-13 21:46:45
回答 1查看 191关注 0票数 1

我想使用elisp来标记化以下内容:

代码语言:javascript
复制
variable := "The symbol \" delimits strings"; (* Comments go here *)

作为:

代码语言:javascript
复制
<variable> <:=> <The symbol \" delimits strings> <;>

基于来自缓冲区的syntax-table的信息。

我已经正确地设置了symbol-table,并且目前正在使用以下函数,除了字符串常量(如果point不在标识符或正则表达式中的某个运算符上,则返回token或nil ),该函数运行正常。

代码语言:javascript
复制
(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新手,所以任何指针都是非常感谢的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-13 23:20:05

我不认为您的skip-syntax-forward使用字符串是正确的。我认为您需要添加一个cond子句,如下所示:

代码语言:javascript
复制
((looking-at "\"")
 (let* ((here (point)) (there (scan-sexps here 1)))
   (goto-char there)
   (buffer-substring-no-properties
    (1+ here) (1- there))))

来处理字符串文字。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15387155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档