Function: tuareg-smie--=-disambiguate
tuareg-smie--=-disambiguate is a natively compiled function defined in
tuareg.el.
Signature
(tuareg-smie--=-disambiguate)
Documentation
Return which kind of "=" we've just found.
Point is not moved and should be right in front of the equality.
Return values can be
"f=" for field definition,
"d=" for a normal definition,
"c=" for a type equality constraint, and
"=…" for an equality test.
Source Code
;; Defined in /nix/store/6mbh851dhnag8f92qfrlh9ckldzwf6c6-emacs-packages-deps/share/emacs/site-lisp/elpa/tuareg-20260626.936/tuareg.el
(defun tuareg-smie--=-disambiguate ()
"Return which kind of \"=\" we've just found.
Point is not moved and should be right in front of the equality.
Return values can be
\"f=\" for field definition,
\"d=\" for a normal definition,
\"c=\" for a type equality constraint, and
\"=…\" for an equality test."
(save-excursion
(let* ((pos (point))
(telltale '("type" "let" "module" "class" "and" "external"
"val" "method" "=" ":="
"if" "then" "else" "->" ";" ))
(nearest (tuareg-smie--search-backward telltale)))
(cond
((and (member nearest '("{" ";"))
(let ((field t))
(while
(let ((x (tuareg-smie--forward-token)))
(and (< (point) pos)
(cond
((zerop (length x)) (setq field nil))
((memq (char-syntax (aref x 0)) '(?w ?_)))
((member x '("." ";")))
(t (setq field nil))))))
field))
"f=")
((progn
(while (and (equal nearest "->")
(save-excursion
(forward-char 2)
(equal (tuareg-smie-backward-token) "t->")))
(setq nearest (tuareg-smie--search-backward telltale)))
nil))
((and (member nearest '("=" ":="))
(member (tuareg-smie--search-backward telltale)
'("type" "module")))
;; Second equality in "type t = M.t = C" or after mod-constraint
"d=")
((not (member nearest '("type" "let" "module" "class" "and"
"external" "val" "method")))
"=…")
((and (member nearest '("type" "module"))
;; Maybe a module's type equality constraint?
(or (member (tuareg-smie--backward-token) '("with" "and"))
;; Or maybe an alias as part of a definition?
(and (equal nearest "type")
(goto-char (1+ pos)) ;"1+" to skip the `=' itself!
(let ((tok (tuareg-smie--search-forward
(cons "=" (mapcar #'car
tuareg-smie-grammar)))))
(equal tok "=")))))
"c=")
(t "d=")))))