Skip to content

Commit

Permalink
[dart-mode] add numeric literal highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
gos-k committed Mar 3, 2020
1 parent 1112ec0 commit 5e10e90
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modes/dart-mode/dart-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ see : https://dart.dev/guides/language/language-tour
(defvar *dart-conditional-expressions* '("?" ":" "??" "?."))
(defvar *dart-cascade-notation* '(".."))

;; numeric literal
(defvar *dart-exponent-literal* "(e|E)(\\+|\\-)?[0-9]+")
(defvar *dart-number-literal* (format nil "([0-9]+(\\.[0-9]+)?(~A)?)|(\\.[0-9]+(~A)?)" *dart-exponent-literal* *dart-exponent-literal*))
(defvar *dart-hex-number-literal* "(0x[a-fA-F0-9]+)|(0X[a-fA-F0-9]+)")
(defvar *dart-numeric-literal* (format nil "(~A)|(~A)" *dart-hex-number-literal* *dart-number-literal*))

(defun tokens (boundary strings)
(let ((alternation
`(:alternation ,@(sort (copy-list strings) #'> :key #'length))))
Expand All @@ -67,6 +73,8 @@ see : https://dart.dev/guides/language/language-tour
:name 'syntax-keyword-attribute)
(make-tm-match (tokens :word-boundary *dart-constants*)
:name 'syntax-constant-attribute)
(make-tm-match *dart-numeric-literal*
:name 'syntax-constant-attribute)
(make-tm-match (tokens :word-boundary *dart-builtin-types*)
:name 'syntax-type-attribute)
(make-tm-match (tokens nil (append *dart-arithmetic-operators*
Expand Down

0 comments on commit 5e10e90

Please sign in to comment.