Skip to content

Commit e8811d2

Browse files
Scheme: Added support for rational number literals (#1964)
This adds support for rational numbers like `2/3`.
1 parent 033c5ad commit e8811d2

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

components/prism-scheme.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Prism.languages.scheme = {
1717
lookbehind: true
1818
},
1919
'number': {
20-
pattern: /([\s()])[-+]?\d*\.?\d+(?:\s*[-+]\s*\d*\.?\d+i)?\b/,
20+
pattern: /([\s()])[-+]?(?:\d+\/\d+|\d*\.?\d+(?:\s*[-+]\s*\d*\.?\d+i)?)\b/,
2121
lookbehind: true
2222
},
2323
'boolean': /#[tf]/,

components/prism-scheme.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/scheme/number_feature.test

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(foo 42)
22
(foo 3.14159)
3+
(foo 8/3)
34
(foo 3+4i)
45
(foo 2.5+0.0i)
56
(foo 3+0i)
@@ -9,11 +10,12 @@
910
[
1011
["punctuation", "("], ["function", "foo"], ["number", "42"], ["punctuation", ")"],
1112
["punctuation", "("], ["function", "foo"], ["number", "3.14159"], ["punctuation", ")"],
13+
["punctuation", "("], ["function", "foo"], ["number", "8/3"], ["punctuation", ")"],
1214
["punctuation", "("], ["function", "foo"], ["number", "3+4i"], ["punctuation", ")"],
1315
["punctuation", "("], ["function", "foo"], ["number", "2.5+0.0i"], ["punctuation", ")"],
1416
["punctuation", "("], ["function", "foo"], ["number", "3+0i"], ["punctuation", ")"]
1517
]
1618

1719
----------------------------------------------------
1820

19-
Checks for numbers and complex numbers.
21+
Checks for numbers, rational numbers, and complex numbers.

0 commit comments

Comments
 (0)