Function: tuareg-smie-forward-token
tuareg-smie-forward-token is a natively compiled function defined in
tuareg.el.
Signature
(tuareg-smie-forward-token)
Documentation
Move point to the end of the next token and return its SMIE name.
Source Code
;; Defined in /nix/store/6mbh851dhnag8f92qfrlh9ckldzwf6c6-emacs-packages-deps/share/emacs/site-lisp/elpa/tuareg-20260626.936/tuareg.el
(defun tuareg-smie-forward-token ()
"Move point to the end of the next token and return its SMIE name."
(let ((tok (tuareg-smie--forward-token)))
(cond
((zerop (length tok))
(if (not (looking-at "{<\\|\\[|"))
tok
(goto-char (match-end 0))
(match-string 0)))
((and (equal tok "|") (looking-at-p "\\]")) (forward-char 1) "|]")
((and (equal tok ">") (looking-at-p "}")) (forward-char 1) ">}")
((and (equal tok ".") (memq (char-after) '(?< ?~)))
(forward-char 1) (string ?. (char-before)))
((or (member tok '("let" "=" "->"
"module" "class" "open" "type" "with" "and"
"exception"))
;; https://v2.ocaml.org/manual/expr.html lists
;; the tokens whose precedence is based on their prefix.
(memq (aref tok 0) '(?* ?/ ?% ?+ ?- ?@ ?^ ?= ?< ?> ?| ?& ?$)))
;; When indenting, the movement is mainly backward, so it's OK to make
;; the forward tokenizer a bit slower.
(save-excursion (tuareg-smie-backward-token)))
((and (member tok '("~" "?"))
(looking-at "[[:alpha:]_][[:alnum:]'_]*:"))
(goto-char (match-end 0))
"label:")
((and (looking-at-p ":\\(?:[^:]\\|\\'\\)")
(string-match-p "\\`[[:alpha:]_]" tok)
(save-excursion
(tuareg-smie--backward-token) ;Go back.
(member (tuareg-smie--backward-token)
tuareg-smie--type-label-leader)))
(forward-char 1)
"label:")
((string-match-p "\\`[[:alpha:]_].*\\.\\'" tok)
(forward-char -1) (substring tok 0 -1))
(t tok))))