prism-reason.js 1.1 KB

12345678910111213141516171819202122232425
  1. Prism.languages.reason = Prism.languages.extend('clike', {
  2. 'string': {
  3. pattern: /"(?:\\(?:\r\n|[\s\S])|[^\\\r\n"])*"/,
  4. greedy: true
  5. },
  6. // 'class-name' must be matched *after* 'constructor' defined below
  7. 'class-name': /\b[A-Z]\w*/,
  8. 'keyword': /\b(?:and|as|assert|begin|class|constraint|do|done|downto|else|end|exception|external|for|fun|function|functor|if|in|include|inherit|initializer|lazy|let|method|module|mutable|new|nonrec|object|of|open|or|private|rec|sig|struct|switch|then|to|try|type|val|virtual|when|while|with)\b/,
  9. 'operator': /\.{3}|:[:=]|\|>|->|=(?:==?|>)?|<=?|>=?|[|^?'#!~`]|[+\-*\/]\.?|\b(?:asr|land|lor|lsl|lsr|lxor|mod)\b/
  10. });
  11. Prism.languages.insertBefore('reason', 'class-name', {
  12. 'char': {
  13. pattern: /'(?:\\x[\da-f]{2}|\\o[0-3][0-7][0-7]|\\\d{3}|\\.|[^'\\\r\n])'/,
  14. greedy: true
  15. },
  16. // Negative look-ahead prevents from matching things like String.capitalize
  17. 'constructor': /\b[A-Z]\w*\b(?!\s*\.)/,
  18. 'label': {
  19. pattern: /\b[a-z]\w*(?=::)/,
  20. alias: 'symbol'
  21. }
  22. });
  23. // We can't match functions property, so let's not even try.
  24. delete Prism.languages.reason.function;