fsharp.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. Language: F#
  3. Author: Jonas Follesø <jonas@follesoe.no>
  4. Contributors: Troy Kershaw <hello@troykershaw.com>, Henrik Feldt <henrik@haf.se>
  5. Website: https://docs.microsoft.com/en-us/dotnet/fsharp/
  6. Category: functional
  7. */
  8. /** @type LanguageFn */
  9. function fsharp(hljs) {
  10. const TYPEPARAM = {
  11. begin: '<',
  12. end: '>',
  13. contains: [
  14. hljs.inherit(hljs.TITLE_MODE, {
  15. begin: /'[a-zA-Z0-9_]+/
  16. })
  17. ]
  18. };
  19. return {
  20. name: 'F#',
  21. aliases: ['fs'],
  22. keywords:
  23. 'abstract and as assert base begin class default delegate do done ' +
  24. 'downcast downto elif else end exception extern false finally for ' +
  25. 'fun function global if in inherit inline interface internal lazy let ' +
  26. 'match member module mutable namespace new null of open or ' +
  27. 'override private public rec return sig static struct then to ' +
  28. 'true try type upcast use val void when while with yield',
  29. illegal: /\/\*/,
  30. contains: [
  31. {
  32. // monad builder keywords (matches before non-bang kws)
  33. className: 'keyword',
  34. begin: /\b(yield|return|let|do)!/
  35. },
  36. {
  37. className: 'string',
  38. begin: '@"',
  39. end: '"',
  40. contains: [
  41. {
  42. begin: '""'
  43. }
  44. ]
  45. },
  46. {
  47. className: 'string',
  48. begin: '"""',
  49. end: '"""'
  50. },
  51. hljs.COMMENT('\\(\\*(\\s)', '\\*\\)', {
  52. contains: ["self"]
  53. }),
  54. {
  55. className: 'class',
  56. beginKeywords: 'type',
  57. end: '\\(|=|$',
  58. excludeEnd: true,
  59. contains: [
  60. hljs.UNDERSCORE_TITLE_MODE,
  61. TYPEPARAM
  62. ]
  63. },
  64. {
  65. className: 'meta',
  66. begin: '\\[<',
  67. end: '>\\]',
  68. relevance: 10
  69. },
  70. {
  71. className: 'symbol',
  72. begin: '\\B(\'[A-Za-z])\\b',
  73. contains: [hljs.BACKSLASH_ESCAPE]
  74. },
  75. hljs.C_LINE_COMMENT_MODE,
  76. hljs.inherit(hljs.QUOTE_STRING_MODE, {
  77. illegal: null
  78. }),
  79. hljs.C_NUMBER_MODE
  80. ]
  81. };
  82. }
  83. module.exports = fsharp;