From 7d740c4508ff00ece22405a7b89ce7df5b9d51ba Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Fri, 10 Dec 2021 14:38:41 +0100 Subject: [PATCH] Scheme: Use standard `char` token (#3254) --- components/prism-scheme.js | 5 +- components/prism-scheme.min.js | 2 +- tests/languages/racket/char_feature.test | 41 ++++++++++++++ tests/languages/racket/character_feature.test | 51 ------------------ tests/languages/scheme/char_feature.test | 43 +++++++++++++++ tests/languages/scheme/character_feature.test | 53 ------------------- 6 files changed, 87 insertions(+), 108 deletions(-) create mode 100644 tests/languages/racket/char_feature.test delete mode 100644 tests/languages/racket/character_feature.test create mode 100644 tests/languages/scheme/char_feature.test delete mode 100644 tests/languages/scheme/character_feature.test diff --git a/components/prism-scheme.js b/components/prism-scheme.js index 681da1b84c..2409f22ff7 100644 --- a/components/prism-scheme.js +++ b/components/prism-scheme.js @@ -14,10 +14,9 @@ pattern: /'[^()\[\]#'\s]+/, greedy: true }, - 'character': { + 'char': { pattern: /#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|[\uD800-\uDBFF][\uDC00-\uDFFF]|\S)/, - greedy: true, - alias: 'string' + greedy: true }, 'lambda-parameter': [ // https://www.cs.cmu.edu/Groups/AI/html/r4rs/r4rs_6.html#SEC30 diff --git a/components/prism-scheme.min.js b/components/prism-scheme.min.js index 0da52e71a7..980d04e6ad 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|[\uD800-\uDBFF][\uDC00-\uDFFF]|\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|except|export|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+)(?:[esfdl][+-]?\\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 +Prism.languages.scheme={comment:/;.*|#;\s*(?:\((?:[^()]|\([^()]*\))*\)|\[(?:[^\[\]]|\[[^\[\]]*\])*\])|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/,string:{pattern:/"(?:[^"\\]|\\.)*"/,greedy:!0},symbol:{pattern:/'[^()\[\]#'\s]+/,greedy:!0},char:{pattern:/#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|[\uD800-\uDBFF][\uDC00-\uDFFF]|\S)/,greedy:!0},"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|except|export|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+)(?:[esfdl][+-]?\\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/char_feature.test b/tests/languages/racket/char_feature.test new file mode 100644 index 0000000000..1e92a056a5 --- /dev/null +++ b/tests/languages/racket/char_feature.test @@ -0,0 +1,41 @@ +#\a ; lowercase letter +#\A ; uppercase letter +#\( ; left parenthesis +#\space ; the space character +#\newline ; the newline character + +#\c-a ; Control-a +#\meta-b ; Meta-b +#\c-s-m-h-a ; Control-Meta-Super-Hyper-A + +#\; #\' #\" + +#\u0041 +#\x10FFFF +#\λ +#\) + +---------------------------------------------------- + +[ + ["char", "#\\a"], ["comment", "; lowercase letter"], + ["char", "#\\A"], ["comment", "; uppercase letter"], + ["char", "#\\("], ["comment", "; left parenthesis"], + ["char", "#\\space"], ["comment", "; the space character"], + ["char", "#\\newline"], ["comment", "; the newline character"], + + ["char", "#\\c-a"], ["comment", "; Control-a"], + ["char", "#\\meta-b"], ["comment", "; Meta-b"], + ["char", "#\\c-s-m-h-a"], ["comment", "; Control-Meta-Super-Hyper-A"], + + ["char", "#\\;"], ["char", "#\\'"], ["char", "#\\\""], + + ["char", "#\\u0041"], + ["char", "#\\x10FFFF"], + ["char", "#\\λ"], + ["char", "#\\)"] +] + +---------------------------------------------------- + +Checks for character literals. diff --git a/tests/languages/racket/character_feature.test b/tests/languages/racket/character_feature.test deleted file mode 100644 index f95cb705bf..0000000000 --- a/tests/languages/racket/character_feature.test +++ /dev/null @@ -1,51 +0,0 @@ -#\a ; lowercase letter -#\A ; uppercase letter -#\( ; left parenthesis -#\space ; the space character -#\newline ; the newline character - -#\c-a ; Control-a -#\meta-b ; Meta-b -#\c-s-m-h-a ; Control-Meta-Super-Hyper-A - -#\; #\' #\" - -#\u0041 -#\x10FFFF -#\λ -#\) - ----------------------------------------------------- - -[ - ["character", "#\\a"], - ["comment", "; lowercase letter"], - ["character", "#\\A"], - ["comment", "; uppercase letter"], - ["character", "#\\("], - ["comment", "; left parenthesis"], - ["character", "#\\space"], - ["comment", "; the space character"], - ["character", "#\\newline"], - ["comment", "; the newline character"], - - ["character", "#\\c-a"], - ["comment", "; Control-a"], - ["character", "#\\meta-b"], - ["comment", "; Meta-b"], - ["character", "#\\c-s-m-h-a"], - ["comment", "; Control-Meta-Super-Hyper-A"], - - ["character", "#\\;"], - ["character", "#\\'"], - ["character", "#\\\""], - - ["character", "#\\u0041"], - ["character", "#\\x10FFFF"], - ["character", "#\\λ"], - ["character", "#\\)"] -] - ----------------------------------------------------- - -Checks for character literals. diff --git a/tests/languages/scheme/char_feature.test b/tests/languages/scheme/char_feature.test new file mode 100644 index 0000000000..799cf5662c --- /dev/null +++ b/tests/languages/scheme/char_feature.test @@ -0,0 +1,43 @@ +#\a ; lowercase letter +#\A ; uppercase letter +#\( ; left parenthesis +#\space ; the space character +#\newline ; the newline character + +#\c-a ; Control-a +#\meta-b ; Meta-b +#\c-s-m-h-a ; Control-Meta-Super-Hyper-A + +#\; #\' #\" + +#\u0041 +#\x10FFFF +#\λ +#\) +#\💩 + +---------------------------------------------------- + +[ + ["char", "#\\a"], ["comment", "; lowercase letter"], + ["char", "#\\A"], ["comment", "; uppercase letter"], + ["char", "#\\("], ["comment", "; left parenthesis"], + ["char", "#\\space"], ["comment", "; the space character"], + ["char", "#\\newline"], ["comment", "; the newline character"], + + ["char", "#\\c-a"], ["comment", "; Control-a"], + ["char", "#\\meta-b"], ["comment", "; Meta-b"], + ["char", "#\\c-s-m-h-a"], ["comment", "; Control-Meta-Super-Hyper-A"], + + ["char", "#\\;"], ["char", "#\\'"], ["char", "#\\\""], + + ["char", "#\\u0041"], + ["char", "#\\x10FFFF"], + ["char", "#\\λ"], + ["char", "#\\)"], + ["char", "#\\💩"] +] + +---------------------------------------------------- + +Checks for character literals. diff --git a/tests/languages/scheme/character_feature.test b/tests/languages/scheme/character_feature.test deleted file mode 100644 index b699e18993..0000000000 --- a/tests/languages/scheme/character_feature.test +++ /dev/null @@ -1,53 +0,0 @@ -#\a ; lowercase letter -#\A ; uppercase letter -#\( ; left parenthesis -#\space ; the space character -#\newline ; the newline character - -#\c-a ; Control-a -#\meta-b ; Meta-b -#\c-s-m-h-a ; Control-Meta-Super-Hyper-A - -#\; #\' #\" - -#\u0041 -#\x10FFFF -#\λ -#\) -#\💩 - ----------------------------------------------------- - -[ - ["character", "#\\a"], - ["comment", "; lowercase letter"], - ["character", "#\\A"], - ["comment", "; uppercase letter"], - ["character", "#\\("], - ["comment", "; left parenthesis"], - ["character", "#\\space"], - ["comment", "; the space character"], - ["character", "#\\newline"], - ["comment", "; the newline character"], - - ["character", "#\\c-a"], - ["comment", "; Control-a"], - ["character", "#\\meta-b"], - ["comment", "; Meta-b"], - ["character", "#\\c-s-m-h-a"], - ["comment", "; Control-Meta-Super-Hyper-A"], - - ["character", "#\\;"], - ["character", "#\\'"], - ["character", "#\\\""], - - ["character", "#\\u0041"], - ["character", "#\\x10FFFF"], - ["character", "#\\λ"], - ["character", "#\\)"], - ["character", "#\\💩"] -] - ----------------------------------------------------- - -Checks for character literals.