Skip to content

Commit 7753fc4

Browse files
committed
F#: Regexp optimisation + don't use captures if not needed
1 parent 7547f83 commit 7753fc4

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

components/prism-fsharp.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ Prism.languages.fsharp = Prism.languages.extend('clike', {
1111
],
1212
'keyword': /\b(?:let|return|use|yield)(?:!\B|\b)|\b(abstract|and|as|assert|base|begin|class|default|delegate|do|done|downcast|downto|elif|else|end|exception|extern|false|finally|for|fun|function|global|if|in|inherit|inline|interface|internal|lazy|match|member|module|mutable|namespace|new|not|null|of|open|or|override|private|public|rec|select|static|struct|then|to|true|try|type|upcast|val|void|when|while|with|asr|land|lor|lsl|lsr|lxor|mod|sig|atomic|break|checked|component|const|constraint|constructor|continue|eager|event|external|fixed|functor|include|method|mixin|object|parallel|process|protected|pure|sealed|tailcall|trait|virtual|volatile)\b/,
1313
'string': {
14-
pattern: /(?:"""[\s\S]*?"""|@"(?:""|[^"])*"|("|')(?:\\\1|\\?(?!\1)[\s\S])*\1)B?/,
14+
pattern: /(?:"""[\s\S]*?"""|@"(?:""|[^"])*"|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1)B?/,
1515
greedy: true
1616
},
1717
'number': [
18-
/\b-?0x[\da-fA-F]+(un|lf|LF)?\b/,
19-
/\b-?0b[01]+(y|uy)?\b/,
20-
/\b-?(\d*\.?\d+|\d+\.)([fFmM]|[eE][+-]?\d+)?\b/,
21-
/\b-?\d+(y|uy|s|us|l|u|ul|L|UL|I)?\b/
18+
/\b-?0x[\da-fA-F]+(?:un|lf|LF)?\b/,
19+
/\b-?0b[01]+(?:y|uy)?\b/,
20+
/\b-?(?:\d*\.?\d+|\d+\.)(?:[fFmM]|[eE][+-]?\d+)?\b/,
21+
/\b-?\d+(?:y|uy|s|us|l|u|ul|L|UL|I)?\b/
2222
]
2323
});
2424
Prism.languages.insertBefore('fsharp', 'keyword', {
@@ -27,7 +27,7 @@ Prism.languages.insertBefore('fsharp', 'keyword', {
2727
alias: 'property',
2828
inside: {
2929
'directive': {
30-
pattern: /(\s*#)\b(else|endif|if|light|line|nowarn)\b/,
30+
pattern: /(\s*#)\b(?:else|endif|if|light|line|nowarn)\b/,
3131
lookbehind: true,
3232
alias: 'keyword'
3333
}

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.

0 commit comments

Comments
 (0)