From 72a4cffd2702b347dee420d4977e9dc3aa3c1cd5 Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sat, 11 Apr 2020 14:47:26 +0200 Subject: [PATCH 1/2] Scheme: Added missing special keywords --- components/prism-scheme.js | 2 +- components/prism-scheme.min.js | 2 +- tests/languages/scheme/keyword_feature.test | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/components/prism-scheme.js b/components/prism-scheme.js index ad5d000b9c..2a28ef1485 100644 --- a/components/prism-scheme.js +++ b/components/prism-scheme.js @@ -18,7 +18,7 @@ Prism.languages.scheme = { lookbehind: true }, 'keyword': { - pattern: /(\()(?:define(?:-syntax|-library|-values)?|(?:case-)?lambda|let(?:\*|rec)?(?:-values)?|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-rules)(?=[()\s])/, + pattern: /(\()(?:define(?:-syntax|-library|-values)?|(?:case-)?lambda|let(?:(?:\*|rec)?(?:-values)?|-syntax|rec-syntax)|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-(?:case|rules))(?=[()\s])/, lookbehind: true }, 'builtin': { diff --git a/components/prism-scheme.min.js b/components/prism-scheme.min.js index 4a2d1fa28a..ea34a7ef21 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},keyword:{pattern:/(\()(?:define(?:-syntax|-library|-values)?|(?:case-)?lambda|let(?:\*|rec)?(?:-values)?|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-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:/#[tf]/,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},keyword:{pattern:/(\()(?:define(?:-syntax|-library|-values)?|(?: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:/#[tf]/,operator:{pattern:/(\()(?:[-+*%\/]|[<>]=?|=>?)(?=\s|$)/,lookbehind:!0},function:{pattern:/(\()[^()'\s]+(?=[()\s]|$)/,lookbehind:!0},punctuation:/[()']/}; \ No newline at end of file diff --git a/tests/languages/scheme/keyword_feature.test b/tests/languages/scheme/keyword_feature.test index 1abc8282a7..3cd0637114 100644 --- a/tests/languages/scheme/keyword_feature.test +++ b/tests/languages/scheme/keyword_feature.test @@ -22,6 +22,9 @@ (quasi-quote) (quote) (syntax-rules) +(syntax-case) +(letrec-syntax) +(let-syntax) ---------------------------------------------------- @@ -49,7 +52,10 @@ ["punctuation", "("], ["keyword", "set!"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "quasi-quote"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "quote"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "syntax-rules"], ["punctuation", ")"] + ["punctuation", "("], ["keyword", "syntax-rules"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "syntax-case"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "letrec-syntax"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "let-syntax"], ["punctuation", ")"] ] ---------------------------------------------------- From 1a8d24669e1f165003cf410962de19f773a8bbee Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Thu, 16 Apr 2020 22:56:23 +0200 Subject: [PATCH 2/2] Added `define-macro` and `defmacro` --- components/prism-scheme.js | 2 +- components/prism-scheme.min.js | 2 +- tests/languages/scheme/keyword_feature.test | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/prism-scheme.js b/components/prism-scheme.js index 2a28ef1485..878383f62d 100644 --- a/components/prism-scheme.js +++ b/components/prism-scheme.js @@ -18,7 +18,7 @@ Prism.languages.scheme = { lookbehind: true }, 'keyword': { - pattern: /(\()(?:define(?:-syntax|-library|-values)?|(?:case-)?lambda|let(?:(?:\*|rec)?(?:-values)?|-syntax|rec-syntax)|else|if|cond|begin|delay(?:-force)?|parameterize|guard|set!|(?:quasi-)?quote|syntax-(?:case|rules))(?=[()\s])/, + 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: true }, 'builtin': { diff --git a/components/prism-scheme.min.js b/components/prism-scheme.min.js index ea34a7ef21..b1a8826dd5 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},keyword:{pattern:/(\()(?:define(?:-syntax|-library|-values)?|(?: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:/#[tf]/,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},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:/#[tf]/,operator:{pattern:/(\()(?:[-+*%\/]|[<>]=?|=>?)(?=\s|$)/,lookbehind:!0},function:{pattern:/(\()[^()'\s]+(?=[()\s]|$)/,lookbehind:!0},punctuation:/[()']/}; \ No newline at end of file diff --git a/tests/languages/scheme/keyword_feature.test b/tests/languages/scheme/keyword_feature.test index 3cd0637114..53085d543d 100644 --- a/tests/languages/scheme/keyword_feature.test +++ b/tests/languages/scheme/keyword_feature.test @@ -1,7 +1,9 @@ (define) -(define-syntax) (define-library) +(define-macro) +(define-syntax) (define-values) +(defmacro) (case-lambda) (lambda) (let) @@ -30,9 +32,11 @@ [ ["punctuation", "("], ["keyword", "define"], ["punctuation", ")"], - ["punctuation", "("], ["keyword", "define-syntax"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "define-library"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "define-macro"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "define-syntax"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "define-values"], ["punctuation", ")"], + ["punctuation", "("], ["keyword", "defmacro"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "case-lambda"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "lambda"], ["punctuation", ")"], ["punctuation", "("], ["keyword", "let"], ["punctuation", ")"],