Skip to content

Commit

Permalink
Squirrel: Use standard char token (#3256)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Dec 10, 2021
1 parent c56e4bf commit 58a65bf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 23 deletions.
25 changes: 13 additions & 12 deletions components/prism-squirrel.js
Expand Up @@ -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+)*/,
Expand All @@ -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: /<\/|\/>/,
Expand Down
2 changes: 1 addition & 1 deletion components/prism-squirrel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/languages/squirrel/char_feature.test
@@ -0,0 +1,11 @@
'w'
'\''
'\x41' '\u0041' '\U00000041'

----------------------------------------------------

[
["char", "'w'"],
["char", "'\\''"],
["char", "'\\x41'"], ["char", "'\\u0041'"], ["char", "'\\U00000041'"]
]
12 changes: 2 additions & 10 deletions tests/languages/squirrel/string_feature.test
Expand Up @@ -14,10 +14,6 @@ multiline verbatim string
characters
"

'w'
'\''
'\x41' '\u0041' '\U00000041'

----------------------------------------------------

[
Expand All @@ -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'"]
]
["string", "@\"\r\n this is a multiline string\r\n it will \"\"embed\"\" all the new line\r\n characters\r\n\""]
]

0 comments on commit 58a65bf

Please sign in to comment.