diff --git a/components/prism-scheme.js b/components/prism-scheme.js index de05b9660c..eea2ae8a95 100644 --- a/components/prism-scheme.js +++ b/components/prism-scheme.js @@ -1,78 +1,121 @@ -Prism.languages.scheme = { - // this supports "normal" single-line comments: - // ; comment - // and (potentially nested) multiline comments: - // #| comment #| nested |# still comment |# - // (only 1 level of nesting is supported) - 'comment': /;.*|#;\s*\((?:[^()]|\([^()]*\))*\)|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/, - 'string': { - pattern: /"(?:[^"\\]|\\.)*"/, - greedy: true - }, - 'symbol': { - pattern: /'[^()#'\s]+/, - greedy: true - }, - 'character': { - pattern: /#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|\S)/, - greedy: true, - alias: 'string' - }, - 'lambda-parameter': [ - // https://www.cs.cmu.edu/Groups/AI/html/r4rs/r4rs_6.html#SEC30 - { - pattern: /((?:^|[^'`#])\(lambda\s+)(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)/, +(function (Prism) { + Prism.languages.scheme = { + // this supports "normal" single-line comments: + // ; comment + // and (potentially nested) multiline comments: + // #| comment #| nested |# still comment |# + // (only 1 level of nesting is supported) + 'comment': /;.*|#;\s*\((?:[^()]|\([^()]*\))*\)|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/, + 'string': { + pattern: /"(?:[^"\\]|\\.)*"/, + greedy: true + }, + 'symbol': { + pattern: /'[^()#'\s]+/, + greedy: true + }, + 'character': { + pattern: /#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|\S)/, + greedy: true, + alias: 'string' + }, + 'lambda-parameter': [ + // https://www.cs.cmu.edu/Groups/AI/html/r4rs/r4rs_6.html#SEC30 + { + pattern: /((?:^|[^'`#])\(lambda\s+)(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)/, + lookbehind: true + }, + { + pattern: /((?:^|[^'`#])\(lambda\s+\()[^()']+/, + lookbehind: true + } + ], + 'keyword': { + pattern: /((?:^|[^'`#])\()(?:begin|case(?:-lambda)?|cond(?:-expand)?|define(?:-library|-macro|-record-type|-syntax|-values)?|defmacro|delay(?:-force)?|do|else|export|except|guard|if|import|include(?:-ci|-library-declarations)?|lambda|let(?:rec)?(?:-syntax|-values|\*)?|let\*-values|only|parameterize|prefix|(?:quasi-?)?quote|rename|set!|syntax-(?:case|rules)|unless|unquote(?:-splicing)?|when)(?=[()\s]|$)/, + lookbehind: true + }, + 'builtin': { + // all functions of the base library of R7RS plus some of built-ins of R5Rs + pattern: /((?:^|[^'`#])\()(?:abs|and|append|apply|assoc|ass[qv]|binary-port\?|boolean=?\?|bytevector(?:-append|-copy|-copy!|-length|-u8-ref|-u8-set!|\?)?|caar|cadr|call-with-(?:current-continuation|port|values)|call\/cc|car|cdar|cddr|cdr|ceiling|char(?:->integer|-ready\?|\?|<\?|<=\?|=\?|>\?|>=\?)|close-(?:input-port|output-port|port)|complex\?|cons|current-(?:error|input|output)-port|denominator|dynamic-wind|eof-object\??|eq\?|equal\?|eqv\?|error|error-object(?:-irritants|-message|\?)|eval|even\?|exact(?:-integer-sqrt|-integer\?|\?)?|expt|features|file-error\?|floor(?:-quotient|-remainder|\/)?|flush-output-port|for-each|gcd|get-output-(?:bytevector|string)|inexact\??|input-port(?:-open\?|\?)|integer(?:->char|\?)|lcm|length|list(?:->string|->vector|-copy|-ref|-set!|-tail|\?)?|make-(?:bytevector|list|parameter|string|vector)|map|max|member|memq|memv|min|modulo|negative\?|newline|not|null\?|number(?:->string|\?)|numerator|odd\?|open-(?:input|output)-(?:bytevector|string)|or|output-port(?:-open\?|\?)|pair\?|peek-char|peek-u8|port\?|positive\?|procedure\?|quotient|raise|raise-continuable|rational\?|rationalize|read-(?:bytevector|bytevector!|char|error\?|line|string|u8)|real\?|remainder|reverse|round|set-c[ad]r!|square|string(?:->list|->number|->symbol|->utf8|->vector|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?|<\?|<=\?|=\?|>\?|>=\?)?|substring|symbol(?:->string|\?|=\?)|syntax-error|textual-port\?|truncate(?:-quotient|-remainder|\/)?|u8-ready\?|utf8->string|values|vector(?:->list|->string|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?)?|with-exception-handler|write-(?:bytevector|char|string|u8)|zero\?)(?=[()\s]|$)/, + lookbehind: true + }, + 'operator': { + pattern: /((?:^|[^'`#])\()(?:[-+*%/]|[<>]=?|=>?)(?=[()\s]|$)/, lookbehind: true }, - { - pattern: /((?:^|[^'`#])\(lambda\s+\()[^()']+/, + 'number': { + // The number pattern from [the R7RS spec](https://small.r7rs.org/attachment/r7rs.pdf). + // + // := ||| + // := + // := (?:@|)?| + // := [+-](?:|(?:inf|nan)\.0)?i + // := [+-]?|[+-](?:inf|nan)\.0 + // := (?:\/)? + // | + // + // := (?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)? + // := + + // := (?:#[ei])?|(?:#[ei])? + // := #b + // := #o + // := (?:#d)? + // := #x + // := [01] + // := [0-7] + // := \d + // := [0-9a-f] + // + // The problem with this grammar is that the resulting regex is way to complex, so we simplify by grouping all + // non-decimal bases together. This results in a decimal (dec) and combined binary, octal, and hexadecimal (box) + // pattern: + pattern: RegExp(SortedBNF({ + '': /\d+(?:\/\d+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/.source, + '': /[+-]?|[+-](?:inf|nan)\.0/.source, + '': /[+-](?:|(?:inf|nan)\.0)?i/.source, + '': /(?:@|)?|/.source, + '': /(?:#d(?:#[ei])?|#[ei](?:#d)?)?/.source, + + '': /[0-9a-f]+(?:\/[0-9a-f]+)?/.source, + '': /[+-]?|[+-](?:inf|nan)\.0/.source, + '': /[+-](?:|(?:inf|nan)\.0)?i/.source, + '': /(?:@|)?|/.source, + '': /#[box](?:#[ei])?|(?:#[ei])?#[box]/.source, + + '': /(^|[\s()])(?:|)(?=[()\s]|$)/.source, + }), 'i'), lookbehind: true + }, + 'boolean': { + pattern: /(^|[\s()])#(?:[ft]|false|true)(?=[()\s]|$)/, + lookbehind: true + }, + 'function': { + pattern: /((?:^|[^'`#])\()(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\s]|$)/, + lookbehind: true + }, + 'identifier': { + pattern: /(^|[\s()])\|(?:[^\\|]|\\.)*\|(?=[()\s]|$)/, + lookbehind: true, + greedy: true + }, + 'punctuation': /[()']/ + }; + + /** + * Given a topologically sorted BNF grammar, this will return the RegExp source of last rule of the grammar. + * + * @param {Record} grammar + * @returns {string} + */ + function SortedBNF(grammar) { + for (var key in grammar) { + grammar[key] = grammar[key].replace(/<[\w\s]+>/g, function (key) { + return '(?:' + grammar[key].trim() + ')'; + }); } - ], - 'keyword': { - pattern: /((?:^|[^'`#])\()(?:begin|case(?:-lambda)?|cond(?:-expand)?|define(?:-library|-macro|-record-type|-syntax|-values)?|defmacro|delay(?:-force)?|do|else|export|except|guard|if|import|include(?:-ci|-library-declarations)?|lambda|let(?:rec)?(?:-syntax|-values|\*)?|let\*-values|only|parameterize|prefix|(?:quasi-?)?quote|rename|set!|syntax-(?:case|rules)|unless|unquote(?:-splicing)?|when)(?=[()\s]|$)/, - lookbehind: true - }, - 'builtin': { - // all functions of the base library of R7RS plus some of built-ins of R5Rs - pattern: /((?:^|[^'`#])\()(?:abs|and|append|apply|assoc|ass[qv]|binary-port\?|boolean=?\?|bytevector(?:-append|-copy|-copy!|-length|-u8-ref|-u8-set!|\?)?|caar|cadr|call-with-(?:current-continuation|port|values)|call\/cc|car|cdar|cddr|cdr|ceiling|char(?:->integer|-ready\?|\?|<\?|<=\?|=\?|>\?|>=\?)|close-(?:input-port|output-port|port)|complex\?|cons|current-(?:error|input|output)-port|denominator|dynamic-wind|eof-object\??|eq\?|equal\?|eqv\?|error|error-object(?:-irritants|-message|\?)|eval|even\?|exact(?:-integer-sqrt|-integer\?|\?)?|expt|features|file-error\?|floor(?:-quotient|-remainder|\/)?|flush-output-port|for-each|gcd|get-output-(?:bytevector|string)|inexact\??|input-port(?:-open\?|\?)|integer(?:->char|\?)|lcm|length|list(?:->string|->vector|-copy|-ref|-set!|-tail|\?)?|make-(?:bytevector|list|parameter|string|vector)|map|max|member|memq|memv|min|modulo|negative\?|newline|not|null\?|number(?:->string|\?)|numerator|odd\?|open-(?:input|output)-(?:bytevector|string)|or|output-port(?:-open\?|\?)|pair\?|peek-char|peek-u8|port\?|positive\?|procedure\?|quotient|raise|raise-continuable|rational\?|rationalize|read-(?:bytevector|bytevector!|char|error\?|line|string|u8)|real\?|remainder|reverse|round|set-c[ad]r!|square|string(?:->list|->number|->symbol|->utf8|->vector|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?|<\?|<=\?|=\?|>\?|>=\?)?|substring|symbol(?:->string|\?|=\?)|syntax-error|textual-port\?|truncate(?:-quotient|-remainder|\/)?|u8-ready\?|utf8->string|values|vector(?:->list|->string|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?)?|with-exception-handler|write-(?:bytevector|char|string|u8)|zero\?)(?=[()\s]|$)/, - lookbehind: true - }, - 'operator': { - pattern: /((?:^|[^'`#])\()(?:[-+*%/]|[<>]=?|=>?)(?=[()\s]|$)/, - lookbehind: true - }, - 'number': { - // This pattern (apart from the lookarounds) works like this: - // - // Decimal numbers - // := \d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+ - // := (?:[+-]i)?|i - // := (?:#d(?:#[ei])?|#[ei](?:#d)?)? - // := [+-]? - // - // Binary, octal, and hexadecimal numbers - // := [\da-fA-F]+(?:\/[\da-fA-F]+)? - // := (?:[+-]i)?|i - // := #[box](?:#[ei])?|#[ei](?:#[box])? - // := [+-]? - // - // := | - pattern: /(^|[\s()])(?:(?:#d(?:#[ei])?|#[ei](?:#d)?)?[+-]?(?:(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)(?:[+-](?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)?|(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)|(?:#[box](?:#[ei])?|#[ei](?:#[box])?)[+-]?(?:[\da-fA-F]+(?:\/[\da-fA-F]+)?(?:[+-][\da-fA-F]+(?:\/[\da-fA-F]+)?i)?|[\da-fA-F]+(?:\/[\da-fA-F]+)?i))(?=[()\s]|$)/, - lookbehind: true - }, - 'boolean': { - pattern: /(^|[\s()])#(?:[ft]|false|true)(?=[()\s]|$)/, - lookbehind: true - }, - 'function': { - pattern: /((?:^|[^'`#])\()(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\s]|$)/, - lookbehind: true - }, - 'identifier': { - pattern: /(^|[\s()])\|(?:[^\\|]|\\.)*\|(?=[()\s]|$)/, - lookbehind: true, - greedy: true - }, - 'punctuation': /[()']/ -}; + // return the last item + return grammar[key]; + } + +})(Prism); diff --git a/components/prism-scheme.min.js b/components/prism-scheme.min.js index eab22d0a88..0e5467f117 100644 --- a/components/prism-scheme.min.js +++ b/components/prism-scheme.min.js @@ -1 +1 @@ -Prism.languages.scheme={comment:/;.*|#;\s*\((?:[^()]|\([^()]*\))*\)|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/,string:{pattern:/"(?:[^"\\]|\\.)*"/,greedy:!0},symbol:{pattern:/'[^()#'\s]+/,greedy:!0},character:{pattern:/#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|\S)/,greedy:!0,alias:"string"},"lambda-parameter":[{pattern:/((?:^|[^'`#])\(lambda\s+)(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)/,lookbehind:!0},{pattern:/((?:^|[^'`#])\(lambda\s+\()[^()']+/,lookbehind:!0}],keyword:{pattern:/((?:^|[^'`#])\()(?:begin|case(?:-lambda)?|cond(?:-expand)?|define(?:-library|-macro|-record-type|-syntax|-values)?|defmacro|delay(?:-force)?|do|else|export|except|guard|if|import|include(?:-ci|-library-declarations)?|lambda|let(?:rec)?(?:-syntax|-values|\*)?|let\*-values|only|parameterize|prefix|(?:quasi-?)?quote|rename|set!|syntax-(?:case|rules)|unless|unquote(?:-splicing)?|when)(?=[()\s]|$)/,lookbehind:!0},builtin:{pattern:/((?:^|[^'`#])\()(?:abs|and|append|apply|assoc|ass[qv]|binary-port\?|boolean=?\?|bytevector(?:-append|-copy|-copy!|-length|-u8-ref|-u8-set!|\?)?|caar|cadr|call-with-(?:current-continuation|port|values)|call\/cc|car|cdar|cddr|cdr|ceiling|char(?:->integer|-ready\?|\?|<\?|<=\?|=\?|>\?|>=\?)|close-(?:input-port|output-port|port)|complex\?|cons|current-(?:error|input|output)-port|denominator|dynamic-wind|eof-object\??|eq\?|equal\?|eqv\?|error|error-object(?:-irritants|-message|\?)|eval|even\?|exact(?:-integer-sqrt|-integer\?|\?)?|expt|features|file-error\?|floor(?:-quotient|-remainder|\/)?|flush-output-port|for-each|gcd|get-output-(?:bytevector|string)|inexact\??|input-port(?:-open\?|\?)|integer(?:->char|\?)|lcm|length|list(?:->string|->vector|-copy|-ref|-set!|-tail|\?)?|make-(?:bytevector|list|parameter|string|vector)|map|max|member|memq|memv|min|modulo|negative\?|newline|not|null\?|number(?:->string|\?)|numerator|odd\?|open-(?:input|output)-(?:bytevector|string)|or|output-port(?:-open\?|\?)|pair\?|peek-char|peek-u8|port\?|positive\?|procedure\?|quotient|raise|raise-continuable|rational\?|rationalize|read-(?:bytevector|bytevector!|char|error\?|line|string|u8)|real\?|remainder|reverse|round|set-c[ad]r!|square|string(?:->list|->number|->symbol|->utf8|->vector|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?|<\?|<=\?|=\?|>\?|>=\?)?|substring|symbol(?:->string|\?|=\?)|syntax-error|textual-port\?|truncate(?:-quotient|-remainder|\/)?|u8-ready\?|utf8->string|values|vector(?:->list|->string|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?)?|with-exception-handler|write-(?:bytevector|char|string|u8)|zero\?)(?=[()\s]|$)/,lookbehind:!0},operator:{pattern:/((?:^|[^'`#])\()(?:[-+*%/]|[<>]=?|=>?)(?=[()\s]|$)/,lookbehind:!0},number:{pattern:/(^|[\s()])(?:(?:#d(?:#[ei])?|#[ei](?:#d)?)?[+-]?(?:(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)(?:[+-](?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)?|(?:\d*\.?\d+(?:[eE][+-]?\d+)?|\d+\/\d+)i)|(?:#[box](?:#[ei])?|#[ei](?:#[box])?)[+-]?(?:[\da-fA-F]+(?:\/[\da-fA-F]+)?(?:[+-][\da-fA-F]+(?:\/[\da-fA-F]+)?i)?|[\da-fA-F]+(?:\/[\da-fA-F]+)?i))(?=[()\s]|$)/,lookbehind:!0},boolean:{pattern:/(^|[\s()])#(?:[ft]|false|true)(?=[()\s]|$)/,lookbehind:!0},function:{pattern:/((?:^|[^'`#])\()(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\s]|$)/,lookbehind:!0},identifier:{pattern:/(^|[\s()])\|(?:[^\\|]|\\.)*\|(?=[()\s]|$)/,lookbehind:!0,greedy:!0},punctuation:/[()']/}; \ No newline at end of file +Prism.languages.scheme={comment:/;.*|#;\s*\((?:[^()]|\([^()]*\))*\)|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/,string:{pattern:/"(?:[^"\\]|\\.)*"/,greedy:!0},symbol:{pattern:/'[^()#'\s]+/,greedy:!0},character:{pattern:/#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|\S)/,greedy:!0,alias:"string"},"lambda-parameter":[{pattern:/((?:^|[^'`#])\(lambda\s+)(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)/,lookbehind:!0},{pattern:/((?:^|[^'`#])\(lambda\s+\()[^()']+/,lookbehind:!0}],keyword:{pattern:/((?:^|[^'`#])\()(?:begin|case(?:-lambda)?|cond(?:-expand)?|define(?:-library|-macro|-record-type|-syntax|-values)?|defmacro|delay(?:-force)?|do|else|export|except|guard|if|import|include(?:-ci|-library-declarations)?|lambda|let(?:rec)?(?:-syntax|-values|\*)?|let\*-values|only|parameterize|prefix|(?:quasi-?)?quote|rename|set!|syntax-(?:case|rules)|unless|unquote(?:-splicing)?|when)(?=[()\s]|$)/,lookbehind:!0},builtin:{pattern:/((?:^|[^'`#])\()(?:abs|and|append|apply|assoc|ass[qv]|binary-port\?|boolean=?\?|bytevector(?:-append|-copy|-copy!|-length|-u8-ref|-u8-set!|\?)?|caar|cadr|call-with-(?:current-continuation|port|values)|call\/cc|car|cdar|cddr|cdr|ceiling|char(?:->integer|-ready\?|\?|<\?|<=\?|=\?|>\?|>=\?)|close-(?:input-port|output-port|port)|complex\?|cons|current-(?:error|input|output)-port|denominator|dynamic-wind|eof-object\??|eq\?|equal\?|eqv\?|error|error-object(?:-irritants|-message|\?)|eval|even\?|exact(?:-integer-sqrt|-integer\?|\?)?|expt|features|file-error\?|floor(?:-quotient|-remainder|\/)?|flush-output-port|for-each|gcd|get-output-(?:bytevector|string)|inexact\??|input-port(?:-open\?|\?)|integer(?:->char|\?)|lcm|length|list(?:->string|->vector|-copy|-ref|-set!|-tail|\?)?|make-(?:bytevector|list|parameter|string|vector)|map|max|member|memq|memv|min|modulo|negative\?|newline|not|null\?|number(?:->string|\?)|numerator|odd\?|open-(?:input|output)-(?:bytevector|string)|or|output-port(?:-open\?|\?)|pair\?|peek-char|peek-u8|port\?|positive\?|procedure\?|quotient|raise|raise-continuable|rational\?|rationalize|read-(?:bytevector|bytevector!|char|error\?|line|string|u8)|real\?|remainder|reverse|round|set-c[ad]r!|square|string(?:->list|->number|->symbol|->utf8|->vector|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?|<\?|<=\?|=\?|>\?|>=\?)?|substring|symbol(?:->string|\?|=\?)|syntax-error|textual-port\?|truncate(?:-quotient|-remainder|\/)?|u8-ready\?|utf8->string|values|vector(?:->list|->string|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?)?|with-exception-handler|write-(?:bytevector|char|string|u8)|zero\?)(?=[()\s]|$)/,lookbehind:!0},operator:{pattern:/((?:^|[^'`#])\()(?:[-+*%/]|[<>]=?|=>?)(?=[()\s]|$)/,lookbehind:!0},number:{pattern:RegExp(function(r){for(var e in r)r[e]=r[e].replace(/<[\w\s]+>/g,function(e){return"(?:"+r[e].trim()+")"});return r[e]}({"":"\\d+(?:/\\d+)?|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:e[+-]?\\d+)?","":"[+-]?|[+-](?:inf|nan)\\.0","":"[+-](?:|(?:inf|nan)\\.0)?i","":"(?:@|)?|","":"(?:#d(?:#[ei])?|#[ei](?:#d)?)?","":"[0-9a-f]+(?:/[0-9a-f]+)?","":"[+-]?|[+-](?:inf|nan)\\.0","":"[+-](?:|(?:inf|nan)\\.0)?i","":"(?:@|)?|","":"#[box](?:#[ei])?|(?:#[ei])?#[box]","":"(^|[\\s()])(?:|)(?=[()\\s]|$)"}),"i"),lookbehind:!0},boolean:{pattern:/(^|[\s()])#(?:[ft]|false|true)(?=[()\s]|$)/,lookbehind:!0},function:{pattern:/((?:^|[^'`#])\()(?:[^|()'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\s]|$)/,lookbehind:!0},identifier:{pattern:/(^|[\s()])\|(?:[^\\|]|\\.)*\|(?=[()\s]|$)/,lookbehind:!0,greedy:!0},punctuation:/[()']/}; \ No newline at end of file diff --git a/tests/languages/racket/number_feature.test b/tests/languages/racket/number_feature.test index 9a517e1a02..01b699fbca 100644 --- a/tests/languages/racket/number_feature.test +++ b/tests/languages/racket/number_feature.test @@ -1,15 +1,21 @@ +123 + (foo 42 +42 -42) (foo 1e3 +1e3 -1e3) (foo 1e+3 1e-3 3.14159 3.14159e-1) (foo 8/3) (foo 3+4i 2.5+0.0i 2.5+0.0i -2.5e4+0.0e4i 3+0i -2e-5i) -(list 10i +10i -10i 10.10i 10+10i 10.10+10.10i 10-10i 10e+10i 10+10e+10i) +(list +10i -10i 10+10i 10.10+10.10i 10-10i 10+10e+10i) (list #d123 #e#d123e-4 #d#i12 #i-1.234i) (list #xBAD #b1110011 #o777) (list #i#x10 #i#x10+10i #b10+10i) +10+i +10+.1i +10+1.i + ; not a number but a symbol (define 1+2 10) @@ -19,6 +25,8 @@ ---------------------------------------------------- [ + ["number", "123"], + ["punctuation", "("], ["function", "foo"], ["number", "42"], @@ -58,14 +66,11 @@ ["punctuation", "("], ["builtin", "list"], - ["number", "10i"], ["number", "+10i"], ["number", "-10i"], - ["number", "10.10i"], ["number", "10+10i"], ["number", "10.10+10.10i"], ["number", "10-10i"], - ["number", "10e+10i"], ["number", "10+10e+10i"], ["punctuation", ")"], @@ -91,8 +96,16 @@ ["number", "#b10+10i"], ["punctuation", ")"], + ["number", "10+i"], + ["number", "10+.1i"], + ["number", "10+1.i"], + ["comment", "; not a number but a symbol"], - ["punctuation", "("], ["keyword", "define"], " 1+2 ", ["number", "10"], ["punctuation", ")"], + ["punctuation", "("], + ["keyword", "define"], + " 1+2 ", + ["number", "10"], + ["punctuation", ")"], ["punctuation", "["], ["function", "foo"], diff --git a/tests/languages/scheme/number_feature.test b/tests/languages/scheme/number_feature.test index 2b51f1b464..2b00dc8492 100644 --- a/tests/languages/scheme/number_feature.test +++ b/tests/languages/scheme/number_feature.test @@ -5,13 +5,17 @@ (foo 1e+3 1e-3 3.14159 3.14159e-1) (foo 8/3) (foo 3+4i 2.5+0.0i 2.5+0.0i -2.5e4+0.0e4i 3+0i -2e-5i) -(list 10i +10i -10i 10.10i 10+10i 10.10+10.10i 10-10i 10e+10i 10+10e+10i) +(list +10i -10i 10+10i 10.10+10.10i 10-10i 10+10e+10i) (list #d123 #e#d123e-4 #d#i12 #i-1.234i) (list #xBAD #b1110011 #o777) (list #i#x10 #i#x10+10i #b10+10i) +10+i +10+.1i +10+1.i + ; not a number but a symbol (define 1+2 10) @@ -59,14 +63,11 @@ ["punctuation", "("], ["builtin", "list"], - ["number", "10i"], ["number", "+10i"], ["number", "-10i"], - ["number", "10.10i"], ["number", "10+10i"], ["number", "10.10+10.10i"], ["number", "10-10i"], - ["number", "10e+10i"], ["number", "10+10e+10i"], ["punctuation", ")"], @@ -92,8 +93,16 @@ ["number", "#b10+10i"], ["punctuation", ")"], + ["number", "10+i"], + ["number", "10+.1i"], + ["number", "10+1.i"], + ["comment", "; not a number but a symbol"], - ["punctuation", "("], ["keyword", "define"], " 1+2 ", ["number", "10"], ["punctuation", ")"] + ["punctuation", "("], + ["keyword", "define"], + " 1+2 ", + ["number", "10"], + ["punctuation", ")"] ] ----------------------------------------------------