Skip to content

Commit adcb19c

Browse files
committed
Improve support of numeric literals
* Infinity and NaN constants now supported: 1.0+INF, 1.0+NaN * Binary and hexadecimal numbers are matched correctly
1 parent 3126c16 commit adcb19c

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

grammars/emacs-lisp.cson

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,24 @@ repository:
309309
# Numeric literals
310310
number:
311311
patterns: [{
312+
313+
# #b10010110: Binary notation
314+
name: "constant.numeric.integer.binary.emacs.lisp"
315+
match: "(?<=[\\s()]|^)(#)[Bb][01]+"
316+
captures: 1: name: "punctuation.definition.binary.emacs.lisp"
317+
},{
318+
# 0xFFFF: Hexadecimal notation
319+
name: "constant.numeric.integer.hex.viml"
320+
match: "(?<=[\\s()]|^)(#)[Xx][0-9A-Fa-f]+"
321+
captures: 1: name: "punctuation.definition.hex.emacs.lisp"
322+
},{
323+
# Float
312324
name: "constant.numeric.float.emacs.lisp"
313-
match: "(?<=[\\s()]|^)[-+]?\\d*\\.\\d+(?:[Ee][-+]?\\d+)?(?=[\\s()]|$)"
325+
match: "(?<=[\\s()]|^)[-+]?\\d*\\.\\d+(?:[Ee][-+]?\\d+|[Ee]\\+(?:INF|NaN))?(?=[\\s()]|$)"
314326
},{
327+
# Integer
315328
name: "constant.numeric.integer.emacs.lisp"
316-
match: "(?<=[\\s()]|^)[-+]?\\d+(?:[Ee][-+]?\\d+)?(?=[\\s()]|$)"
329+
match: "(?<=[\\s()]|^)[-+]?\\d+(?:[Ee][-+]?\\d+|[Ee]\\+(?:INF|NaN))?(?=[\\s()]|$)"
317330
}]
318331

319332

0 commit comments

Comments
 (0)