Skip to content

Commit b58cd72

Browse files
authoredDec 6, 2021
F#: Added char token (#3271)
1 parent bee6ad5 commit b58cd72

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed
 

‎components/prism-fsharp.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ Prism.languages.fsharp = Prism.languages.extend('clike', {
22
'comment': [
33
{
44
pattern: /(^|[^\\])\(\*(?!\))[\s\S]*?\*\)/,
5-
lookbehind: true
5+
lookbehind: true,
6+
greedy: true
67
},
78
{
89
pattern: /(^|[^\\:])\/\/.*/,
9-
lookbehind: true
10+
lookbehind: true,
11+
greedy: true
1012
}
1113
],
1214
'string': {
13-
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?/,
15+
pattern: /(?:"""[\s\S]*?"""|@"(?:""|[^"])*"|"(?:\\[\s\S]|[^\\"])*")B?/,
1416
greedy: true
1517
},
1618
'class-name': {
@@ -53,6 +55,7 @@ Prism.languages.insertBefore('fsharp', 'punctuation', {
5355
Prism.languages.insertBefore('fsharp', 'string', {
5456
'annotation': {
5557
pattern: /\[<.+?>\]/,
58+
greedy: true,
5659
inside: {
5760
'punctuation': /^\[<|>\]$/,
5861
'class-name': {
@@ -64,5 +67,9 @@ Prism.languages.insertBefore('fsharp', 'string', {
6467
inside: Prism.languages.fsharp
6568
}
6669
}
70+
},
71+
'char': {
72+
pattern: /'(?:[^\\']|\\(?:.|\d{3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}|U[a-fA-F\d]{8}))'B?/,
73+
greedy: true
6774
}
6875
});

‎components/prism-fsharp.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'a'
2+
'a'B
3+
'\''
4+
'\\'
5+
'\231'
6+
'\x41'
7+
'\u0041'
8+
'\U0001F47D'
9+
10+
----------------------------------------------------
11+
12+
[
13+
["char", "'a'"],
14+
["char", "'a'B"],
15+
["char", "'\\''"],
16+
["char", "'\\\\'"],
17+
["char", "'\\231'"],
18+
["char", "'\\x41'"],
19+
["char", "'\\u0041'"],
20+
["char", "'\\U0001F47D'"]
21+
]

‎tests/languages/fsharp/string_feature.test

+2-20
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@ bar"
1414
bar"""
1515
"""foo"""B
1616

17-
'a'
18-
'a'B
19-
'\''
20-
'\\'
21-
'\231'
22-
'\x41'
23-
'\u0041'
24-
'\U0001F47D'
25-
2617
----------------------------------------------------
2718

2819
[
@@ -38,18 +29,9 @@ bar"""
3829

3930
["string", "\"\"\"\"\"\""],
4031
["string", "\"\"\"fo\"\"o\"\r\nbar\"\"\""],
41-
["string", "\"\"\"foo\"\"\"B"],
42-
43-
["string", "'a'"],
44-
["string", "'a'B"],
45-
["string", "'\\''"],
46-
["string", "'\\\\'"],
47-
["string", "'\\231'"],
48-
["string", "'\\x41'"],
49-
["string", "'\\u0041'"],
50-
["string", "'\\U0001F47D'"]
32+
["string", "\"\"\"foo\"\"\"B"]
5133
]
5234

5335
----------------------------------------------------
5436

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

0 commit comments

Comments
 (0)
Please sign in to comment.