Skip to content

Commit

Permalink
Update Scheme syntax for reals
Browse files Browse the repository at this point in the history
According to R7RS spec, you can use different mnemonics
for the scientific notation that indicated the precision of the number.
  • Loading branch information
jcubic committed Oct 23, 2021
1 parent 3755120 commit 0523534
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/prism-scheme.js
Expand Up @@ -70,7 +70,7 @@
// non-decimal bases together. This results in a decimal (dec) and combined binary, octal, and hexadecimal (box)
// pattern:
pattern: RegExp(SortedBNF({
'<ureal dec>': /\d+(?:\/\d+)|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/.source,
'<ureal dec>': /\d+(?:\/\d+)|(?:\d+(?:\.\d*)?|\.\d+)(?:[esfdl][+-]?\d+)?/.source,
'<real dec>': /[+-]?<ureal dec>|[+-](?:inf|nan)\.0/.source,
'<imaginary dec>': /[+-](?:<ureal dec>|(?:inf|nan)\.0)?i/.source,
'<complex dec>': /<real dec>(?:@<real dec>|<imaginary dec>)?|<imaginary dec>/.source,
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.

32 changes: 32 additions & 0 deletions tests/languages/scheme/number_feature.test
Expand Up @@ -18,9 +18,23 @@
10+.1i
10+1.i

10.0E2
10.0D2
10.0L2
10.0S2
10.0F2

10.0e2
10.0d2
10.0l2
10.0s2
10.0f2

; not a number but a symbol
(define 1+2 10)

(list 10.0P2 10.0g2 10.0w2)

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

[
Expand Down Expand Up @@ -101,13 +115,31 @@
["number", "10+.1i"],
["number", "10+1.i"],

["number", "10.0E2"],
["number", "10.0D2"],
["number", "10.0L2"],
["number", "10.0S2"],
["number", "10.0F2"],

["number", "10.0e2"],
["number", "10.0d2"],
["number", "10.0l2"],
["number", "10.0s2"],
["number", "10.0f2"],

["comment", "; not a number but a symbol"],

["punctuation", "("],
["keyword", "define"],
" 1+2 ",
["number", "10"],
["punctuation", ")"],

["punctuation", "("],
["builtin", "list"],
" 10.0P2 10.0g2 10.0w2",
["punctuation", ")"]

]

----------------------------------------------------
Expand Down

0 comments on commit 0523534

Please sign in to comment.