prism-stata.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // https://www.stata.com/manuals/u.pdf
  2. // https://www.stata.com/manuals/p.pdf
  3. Prism.languages.stata = {
  4. 'comment': [
  5. {
  6. pattern: /(^[ \t]*)\*.*/m,
  7. lookbehind: true,
  8. greedy: true
  9. },
  10. {
  11. pattern: /(^|\s)\/\/.*|\/\*[\s\S]*?\*\//,
  12. lookbehind: true,
  13. greedy: true
  14. }
  15. ],
  16. 'string-literal': {
  17. pattern: /"[^"\r\n]*"|[‘`']".*?"[’`']/,
  18. greedy: true,
  19. inside: {
  20. 'interpolation': {
  21. pattern: /\$\{[^{}]*\}|[‘`']\w[^’`'\r\n]*[’`']/,
  22. inside: {
  23. 'punctuation': /^\$\{|\}$/,
  24. 'expression': {
  25. pattern: /[\s\S]+/,
  26. inside: null // see below
  27. }
  28. }
  29. },
  30. 'string': /[\s\S]+/
  31. }
  32. },
  33. 'mata': {
  34. pattern: /(^[ \t]*mata[ \t]*:)[\s\S]+?(?=^end\b)/m,
  35. lookbehind: true,
  36. greedy: true,
  37. alias: 'language-mata',
  38. inside: Prism.languages.mata
  39. },
  40. 'java': {
  41. pattern: /(^[ \t]*java[ \t]*:)[\s\S]+?(?=^end\b)/m,
  42. lookbehind: true,
  43. greedy: true,
  44. alias: 'language-java',
  45. inside: Prism.languages.java
  46. },
  47. 'python': {
  48. pattern: /(^[ \t]*python[ \t]*:)[\s\S]+?(?=^end\b)/m,
  49. lookbehind: true,
  50. greedy: true,
  51. alias: 'language-python',
  52. inside: Prism.languages.python
  53. },
  54. 'command': {
  55. pattern: /(^[ \t]*(?:\.[ \t]+)?(?:(?:bayes|bootstrap|by|bysort|capture|collect|fmm|fp|frame|jackknife|mfp|mi|nestreg|noisily|permute|quietly|rolling|simulate|statsby|stepwise|svy|version|xi)\b[^:\r\n]*:[ \t]*|(?:capture|noisily|quietly|version)[ \t]+)?)[a-zA-Z]\w*/m,
  56. lookbehind: true,
  57. greedy: true,
  58. alias: 'keyword'
  59. },
  60. 'variable': /\$\w+|[‘`']\w[^’`'\r\n]*[’`']/,
  61. 'keyword': /\b(?:bayes|bootstrap|by|bysort|capture|clear|collect|fmm|fp|frame|if|in|jackknife|mi[ \t]+estimate|mfp|nestreg|noisily|of|permute|quietly|rolling|simulate|sort|statsby|stepwise|svy|varlist|version|xi)\b/,
  62. 'boolean': /\b(?:off|on)\b/,
  63. 'number': /\b\d+(?:\.\d+)?\b|\B\.\d+/,
  64. 'function': /\b[a-z_]\w*(?=\()/i,
  65. 'operator': /\+\+|--|##?|[<>!=~]=?|[+\-*^&|/]/,
  66. 'punctuation': /[(){}[\],:]/
  67. };
  68. Prism.languages.stata['string-literal'].inside.interpolation.inside.expression.inside = Prism.languages.stata;