branch: elpa/scala-mode commit 64c496a7152a088850baa0ff1acd1d0d3a7b2e6a Author: Heikki Vesalainen <heikkivesalai...@yahoo.com> Commit: Heikki Vesalainen <heikkivesalai...@yahoo.com>
Fixed #4: numbers in ids --- scala-mode-fontlock.el | 20 ++++++++++++++++++-- scala-mode-syntax.el | 12 ++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/scala-mode-fontlock.el b/scala-mode-fontlock.el index ddf6849..3e3bbfd 100644 --- a/scala-mode-fontlock.el +++ b/scala-mode-fontlock.el @@ -295,6 +295,22 @@ Does not continue past limit. (let ((state (syntax-ppss (match-beginning 0)))) (goto-char (match-end 0)) (= (nth 3 state) ?\")))) + +(defun scala-font-lock:mark-numberLiteral (re limit) + (when (re-search-forward re limit t) + (goto-char (match-beginning 0)) + (when (or (bolp) (string-match-p scala-syntax:number-safe-start-re (string (char-before)))) + (goto-char (match-end 0))))) + +(defun scala-font-lock:mark-floatingPointLiteral (limit) + (scala-font-lock:mark-numberLiteral + scala-syntax:floatingPointLiteral-re + limit)) + +(defun scala-font-lock:mark-integerLiteral (limit) + (scala-font-lock:mark-numberLiteral + scala-syntax:integerLiteral-re + limit)) (defun scala-font-lock:keywords () ;; chars, string, comments are handled acording to syntax and @@ -424,7 +440,7 @@ Does not continue past limit. (1 font-lock-keyword-face) (2 font-lock-string-face)) ;; number literals (have to be here so that other rules take precedence) - (,scala-syntax:floatingPointLiteral-re . font-lock-constant-face) - (,scala-syntax:integerLiteral-re . font-lock-constant-face) + (scala-font-lock:mark-floatingPointLiteral . font-lock-constant-face) + (scala-font-lock:mark-integerLiteral . font-lock-constant-face) )) diff --git a/scala-mode-syntax.el b/scala-mode-syntax.el index 575b457..1e83cd6 100644 --- a/scala-mode-syntax.el +++ b/scala-mode-syntax.el @@ -51,10 +51,11 @@ (defconst scala-syntax:hexNumeral-re (concat "0x[" scala-syntax:hexDigit-group "]+")) (defconst scala-syntax:octalNumeral-re (concat "0[" scala-syntax:octalDigit-group "]+")) (defconst scala-syntax:integerLiteral-re (concat "-?" ;; added from definition of literal - "\\(" scala-syntax:decimalNumeral-re - "\\|" scala-syntax:hexNumeral-re - "\\|" scala-syntax:octalNumeral-re - "\\)[Ll]?")) + "\\(" scala-syntax:decimalNumeral-re + "\\|" scala-syntax:hexNumeral-re + "\\|" scala-syntax:octalNumeral-re + "\\)[Ll]?")) + ;; Floating Point Literal (Chapter 1.3.2) (defconst scala-syntax:exponentPart-re (concat "\\([eE][+-]?[" scala-syntax:digit-group "]+\\)")) @@ -68,6 +69,9 @@ "\\|" "[" scala-syntax:digit-group "]+" scala-syntax:exponentPart-re "\\|" "[" scala-syntax:digit-group "]+" scala-syntax:floatType-re "\\)")) +(defconst scala-syntax:number-safe-start-re + (concat "[^_" scala-syntax:letter-group "]")) + ;; Boolean Literals (Chapter 1.3.3) (defconst scala-syntax:booleanLiteral-re "true|false")