From 314d6994c000bc0360bdf64693b51f64338cfc4e Mon Sep 17 00:00:00 2001 From: Michael Schmidt Date: Tue, 5 Oct 2021 21:24:28 +0200 Subject: [PATCH] Ocaml: Removed unmatchable punctuation variant (#3120) --- components/prism-ocaml.js | 2 +- components/prism-ocaml.min.js | 2 +- .../languages/ocaml/punctuation_feature.test | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/languages/ocaml/punctuation_feature.test diff --git a/components/prism-ocaml.js b/components/prism-ocaml.js index 8f89471140..d9b06a385d 100644 --- a/components/prism-ocaml.js +++ b/components/prism-ocaml.js @@ -37,5 +37,5 @@ Prism.languages.ocaml = { 'boolean': /\b(?:false|true)\b/, // Custom operators are allowed 'operator': /:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/, - 'punctuation': /[(){}\[\]|.,:;]|\b_\b/ + 'punctuation': /[(){}\[\].,:;]|\b_\b/ }; diff --git a/components/prism-ocaml.min.js b/components/prism-ocaml.min.js index 3145e94d84..1b7d7bccc4 100644 --- a/components/prism-ocaml.min.js +++ b/components/prism-ocaml.min.js @@ -1 +1 @@ -Prism.languages.ocaml={comment:/\(\*[\s\S]*?\*\)/,string:[{pattern:/"(?:\\.|[^\\\r\n"])*"/,greedy:!0},{pattern:/(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,greedy:!0}],number:/\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*(?:\.[\d_]*)?(?:e[+-]?[\d_]+)?)/i,directive:{pattern:/\B#\w+/,alias:"important"},label:{pattern:/\B~\w+/,alias:"function"},"type-variable":{pattern:/\B'\w+/,alias:"function"},variant:{pattern:/`\w+/,alias:"variable"},module:{pattern:/\b[A-Z]\w+/,alias:"variable"},keyword:/\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|nonrec|object|of|open|private|rec|sig|struct|then|to|try|type|val|value|virtual|when|where|while|with)\b/,boolean:/\b(?:false|true)\b/,operator:/:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,punctuation:/[(){}\[\]|.,:;]|\b_\b/}; \ No newline at end of file +Prism.languages.ocaml={comment:/\(\*[\s\S]*?\*\)/,string:[{pattern:/"(?:\\.|[^\\\r\n"])*"/,greedy:!0},{pattern:/(['`])(?:\\(?:\d+|x[\da-f]+|.)|(?!\1)[^\\\r\n])\1/i,greedy:!0}],number:/\b(?:0x[\da-f][\da-f_]+|(?:0[bo])?\d[\d_]*(?:\.[\d_]*)?(?:e[+-]?[\d_]+)?)/i,directive:{pattern:/\B#\w+/,alias:"important"},label:{pattern:/\B~\w+/,alias:"function"},"type-variable":{pattern:/\B'\w+/,alias:"function"},variant:{pattern:/`\w+/,alias:"variable"},module:{pattern:/\b[A-Z]\w+/,alias:"variable"},keyword:/\b(?:as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|match|method|module|mutable|new|nonrec|object|of|open|private|rec|sig|struct|then|to|try|type|val|value|virtual|when|where|while|with)\b/,boolean:/\b(?:false|true)\b/,operator:/:=|[=<>@^|&+\-*\/$%!?~][!$%&*+\-.\/:<=>?@^|~]*|\b(?:and|asr|land|lor|lsl|lsr|lxor|mod|or)\b/,punctuation:/[(){}\[\].,:;]|\b_\b/}; \ No newline at end of file diff --git a/tests/languages/ocaml/punctuation_feature.test b/tests/languages/ocaml/punctuation_feature.test new file mode 100644 index 0000000000..48b2a53cc0 --- /dev/null +++ b/tests/languages/ocaml/punctuation_feature.test @@ -0,0 +1,21 @@ +( ) { } [ ] +. , : ; +_ + +---------------------------------------------------- + +[ + ["punctuation", "("], + ["punctuation", ")"], + ["punctuation", "{"], + ["punctuation", "}"], + ["punctuation", "["], + ["punctuation", "]"], + + ["punctuation", "."], + ["punctuation", ","], + ["punctuation", ":"], + ["punctuation", ";"], + + ["punctuation", "_"] +]