elispを使用して以下をトークン化したいと思います。
variable := "The symbol \" delimits strings"; (* Comments go here *)
なので:
<variable> <:=> <The symbol \" delimits strings> <;>
バッファのからの情報に基づいていますsyntax-table
。
私はsymbol-table
適切に設定し、現在、文字列定数を除いて正しく動作する次の関数を使用しています(ポイントが識別子または正規表現の演算子の1つにない場合は、トークンまたは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の初心者なので、どんなポインタでも大歓迎です。