Skip to content

Commit

Permalink
Scheme: Added support for rational number literals (#1964)
Browse files Browse the repository at this point in the history
This adds support for rational numbers like `2/3`.
  • Loading branch information
RunDevelopment authored Jul 20, 2019
1 parent 033c5ad commit e8811d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/prism-scheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Prism.languages.scheme = {
lookbehind: true
},
'number': {
pattern: /([\s()])[-+]?\d*\.?\d+(?:\s*[-+]\s*\d*\.?\d+i)?\b/,
pattern: /([\s()])[-+]?(?:\d+\/\d+|\d*\.?\d+(?:\s*[-+]\s*\d*\.?\d+i)?)\b/,
lookbehind: true
},
'boolean': /#[tf]/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-scheme.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/languages/scheme/number_feature.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(foo 42)
(foo 3.14159)
(foo 8/3)
(foo 3+4i)
(foo 2.5+0.0i)
(foo 3+0i)
Expand All @@ -9,11 +10,12 @@
[
["punctuation", "("], ["function", "foo"], ["number", "42"], ["punctuation", ")"],
["punctuation", "("], ["function", "foo"], ["number", "3.14159"], ["punctuation", ")"],
["punctuation", "("], ["function", "foo"], ["number", "8/3"], ["punctuation", ")"],
["punctuation", "("], ["function", "foo"], ["number", "3+4i"], ["punctuation", ")"],
["punctuation", "("], ["function", "foo"], ["number", "2.5+0.0i"], ["punctuation", ")"],
["punctuation", "("], ["function", "foo"], ["number", "3+0i"], ["punctuation", ")"]
]

----------------------------------------------------

Checks for numbers and complex numbers.
Checks for numbers, rational numbers, and complex numbers.

0 comments on commit e8811d2

Please sign in to comment.