prism-tremor.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. (function (Prism) {
  2. Prism.languages.tremor = {
  3. 'comment': {
  4. pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
  5. lookbehind: true
  6. },
  7. 'interpolated-string': null, // see below
  8. 'extractor': {
  9. pattern: /\b[a-z_]\w*\|(?:[^\r\n\\|]|\\(?:\r\n|[\s\S]))*\|/i,
  10. greedy: true,
  11. inside: {
  12. 'regex': {
  13. pattern: /(^re)\|[\s\S]+/,
  14. lookbehind: true
  15. },
  16. 'function': /^\w+/,
  17. 'value': /\|[\s\S]+/
  18. }
  19. },
  20. 'identifier': {
  21. pattern: /`[^`]*`/,
  22. greedy: true
  23. },
  24. 'function': /\b[a-z_]\w*(?=\s*(?:::\s*<|\())\b/,
  25. 'keyword': /\b(?:args|as|by|case|config|connect|connector|const|copy|create|default|define|deploy|drop|each|emit|end|erase|event|flow|fn|for|from|group|having|insert|into|intrinsic|let|links|match|merge|mod|move|of|operator|patch|pipeline|recur|script|select|set|sliding|state|stream|to|tumbling|update|use|when|where|window|with)\b/,
  26. 'boolean': /\b(?:false|null|true)\b/i,
  27. 'number': /\b(?:0b[01_]*|0x[0-9a-fA-F_]*|\d[\d_]*(?:\.\d[\d_]*)?(?:[Ee][+-]?[\d_]+)?)\b/,
  28. 'pattern-punctuation': {
  29. pattern: /%(?=[({[])/,
  30. alias: 'punctuation'
  31. },
  32. 'operator': /[-+*\/%~!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?>?=?|(?:absent|and|not|or|present|xor)\b/,
  33. 'punctuation': /::|[;\[\]()\{\},.:]/,
  34. };
  35. var interpolationPattern = /#\{(?:[^"{}]|\{[^{}]*\}|"(?:[^"\\\r\n]|\\(?:\r\n|[\s\S]))*")*\}/.source;
  36. Prism.languages.tremor['interpolated-string'] = {
  37. pattern: RegExp(
  38. /(^|[^\\])/.source +
  39. '(?:' +
  40. '"""(?:' + /[^"\\#]|\\[\s\S]|"(?!"")|#(?!\{)/.source + '|' + interpolationPattern + ')*"""' +
  41. '|' +
  42. '"(?:' + /[^"\\\r\n#]|\\(?:\r\n|[\s\S])|#(?!\{)/.source + '|' + interpolationPattern + ')*"' +
  43. ')'
  44. ),
  45. lookbehind: true,
  46. greedy: true,
  47. inside: {
  48. 'interpolation': {
  49. pattern: RegExp(interpolationPattern),
  50. inside: {
  51. 'punctuation': /^#\{|\}$/,
  52. 'expression': {
  53. pattern: /[\s\S]+/,
  54. inside: Prism.languages.tremor
  55. }
  56. }
  57. },
  58. 'string': /[\s\S]+/
  59. }
  60. };
  61. Prism.languages.troy = Prism.languages['tremor'];
  62. Prism.languages.trickle = Prism.languages['tremor'];
  63. }(Prism));