Squirrel: Use standard `char` token (#3256)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
diff --git a/components/prism-squirrel.js b/components/prism-squirrel.js
index 9e1db54..d208633 100644
--- a/components/prism-squirrel.js
+++ b/components/prism-squirrel.js
@@ -7,18 +7,11 @@ Prism.languages.squirrel = Prism.languages.extend('clike', {
greedy: true
}
],
- 'string': [
- {
- pattern: /(^|[^\\"'@])(?:@"(?:[^"]|"")*"(?!")|"(?:[^\\\r\n"]|\\.)*")/,
- lookbehind: true,
- greedy: true
- },
- {
- pattern: /(^|[^\\"'])'(?:[^\\']|\\(?:[xuU][0-9a-fA-F]{0,8}|[\s\S]))'/,
- lookbehind: true,
- greedy: true
- }
- ],
+ 'string': {
+ pattern: /(^|[^\\"'@])(?:@"(?:[^"]|"")*"(?!")|"(?:[^\\\r\n"]|\\.)*")/,
+ lookbehind: true,
+ greedy: true
+ },
'class-name': {
pattern: /(\b(?:class|enum|extends|instanceof)\s+)\w+(?:\.\w+)*/,
@@ -34,6 +27,14 @@ Prism.languages.squirrel = Prism.languages.extend('clike', {
'punctuation': /[(){}\[\],;.]/
});
+Prism.languages.insertBefore('squirrel', 'string', {
+ 'char': {
+ pattern: /(^|[^\\"'])'(?:[^\\']|\\(?:[xuU][0-9a-fA-F]{0,8}|[\s\S]))'/,
+ lookbehind: true,
+ greedy: true
+ }
+});
+
Prism.languages.insertBefore('squirrel', 'operator', {
'attribute-punctuation': {
pattern: /<\/|\/>/,
diff --git a/components/prism-squirrel.min.js b/components/prism-squirrel.min.js
index 200885b..c45f650 100644
--- a/components/prism-squirrel.min.js
+++ b/components/prism-squirrel.min.js
@@ -1 +1 @@
-Prism.languages.squirrel=Prism.languages.extend("clike",{comment:[Prism.languages.clike.comment[0],{pattern:/(^|[^\\:])(?:\/\/|#).*/,lookbehind:!0,greedy:!0}],string:[{pattern:/(^|[^\\"'@])(?:@"(?:[^"]|"")*"(?!")|"(?:[^\\\r\n"]|\\.)*")/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\"'])'(?:[^\\']|\\(?:[xuU][0-9a-fA-F]{0,8}|[\s\S]))'/,lookbehind:!0,greedy:!0}],"class-name":{pattern:/(\b(?:class|enum|extends|instanceof)\s+)\w+(?:\.\w+)*/,lookbehind:!0,inside:{punctuation:/\./}},keyword:/\b(?:__FILE__|__LINE__|base|break|case|catch|class|clone|const|constructor|continue|default|delete|else|enum|extends|for|foreach|function|if|in|instanceof|local|null|resume|return|static|switch|this|throw|try|typeof|while|yield)\b/,number:/\b(?:0x[0-9a-fA-F]+|\d+(?:\.(?:\d+|[eE][+-]?\d+))?)\b/,operator:/\+\+|--|<=>|<[-<]|>>>?|&&?|\|\|?|[-+*/%!=<>]=?|[~^]|::?/,punctuation:/[(){}\[\],;.]/}),Prism.languages.insertBefore("squirrel","operator",{"attribute-punctuation":{pattern:/<\/|\/>/,alias:"important"},lambda:{pattern:/@(?=\()/,alias:"operator"}});
\ No newline at end of file
+Prism.languages.squirrel=Prism.languages.extend("clike",{comment:[Prism.languages.clike.comment[0],{pattern:/(^|[^\\:])(?:\/\/|#).*/,lookbehind:!0,greedy:!0}],string:{pattern:/(^|[^\\"'@])(?:@"(?:[^"]|"")*"(?!")|"(?:[^\\\r\n"]|\\.)*")/,lookbehind:!0,greedy:!0},"class-name":{pattern:/(\b(?:class|enum|extends|instanceof)\s+)\w+(?:\.\w+)*/,lookbehind:!0,inside:{punctuation:/\./}},keyword:/\b(?:__FILE__|__LINE__|base|break|case|catch|class|clone|const|constructor|continue|default|delete|else|enum|extends|for|foreach|function|if|in|instanceof|local|null|resume|return|static|switch|this|throw|try|typeof|while|yield)\b/,number:/\b(?:0x[0-9a-fA-F]+|\d+(?:\.(?:\d+|[eE][+-]?\d+))?)\b/,operator:/\+\+|--|<=>|<[-<]|>>>?|&&?|\|\|?|[-+*/%!=<>]=?|[~^]|::?/,punctuation:/[(){}\[\],;.]/}),Prism.languages.insertBefore("squirrel","string",{char:{pattern:/(^|[^\\"'])'(?:[^\\']|\\(?:[xuU][0-9a-fA-F]{0,8}|[\s\S]))'/,lookbehind:!0,greedy:!0}}),Prism.languages.insertBefore("squirrel","operator",{"attribute-punctuation":{pattern:/<\/|\/>/,alias:"important"},lambda:{pattern:/@(?=\()/,alias:"operator"}});
\ No newline at end of file
diff --git a/tests/languages/squirrel/char_feature.test b/tests/languages/squirrel/char_feature.test
new file mode 100644
index 0000000..2c05d27
--- /dev/null
+++ b/tests/languages/squirrel/char_feature.test
@@ -0,0 +1,11 @@
+'w'
+'\''
+'\x41' '\u0041' '\U00000041'
+
+----------------------------------------------------
+
+[
+ ["char", "'w'"],
+ ["char", "'\\''"],
+ ["char", "'\\x41'"], ["char", "'\\u0041'"], ["char", "'\\U00000041'"]
+]
diff --git a/tests/languages/squirrel/string_feature.test b/tests/languages/squirrel/string_feature.test
index 70dd41a..0df8c44 100644
--- a/tests/languages/squirrel/string_feature.test
+++ b/tests/languages/squirrel/string_feature.test
@@ -14,10 +14,6 @@ multiline verbatim string
characters
"
-'w'
-'\''
-'\x41' '\u0041' '\U00000041'
-
----------------------------------------------------
[
@@ -29,9 +25,5 @@ multiline verbatim string
["string", "@\"I'm a verbatim string\""],
["string", "@\" I'm a\r\nmultiline verbatim string\r\n\""],
- ["string", "@\"\r\n this is a multiline string\r\n it will \"\"embed\"\" all the new line\r\n characters\r\n\""],
-
- ["string", "'w'"],
- ["string", "'\\''"],
- ["string", "'\\x41'"], ["string", "'\\u0041'"], ["string", "'\\U00000041'"]
-]
\ No newline at end of file
+ ["string", "@\"\r\n this is a multiline string\r\n it will \"\"embed\"\" all the new line\r\n characters\r\n\""]
+]