Skip to content

Commit

Permalink
Add better number matching
Browse files Browse the repository at this point in the history
Resolves #1378
  • Loading branch information
MrEbbinghaus committed Dec 13, 2021
1 parent b8f9e03 commit 085c63b
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions src/calva-fmt/atom-language-clojure/grammars/clojure.cson
Expand Up @@ -107,48 +107,34 @@
'match': '(?<=^|\\s|,|\\(|\\[|\\{)(true|false)(?=(\\s|,|\\)|\\]|\\}|\\^))'
'name': 'constant.language.boolean.clojure'
}
{
'match': '(##(?:Inf|-Inf|NaN))'
'name': 'constant.numeric.symbol.clojure'
}
{
'match': '([-+]?\\d+/\\d+)'
'name': 'constant.numeric.ratio.clojure'
}
{
'match': '([-+]?\\d+[rR]\\w+)'
# Only Radixes between 2 and 36 are allowed
'match': '([-+]?(?:(?:3[0-6])|(?:[12]\\d)|[2-9])[rR][0-9A-Za-z]+N?)'
'name': 'constant.numeric.arbitrary-radix.clojure'
}
{
'match': '([-+]?0[xX][0-9a-fA-F]+N?)'
'name': 'constant.numeric.hexadecimal.clojure'
}
{
'match': '([-+]?0[xX][g-zG-Z]+)'
'name': 'constant.numeric.invalid.clojure'
}
{
'match': '([-+]?\\d+M)'
'name': 'constant.numeric.bigdecimal.clojure'
}
{
'match': '([-+]?0[0-7]+N?)'
'name': 'constant.numeric.octal.clojure'
}
{
'match': '([-+]?0[89]+)'
'name': 'constant.numeric.invalid.clojure'
}
{
'match': '([-+]?\\d+\\.\\d+([eE][+-]?\\d+)?M)'
'name': 'constant.numeric.bigdecimal.clojure'
}
{
'match': '([-+]?\\d+\\.\\d+([eE][+-]?\\d+)?)'
# The decimal separator is optional only when followed by e, E or M!
'match': '([-+]?[0-9]+(?:(\\.|(?=[eEM]))[0-9]*([eE][-+]?[0-9]+)?)M?)'
'name': 'constant.numeric.double.clojure'
}
{
'match': '([-+]?\\d+N)'
'name': 'constant.numeric.bigint.clojure'
}
{
'match': '([-+]?\\d+)'
'match': '([-+]?\\d+N?)'
'name': 'constant.numeric.long.clojure'
}
{ # separating the pattern for reuse
Expand Down

0 comments on commit 085c63b

Please sign in to comment.