Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squirrel: Use standard char token #3256

Merged
merged 1 commit into from Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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\""]
]