From 1e3f542be065f04bf9f9f109e92c08b1370572ad Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Thu, 4 Jun 2020 22:15:55 +0200 Subject: [PATCH] Scheme: Adjusted lookbehind for literals (#2396) --- components/prism-scheme.js | 7 +++++-- components/prism-scheme.min.js | 2 +- tests/languages/scheme/number_feature.test | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/prism-scheme.js b/components/prism-scheme.js index e36aa1ee7f..9c7b60c0fc 100644 --- a/components/prism-scheme.js +++ b/components/prism-scheme.js @@ -48,10 +48,13 @@ Prism.languages.scheme = { // := [+-]? // // := | - 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]|$)/, + 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](?=[()\s]|$)/, lookbehind: true }, - 'boolean': /#[ft](?=[()\s]|$)/, 'operator': { pattern: /(\()(?:[-+*%\/]|[<>]=?|=>?)(?=[()\s]|$)/, lookbehind: true diff --git a/components/prism-scheme.min.js b/components/prism-scheme.min.js index bdd367f019..7176052c9d 100644 --- a/components/prism-scheme.min.js +++ b/components/prism-scheme.min.js @@ -1 +1 @@ -Prism.languages.scheme={comment:/;.*/,string:{pattern:/"(?:[^"\\]|\\.)*"/,greedy:!0},symbol:{pattern:/'[^()#'\s]+/,greedy:!0},character:{pattern:/#\\(?:[ux][a-fA-F\d]+|[-a-zA-Z]+|\S)/,greedy:!0,alias:"string"},"lambda-parameter":[{pattern:/(\(lambda\s+)[^()'\s]+/,lookbehind:!0},{pattern:/(\(lambda\s+\()[^()']+/,lookbehind:!0}],keyword:{pattern:/(\()(?:define(?:-library|-macro|-syntax|-values)?|defmacro|(?:case-)?lambda|let(?:(?:\*|rec)?(?:-values)?|-syntax|rec-syntax)|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-(?:case|rules))(?=[()\s]|$)/,lookbehind:!0},builtin:{pattern:/(\()(?:(?:cons|car|cdr|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?)(?=[()\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:/#[ft](?=[()\s]|$)/,operator:{pattern:/(\()(?:[-+*%\/]|[<>]=?|=>?)(?=[()\s]|$)/,lookbehind:!0},function:{pattern:/(\()[^()'\s]+(?=[()\s]|$)/,lookbehind:!0},punctuation:/[()']/}; \ No newline at end of file +Prism.languages.scheme={comment:/;.*/,string:{pattern:/"(?:[^"\\]|\\.)*"/,greedy:!0},symbol:{pattern:/'[^()#'\s]+/,greedy:!0},character:{pattern:/#\\(?:[ux][a-fA-F\d]+|[-a-zA-Z]+|\S)/,greedy:!0,alias:"string"},"lambda-parameter":[{pattern:/(\(lambda\s+)[^()'\s]+/,lookbehind:!0},{pattern:/(\(lambda\s+\()[^()']+/,lookbehind:!0}],keyword:{pattern:/(\()(?:define(?:-library|-macro|-syntax|-values)?|defmacro|(?:case-)?lambda|let(?:(?:\*|rec)?(?:-values)?|-syntax|rec-syntax)|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-(?:case|rules))(?=[()\s]|$)/,lookbehind:!0},builtin:{pattern:/(\()(?:(?:cons|car|cdr|list|call-with-current-continuation|call\/cc|append|abs|apply|eval)\b|null\?|pair\?|boolean\?|eof-object\?|char\?|procedure\?|number\?|port\?|string\?|vector\?|symbol\?|bytevector\?)(?=[()\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](?=[()\s]|$)/,lookbehind:!0},operator:{pattern:/(\()(?:[-+*%\/]|[<>]=?|=>?)(?=[()\s]|$)/,lookbehind:!0},function:{pattern:/(\()[^()'\s]+(?=[()\s]|$)/,lookbehind:!0},punctuation:/[()']/}; \ No newline at end of file diff --git a/tests/languages/scheme/number_feature.test b/tests/languages/scheme/number_feature.test index 15f1ca20a5..2b51f1b464 100644 --- a/tests/languages/scheme/number_feature.test +++ b/tests/languages/scheme/number_feature.test @@ -1,3 +1,5 @@ +123 + (foo 42 +42 -42) (foo 1e3 +1e3 -1e3) (foo 1e+3 1e-3 3.14159 3.14159e-1) @@ -16,6 +18,8 @@ ---------------------------------------------------- [ + ["number", "123"], + ["punctuation", "("], ["function", "foo"], ["number", "42"],