[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/smalltalk-mode 01b774f: * smalltalk-mode.el (smalltalk-
From: |
Stefan Monnier |
Subject: |
[elpa] externals/smalltalk-mode 01b774f: * smalltalk-mode.el (smalltalk--smie-number-re): New var |
Date: |
Tue, 16 Apr 2019 23:03:29 -0400 (EDT) |
branch: externals/smalltalk-mode
commit 01b774fd6d408809a4a79a85e18fbbdec074585d
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* smalltalk-mode.el (smalltalk--smie-number-re): New var
(smalltalk--smie-forward-token): Use it.
(smalltalk--smie-backward-token): Try and handle at least
negative integers.
(smalltalk--smie-exp-p): Adjust for new `lit-number` token.
---
smalltalk-mode.el | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/smalltalk-mode.el b/smalltalk-mode.el
index ec0609f..dbe2899 100644
--- a/smalltalk-mode.el
+++ b/smalltalk-mode.el
@@ -327,8 +327,11 @@ The SMIE support is currently experimental
work-in-progress.")
"\\|\\(?:\\." smalltalk-name-regexp "\\)*"
"\\)\\)\\)"))
+(defconst smalltalk--smie-number-re
+ "\\(?:[0-9]+r\\)?-?[0-9][0-9.]*\\(?:[deqs]-?[0-9]+\\)?")
+
(defun smalltalk--smie-|-kind ()
- ;; FIXME: Probably too naive a heuristic.
+ ;; FIXME: `|' can also be a binary-selector!
(if (save-excursion
(forward-comment (- (point)))
(memq (char-syntax (preceding-char)) '(?w ?_)))
@@ -340,7 +343,10 @@ The SMIE support is currently experimental
work-in-progress.")
(cond
((looking-at "\\s(\\|\\s)") "")
;; Symbol literals are easy to lex when going forward.
- ((looking-at smalltalk--smie-symbol-re) "lit-symbol")
+ ((looking-at smalltalk--smie-symbol-re)
+ (goto-char (match-end 0)) "lit-symbol")
+ ((looking-at smalltalk--smie-number-re)
+ (goto-char (match-end 0)) "lit-number")
((looking-at smalltalk--smie-id-re)
(goto-char (match-end 0))
(cond
@@ -376,11 +382,14 @@ The SMIE support is currently experimental
work-in-progress.")
((memq (char-syntax (preceding-char)) '(?w ?_))
(skip-chars-backward "[:alnum:]_.")
;; (skip-chars-forward "0-9_.") ;Maybe we skipped too much!
- (if (eq (char-before) ?#)
- (progn
- (forward-char -1)
- "lit-symbol")
- "id"))
+ (cond
+ ((eq (char-before) ?#)
+ (forward-char -1)
+ "lit-symbol")
+ ((eq (char-before) ?-)
+ (forward-char -1)
+ "lit-number")
+ (t "id")))
((looking-back smalltalk-binsel (- (point) 2) t)
(goto-char (match-beginning 0))
(if (eq (char-before) ?#)
@@ -402,7 +411,7 @@ The SMIE support is currently experimental
work-in-progress.")
(pcase (smalltalk--smie-backward-token)
((or `"bin-sel" `"kw-sel" ":=" `"." `"^" `"!" "|")
t)
- ((or `"|-open" `";" `"lit-symbol") nil)
+ ((or `"|-open" `";" `"lit-symbol" "lit-number") nil)
;;`""' means we bumped into a paren or a string.
(`"" (looking-back "\\s(" (1- (point))))
(_
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/smalltalk-mode 01b774f: * smalltalk-mode.el (smalltalk--smie-number-re): New var,
Stefan Monnier <=