]>
luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/stan.js
1 /*! `stan` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar
= (function () {
7 Description: The Stan probabilistic programming language
8 Author: Sean Pinkney <sean.pinkney@gmail.com>
9 Website: http://mc-stan.org/
14 const regex
= hljs
.regex
;
15 // variable names cannot conflict with block identifiers
53 'cholesky_factor_corr|10',
54 'cholesky_factor_cov|10',
60 // to get the functions list
61 // clone the [stan-docs repo](https://github.com/stan-dev/docs)
62 // then cd into it and run this bash script https://gist.github.com/joshgoebel/dcd33f82d4059a907c986049893843cf
64 // the output files are
65 // distributions_quoted.txt
66 // functions_quoted.txt
74 'algebra_solver_newton',
94 'columns_dot_product',
96 'complex_schur_decompose',
97 'complex_schur_decompose_t',
98 'complex_schur_decompose_u',
108 'csr_matrix_times_vector',
109 'csr_to_dense_matrix',
116 'diag_post_multiply',
124 'eigendecompose_sym',
145 'generalized_inverse',
149 'hmm_hidden_state_prob',
156 'integrate_ode_adams',
158 'integrate_ode_rk45',
181 'linspaced_int_array',
182 'linspaced_row_vector',
194 'log_falling_factorial',
196 'log_inv_logit_diff',
199 'log_modified_bessel_first_kind',
200 'log_rising_factorial',
206 'matrix_exp_multiply',
210 'mdivide_left_tri_low',
212 'mdivide_right_tri_low',
215 'modified_bessel_first_kind',
216 'modified_bessel_second_kind',
217 'multiply_lower_tri_self_transpose',
226 'ode_adjoint_tol_ctl',
235 'one_hot_row_vector',
274 'scale_matrix_exp_multiply',
296 'symmetrize_from_lower_tri',
311 'trace_gen_quad_form',
322 const DISTRIBUTIONS
= [
325 'bernoulli_logit_glm',
333 'categorical_logit_glm',
338 'double_exponential',
350 'inv_wishart_cholesky',
361 'multi_normal_cholesky',
363 'multi_student_cholesky_t',
365 'multi_student_t_cholesky',
368 'neg_binomial_2_log',
369 'neg_binomial_2_log_glm',
373 'ordered_logistic_glm',
381 'scaled_inv_chi_square',
382 'skew_double_exponential',
395 const BLOCK_COMMENT
= hljs
.COMMENT(
403 match: /@(return|param)/
415 match: /[a-z][a-z-._]+/,
418 hljs
.C_LINE_COMMENT_MODE
422 const RANGE_CONSTRAINTS
= [
431 aliases: [ 'stanfuncs' ],
433 $pattern: hljs
.IDENT_RE
,
440 hljs
.C_LINE_COMMENT_MODE
,
442 hljs
.HASH_COMMENT_MODE
,
446 match: /\s(pi|e|sqrt2|log2|log10)(?=\()/,
450 match: regex
.concat(/[<,]\s*/, regex
.either(...RANGE_CONSTRAINTS
), /\s*=/),
451 keywords: RANGE_CONSTRAINTS
455 match: /\btarget(?=\s*\+=)/,
458 // highlights the 'T' in T[,] for only Stan language distributrions
461 regex
.either(...DISTRIBUTIONS
),
471 // highlights distributions that end with special endings
473 keywords: DISTRIBUTIONS
,
474 begin: regex
.concat(/\w*/, regex
.either(...DISTRIBUTIONS
), /(_lpdf|_lupdf|_lpmf|_cdf|_lcdf|_lccdf|_qf)(?=\s*[\(.*\)])/)
477 // highlights distributions after ~
481 regex
.concat(regex
.either(...DISTRIBUTIONS
), /(?=\s*[\(.*\)])/)
483 scope: { 3: "built_in" }
486 // highlights user defined distributions after ~
489 /\s*\w+(?=\s*[\(.*\)])/,
490 '(?!.*/\b(' + regex
.either(...DISTRIBUTIONS
) + ')\b)'
492 scope: { 2: "title.function" }
495 // highlights user defined distributions with special endings
496 scope: 'title.function',
497 begin: /\w*(_lpdf|_lupdf|_lpmf|_cdf|_lcdf|_lccdf|_qf)(?=\s*[\(.*\)])/
502 // Comes from @RunDevelopment accessed 11/29/2021 at
503 // https://github.com/PrismJS/prism/blob/c53ad2e65b7193ab4f03a1797506a54bbb33d5a2/components/prism-stan.js#L56
505 // start of big noncapture group which
506 // 1. gets numbers that are by themselves
507 // 2. numbers that are separated by _
508 // 3. numbers that are separted by .
509 /(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)/,
510 // grabs scientific notation
511 // grabs complex numbers with i
512 /(?:[eE][+-]?\d+(?:_\d+)*)?i?(?!\w)/
529 export default hljsGrammar
;