stan.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. module.exports = function(hljs) {
  2. return {
  3. contains: [
  4. hljs.HASH_COMMENT_MODE,
  5. hljs.C_LINE_COMMENT_MODE,
  6. hljs.C_BLOCK_COMMENT_MODE,
  7. {
  8. begin: hljs.UNDERSCORE_IDENT_RE,
  9. lexemes: hljs.UNDERSCORE_IDENT_RE,
  10. keywords: {
  11. // Stan's keywords
  12. name:
  13. 'for in while repeat until if then else',
  14. // Stan's probablity distributions (less beta and gamma, as commonly
  15. // used for parameter names). So far, _log and _rng variants are not
  16. // included
  17. symbol:
  18. 'bernoulli bernoulli_logit binomial binomial_logit ' +
  19. 'beta_binomial hypergeometric categorical categorical_logit ' +
  20. 'ordered_logistic neg_binomial neg_binomial_2 ' +
  21. 'neg_binomial_2_log poisson poisson_log multinomial normal ' +
  22. 'exp_mod_normal skew_normal student_t cauchy double_exponential ' +
  23. 'logistic gumbel lognormal chi_square inv_chi_square ' +
  24. 'scaled_inv_chi_square exponential inv_gamma weibull frechet ' +
  25. 'rayleigh wiener pareto pareto_type_2 von_mises uniform ' +
  26. 'multi_normal multi_normal_prec multi_normal_cholesky multi_gp ' +
  27. 'multi_gp_cholesky multi_student_t gaussian_dlm_obs dirichlet ' +
  28. 'lkj_corr lkj_corr_cholesky wishart inv_wishart',
  29. // Stan's data types
  30. 'selector-tag':
  31. 'int real vector simplex unit_vector ordered positive_ordered ' +
  32. 'row_vector matrix cholesky_factor_corr cholesky_factor_cov ' +
  33. 'corr_matrix cov_matrix',
  34. // Stan's model blocks
  35. title:
  36. 'functions model data parameters quantities transformed ' +
  37. 'generated',
  38. literal:
  39. 'true false'
  40. },
  41. relevance: 0
  42. },
  43. // The below is all taken from the R language definition
  44. {
  45. // hex value
  46. className: 'number',
  47. begin: "0[xX][0-9a-fA-F]+[Li]?\\b",
  48. relevance: 0
  49. },
  50. {
  51. // hex value
  52. className: 'number',
  53. begin: "0[xX][0-9a-fA-F]+[Li]?\\b",
  54. relevance: 0
  55. },
  56. {
  57. // explicit integer
  58. className: 'number',
  59. begin: "\\d+(?:[eE][+\\-]?\\d*)?L\\b",
  60. relevance: 0
  61. },
  62. {
  63. // number with trailing decimal
  64. className: 'number',
  65. begin: "\\d+\\.(?!\\d)(?:i\\b)?",
  66. relevance: 0
  67. },
  68. {
  69. // number
  70. className: 'number',
  71. begin: "\\d+(?:\\.\\d*)?(?:[eE][+\\-]?\\d*)?i?\\b",
  72. relevance: 0
  73. },
  74. {
  75. // number with leading decimal
  76. className: 'number',
  77. begin: "\\.\\d+(?:[eE][+\\-]?\\d*)?i?\\b",
  78. relevance: 0
  79. }
  80. ]
  81. };
  82. };