Function: meson-smie-forward-token
meson-smie-forward-token is a natively compiled function defined in
meson-mode.el.
Signature
(meson-smie-forward-token)
Documentation
Move forward by one lexer token.
Source Code
;; Defined in /nix/store/57kn62wrv0z1jads9j9blmagdm8rh132-emacs-packages-deps/share/emacs/site-lisp/elpa/meson-mode-20240601.1647/meson-mode.el
(defun meson-smie-forward-token ()
"Move forward by one lexer token."
(let ((token 'unknown))
(while (eq token 'unknown)
(let ((ppss (syntax-ppss)))
;; When inside or at start of a comment, goto end of line so
;; that we can still return "eol" token there.
(when (or (nth 4 ppss)
(and (not (nth 3 ppss)) ; not inside string
(looking-at-p "#")))
(end-of-line)
(setq ppss (syntax-ppss))) ; update ppss after move
;; Determine token but do not move behind it
(setq token
(cond
;; Let syntactic parser handle parentheses (even inside
;; strings - this ensures that parentheses are NOT
;; indented inside strings according to meson
;; indentation rules)
((looking-at (rx (or (syntax open-parenthesis)
(syntax close-parenthesis))))
"")
;; After handling parentheses (inside strings), we can
;; handle strings
((or (when (nth 3 ppss) ; If inside string
(goto-char (nth 8 ppss)) ; goto beginning
nil)
(looking-at meson-string-regexp)) ; Match the whole string
"string")
((looking-at meson-keywords-regexp) (match-string-no-properties 0))
((cl-some (lambda (spec) (when (looking-at (cdr spec)) (car spec)))
meson-token-spec))
((looking-at meson-literate-tokens-regexp)
(match-string-no-properties 0))))
;; Remember token end (except for parentheses)
(let ((after-token (when (< 0 (length token)) (match-end 0))))
;; Skip certain tokens
(when (or (equal token "ignore")
(equal token "eol_cont")
(and (equal token "eol") ; Skip EOL when:
(or (> (nth 0 ppss) 0) ; - inside parentheses
(and (looking-back ; - after operator but not inside comments
meson-literate-tokens-regexp
(- (point) meson-literate-tokens-max-length))
(not (nth 4 ppss)))
(meson--comment-bolp ppss)))) ; - at empty line
(setq token 'unknown))
(when after-token
(goto-char after-token)))))
token))