stan.js 3.0 KB

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