Skip to content

Commit

Permalink
F#: Added char token (#3271)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Dec 6, 2021
1 parent bee6ad5 commit b58cd72
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 24 deletions.
13 changes: 10 additions & 3 deletions components/prism-fsharp.js
Expand Up @@ -2,15 +2,17 @@ Prism.languages.fsharp = Prism.languages.extend('clike', {
'comment': [
{
pattern: /(^|[^\\])\(\*(?!\))[\s\S]*?\*\)/,
lookbehind: true
lookbehind: true,
greedy: true
},
{
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true
lookbehind: true,
greedy: true
}
],
'string': {
pattern: /(?:"""[\s\S]*?"""|@"(?:""|[^"])*"|"(?:\\[\s\S]|[^\\"])*")B?|'(?:[^\\']|\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8}))'B?/,
pattern: /(?:"""[\s\S]*?"""|@"(?:""|[^"])*"|"(?:\\[\s\S]|[^\\"])*")B?/,
greedy: true
},
'class-name': {
Expand Down Expand Up @@ -53,6 +55,7 @@ Prism.languages.insertBefore('fsharp', 'punctuation', {
Prism.languages.insertBefore('fsharp', 'string', {
'annotation': {
pattern: /\[<.+?>\]/,
greedy: true,
inside: {
'punctuation': /^\[<|>\]$/,
'class-name': {
Expand All @@ -64,5 +67,9 @@ Prism.languages.insertBefore('fsharp', 'string', {
inside: Prism.languages.fsharp
}
}
},
'char': {
pattern: /'(?:[^\\']|\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8}))'B?/,
greedy: true
}
});
2 changes: 1 addition & 1 deletion components/prism-fsharp.min.js

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

21 changes: 21 additions & 0 deletions tests/languages/fsharp/char_feature.test
@@ -0,0 +1,21 @@
'a'
'a'B
'\''
'\\'
'\231'
'\x41'
'\u0041'
'\U0001F47D'

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

[
["char", "'a'"],
["char", "'a'B"],
["char", "'\\''"],
["char", "'\\\\'"],
["char", "'\\231'"],
["char", "'\\x41'"],
["char", "'\\u0041'"],
["char", "'\\U0001F47D'"]
]
22 changes: 2 additions & 20 deletions tests/languages/fsharp/string_feature.test
Expand Up @@ -14,15 +14,6 @@ bar"
bar"""
"""foo"""B

'a'
'a'B
'\''
'\\'
'\231'
'\x41'
'\u0041'
'\U0001F47D'

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

[
Expand All @@ -38,18 +29,9 @@ bar"""

["string", "\"\"\"\"\"\""],
["string", "\"\"\"fo\"\"o\"\r\nbar\"\"\""],
["string", "\"\"\"foo\"\"\"B"],

["string", "'a'"],
["string", "'a'B"],
["string", "'\\''"],
["string", "'\\\\'"],
["string", "'\\231'"],
["string", "'\\x41'"],
["string", "'\\u0041'"],
["string", "'\\U0001F47D'"]
["string", "\"\"\"foo\"\"\"B"]
]

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

Checks for normal strings, verbatim strings, triple-quoted strings and character literals.
Checks for normal strings, verbatim strings, and triple-quoted strings.

0 comments on commit b58cd72

Please sign in to comment.