I managed to write the forward and backward tokenization functions:
(defun factor-smie-token (dir)
(pcase dir
('forward (forward-comment (point-max)))
('backward (forward-comment (- (point)))))
(let ((tok (buffer-substring-no-properties
(point)
(let ((syntax "w_\\\""))
(pcase dir
('forward (skip-syntax-forward syntax))
('backward (skip-syntax-backward syntax)))
(point)))))
;; Normalizes different indent starters.
(cond ((string-match factor-smie-indents-regex tok) ":")
(t tok))))
(defun factor-smie-forward-token ()
(factor-smie-token 'forward))
(defun factor-smie-backward-token ()
(factor-smie-token 'backward))
It works in 99% of the cases. But since almost any character can be
part of a token, it doesn't work perfectly. E.g te]st(ab3 would be a
perfectly valid variable name. I tried changing the syntax to
"w_()\\\"" and that fixes the tokenization but then I lose the useful
automatic indentation smie adds to opening- and closing bracket
characters. E.g I'm happy that smie indents:
[
neat
{
nice
}
(
good
)
]
It's very nice. But the following two lines are not right:
hi[there
two
They should be:
hi[there
two