Commit 58a65bfd8b28800491b93d70cc3eccd754c45b42

Michael Schmidt 2021-12-10T14:37:06

Squirrel: Use standard `char` token (#3256)

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\""]
+]