summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pygments/lexers/_stan_builtins.py911
-rw-r--r--pygments/lexers/math.py10
-rw-r--r--tests/examplefiles/example.stan11
3 files changed, 488 insertions, 444 deletions
diff --git a/pygments/lexers/_stan_builtins.py b/pygments/lexers/_stan_builtins.py
index 583b44a8..4c4a27c1 100644
--- a/pygments/lexers/_stan_builtins.py
+++ b/pygments/lexers/_stan_builtins.py
@@ -4,451 +4,486 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This file contains the names of functions for Stan used by
- ``pygments.lexers.math.StanLexer``. These builtins are from Stan language v2.2.0.
+ ``pygments.lexers.math.StanLexer. This is for Stan language version 2.4.0.
:copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
-KEYWORDS = ['else', 'for', 'if', 'in', 'lp__', 'print', 'while']
+KEYWORDS = [ u'else',
+ u'for',
+ u'if',
+ u'in',
+ u'increment_log_prob',
+ u'lp__',
+ u'print',
+ u'return',
+ u'while']
-TYPES = [ 'cholesky_factor_cov',
- 'corr_matrix',
- 'cov_matrix',
- 'int',
- 'matrix',
- 'ordered',
- 'positive_ordered',
- 'real',
- 'row_vector',
- 'simplex',
- 'unit_vector',
- 'vector']
+TYPES = [ u'cholesky_factor_corr',
+ u'cholesky_factor_cov',
+ u'corr_matrix',
+ u'cov_matrix',
+ u'int',
+ u'matrix',
+ u'ordered',
+ u'positive_ordered',
+ u'real',
+ u'row_vector',
+ u'simplex',
+ u'unit_vector',
+ u'vector',
+ u'void']
-FUNCTIONS = [ 'Phi',
- 'Phi_approx',
- 'abs',
- 'acos',
- 'acosh',
- 'asin',
- 'asinh',
- 'atan',
- 'atan2',
- 'atanh',
- 'bernoulli_ccdf_log',
- 'bernoulli_cdf',
- 'bernoulli_cdf_log',
- 'bernoulli_log',
- 'bernoulli_logit_log',
- 'bernoulli_rng',
- 'bessel_first_kind',
- 'bessel_second_kind',
- 'beta_binomial_ccdf_log',
- 'beta_binomial_cdf',
- 'beta_binomial_cdf_log',
- 'beta_binomial_log',
- 'beta_binomial_rng',
- 'beta_ccdf_log',
- 'beta_cdf',
- 'beta_cdf_log',
- 'beta_log',
- 'beta_rng',
- 'binary_log_loss',
- 'binomial_ccdf_log',
- 'binomial_cdf',
- 'binomial_cdf_log',
- 'binomial_coefficient_log',
- 'binomial_log',
- 'binomial_logit_log',
- 'binomial_rng',
- 'block',
- 'categorical_log',
- 'categorical_logit_log',
- 'categorical_rng',
- 'cauchy_ccdf_log',
- 'cauchy_cdf',
- 'cauchy_cdf_log',
- 'cauchy_log',
- 'cauchy_rng',
- 'cbrt',
- 'ceil',
- 'chi_square_ccdf_log',
- 'chi_square_cdf',
- 'chi_square_cdf_log',
- 'chi_square_log',
- 'chi_square_rng',
- 'cholesky_decompose',
- 'col',
- 'cols',
- 'columns_dot_product',
- 'columns_dot_self',
- 'cos',
- 'cosh',
- 'crossprod',
- 'cumulative_sum',
- 'determinant',
- 'diag_matrix',
- 'diag_post_multiply',
- 'diag_pre_multiply',
- 'diagonal',
- 'digamma',
- 'dims',
- 'dirichlet_log',
- 'dirichlet_rng',
- 'distance',
- 'dot_product',
- 'dot_self',
- 'double_exponential_ccdf_log',
- 'double_exponential_cdf',
- 'double_exponential_cdf_log',
- 'double_exponential_log',
- 'double_exponential_rng',
- 'e',
- 'eigenvalues_sym',
- 'eigenvectors_sym',
- 'erf',
- 'erfc',
- 'exp',
- 'exp2',
- 'exp_mod_normal_ccdf_log',
- 'exp_mod_normal_cdf',
- 'exp_mod_normal_cdf_log',
- 'exp_mod_normal_log',
- 'exp_mod_normal_rng',
- 'expm1',
- 'exponential_ccdf_log',
- 'exponential_cdf',
- 'exponential_cdf_log',
- 'exponential_log',
- 'exponential_rng',
- 'fabs',
- 'falling_factorial',
- 'fdim',
- 'floor',
- 'fma',
- 'fmax',
- 'fmin',
- 'fmod',
- 'gamma_ccdf_log',
- 'gamma_cdf',
- 'gamma_cdf_log',
- 'gamma_log',
- 'gamma_p',
- 'gamma_q',
- 'gamma_rng',
- 'gaussian_dlm_obs_log',
- 'gumbel_ccdf_log',
- 'gumbel_cdf',
- 'gumbel_cdf_log',
- 'gumbel_log',
- 'gumbel_rng',
- 'head',
- 'hypergeometric_log',
- 'hypergeometric_rng',
- 'hypot',
- 'if_else',
- 'increment_log_prob',
- 'int_step',
- 'inv',
- 'inv_chi_square_ccdf_log',
- 'inv_chi_square_cdf',
- 'inv_chi_square_cdf_log',
- 'inv_chi_square_log',
- 'inv_chi_square_rng',
- 'inv_cloglog',
- 'inv_gamma_ccdf_log',
- 'inv_gamma_cdf',
- 'inv_gamma_cdf_log',
- 'inv_gamma_log',
- 'inv_gamma_rng',
- 'inv_logit',
- 'inv_sqrt',
- 'inv_square',
- 'inv_wishart_log',
- 'inv_wishart_rng',
- 'inverse',
- 'inverse_spd',
- 'lbeta',
- 'lgamma',
- 'lkj_corr_log',
- 'lkj_corr_rng',
- 'lmgamma',
- 'log',
- 'log10',
- 'log1m',
- 'log1m_exp',
- 'log1m_inv_logit',
- 'log1p',
- 'log1p_exp',
- 'log2',
- 'log_determinant',
- 'log_diff_exp',
- 'log_falling_factorial',
- 'log_inv_logit',
- 'log_rising_factorial',
- 'log_softmax',
- 'log_sum_exp',
- 'logistic_ccdf_log',
- 'logistic_cdf',
- 'logistic_cdf_log',
- 'logistic_log',
- 'logistic_rng',
- 'logit',
- 'lognormal_ccdf_log',
- 'lognormal_cdf',
- 'lognormal_cdf_log',
- 'lognormal_log',
- 'lognormal_rng',
- 'machine_precision',
- 'max',
- 'mdivide_left_tri_low',
- 'mdivide_right_tri_low',
- 'mean',
- 'min',
- 'modified_bessel_first_kind',
- 'modified_bessel_second_kind',
- 'multi_normal_cholesky_log',
- 'multi_normal_log',
- 'multi_normal_prec_log',
- 'multi_normal_rng',
- 'multi_student_t_log',
- 'multi_student_t_rng',
- 'multinomial_log',
- 'multinomial_rng',
- 'multiply_log',
- 'multiply_lower_tri_self_transpose',
- 'neg_binomial_ccdf_log',
- 'neg_binomial_cdf',
- 'neg_binomial_cdf_log',
- 'neg_binomial_log',
- 'neg_binomial_rng',
- 'negative_infinity',
- 'normal_ccdf_log',
- 'normal_cdf',
- 'normal_cdf_log',
- 'normal_log',
- 'normal_rng',
- 'not_a_number',
- 'ordered_logistic_log',
- 'ordered_logistic_rng',
- 'owens_t',
- 'pareto_ccdf_log',
- 'pareto_cdf',
- 'pareto_cdf_log',
- 'pareto_log',
- 'pareto_rng',
- 'pi',
- 'poisson_ccdf_log',
- 'poisson_cdf',
- 'poisson_cdf_log',
- 'poisson_log',
- 'poisson_log_log',
- 'poisson_rng',
- 'positive_infinity',
- 'pow',
- 'prod',
- 'quad_form',
- 'rank',
- 'rayleigh_ccdf_log',
- 'rayleigh_cdf',
- 'rayleigh_cdf_log',
- 'rayleigh_log',
- 'rayleigh_rng',
- 'rep_array',
- 'rep_matrix',
- 'rep_row_vector',
- 'rep_vector',
- 'rising_factorial',
- 'round',
- 'row',
- 'rows',
- 'rows_dot_product',
- 'rows_dot_self',
- 'scaled_inv_chi_square_ccdf_log',
- 'scaled_inv_chi_square_cdf',
- 'scaled_inv_chi_square_cdf_log',
- 'scaled_inv_chi_square_log',
- 'scaled_inv_chi_square_rng',
- 'sd',
- 'segment',
- 'sin',
- 'singular_values',
- 'sinh',
- 'size',
- 'skew_normal_ccdf_log',
- 'skew_normal_cdf',
- 'skew_normal_cdf_log',
- 'skew_normal_log',
- 'skew_normal_rng',
- 'softmax',
- 'sort_asc',
- 'sort_desc',
- 'sqrt',
- 'sqrt2',
- 'square',
- 'squared_distance',
- 'step',
- 'student_t_ccdf_log',
- 'student_t_cdf',
- 'student_t_cdf_log',
- 'student_t_log',
- 'student_t_rng',
- 'sub_col',
- 'sub_row',
- 'sum',
- 'tail',
- 'tan',
- 'tanh',
- 'tcrossprod',
- 'tgamma',
- 'to_vector',
- 'trace',
- 'trace_gen_quad_form',
- 'trace_quad_form',
- 'trigamma',
- 'trunc',
- 'uniform_ccdf_log',
- 'uniform_cdf',
- 'uniform_cdf_log',
- 'uniform_log',
- 'uniform_rng',
- 'variance',
- 'von_mises_log',
- 'weibull_ccdf_log',
- 'weibull_cdf',
- 'weibull_cdf_log',
- 'weibull_log',
- 'weibull_rng',
- 'wishart_log',
- 'wishart_rng']
+FUNCTIONS = [ u'Phi',
+ u'Phi_approx',
+ u'abs',
+ u'acos',
+ u'acosh',
+ u'asin',
+ u'asinh',
+ u'atan',
+ u'atan2',
+ u'atanh',
+ u'bernoulli_ccdf_log',
+ u'bernoulli_cdf',
+ u'bernoulli_cdf_log',
+ u'bernoulli_log',
+ u'bernoulli_logit_log',
+ u'bernoulli_rng',
+ u'bessel_first_kind',
+ u'bessel_second_kind',
+ u'beta_binomial_ccdf_log',
+ u'beta_binomial_cdf',
+ u'beta_binomial_cdf_log',
+ u'beta_binomial_log',
+ u'beta_binomial_rng',
+ u'beta_ccdf_log',
+ u'beta_cdf',
+ u'beta_cdf_log',
+ u'beta_log',
+ u'beta_rng',
+ u'binary_log_loss',
+ u'binomial_ccdf_log',
+ u'binomial_cdf',
+ u'binomial_cdf_log',
+ u'binomial_coefficient_log',
+ u'binomial_log',
+ u'binomial_logit_log',
+ u'binomial_rng',
+ u'block',
+ u'categorical_log',
+ u'categorical_logit_log',
+ u'categorical_rng',
+ u'cauchy_ccdf_log',
+ u'cauchy_cdf',
+ u'cauchy_cdf_log',
+ u'cauchy_log',
+ u'cauchy_rng',
+ u'cbrt',
+ u'ceil',
+ u'chi_square_ccdf_log',
+ u'chi_square_cdf',
+ u'chi_square_cdf_log',
+ u'chi_square_log',
+ u'chi_square_rng',
+ u'cholesky_decompose',
+ u'col',
+ u'cols',
+ u'columns_dot_product',
+ u'columns_dot_self',
+ u'cos',
+ u'cosh',
+ u'crossprod',
+ u'cumulative_sum',
+ u'determinant',
+ u'diag_matrix',
+ u'diag_post_multiply',
+ u'diag_pre_multiply',
+ u'diagonal',
+ u'digamma',
+ u'dims',
+ u'dirichlet_log',
+ u'dirichlet_rng',
+ u'distance',
+ u'dot_product',
+ u'dot_self',
+ u'double_exponential_ccdf_log',
+ u'double_exponential_cdf',
+ u'double_exponential_cdf_log',
+ u'double_exponential_log',
+ u'double_exponential_rng',
+ u'e',
+ u'eigenvalues_sym',
+ u'eigenvectors_sym',
+ u'erf',
+ u'erfc',
+ u'exp',
+ u'exp2',
+ u'exp_mod_normal_ccdf_log',
+ u'exp_mod_normal_cdf',
+ u'exp_mod_normal_cdf_log',
+ u'exp_mod_normal_log',
+ u'exp_mod_normal_rng',
+ u'expm1',
+ u'exponential_ccdf_log',
+ u'exponential_cdf',
+ u'exponential_cdf_log',
+ u'exponential_log',
+ u'exponential_rng',
+ u'fabs',
+ u'falling_factorial',
+ u'fdim',
+ u'floor',
+ u'fma',
+ u'fmax',
+ u'fmin',
+ u'fmod',
+ u'gamma_ccdf_log',
+ u'gamma_cdf',
+ u'gamma_cdf_log',
+ u'gamma_log',
+ u'gamma_p',
+ u'gamma_q',
+ u'gamma_rng',
+ u'gaussian_dlm_obs_log',
+ u'gumbel_ccdf_log',
+ u'gumbel_cdf',
+ u'gumbel_cdf_log',
+ u'gumbel_log',
+ u'gumbel_rng',
+ u'head',
+ u'hypergeometric_log',
+ u'hypergeometric_rng',
+ u'hypot',
+ u'if_else',
+ u'int_step',
+ u'inv',
+ u'inv_chi_square_ccdf_log',
+ u'inv_chi_square_cdf',
+ u'inv_chi_square_cdf_log',
+ u'inv_chi_square_log',
+ u'inv_chi_square_rng',
+ u'inv_cloglog',
+ u'inv_gamma_ccdf_log',
+ u'inv_gamma_cdf',
+ u'inv_gamma_cdf_log',
+ u'inv_gamma_log',
+ u'inv_gamma_rng',
+ u'inv_logit',
+ u'inv_sqrt',
+ u'inv_square',
+ u'inv_wishart_log',
+ u'inv_wishart_rng',
+ u'inverse',
+ u'inverse_spd',
+ u'lbeta',
+ u'lgamma',
+ u'lkj_corr_cholesky_log',
+ u'lkj_corr_cholesky_rng',
+ u'lkj_corr_log',
+ u'lkj_corr_rng',
+ u'lkj_cov_log',
+ u'lmgamma',
+ u'log',
+ u'log10',
+ u'log1m',
+ u'log1m_exp',
+ u'log1m_inv_logit',
+ u'log1p',
+ u'log1p_exp',
+ u'log2',
+ u'log_determinant',
+ u'log_diff_exp',
+ u'log_falling_factorial',
+ u'log_inv_logit',
+ u'log_rising_factorial',
+ u'log_softmax',
+ u'log_sum_exp',
+ u'logistic_ccdf_log',
+ u'logistic_cdf',
+ u'logistic_cdf_log',
+ u'logistic_log',
+ u'logistic_rng',
+ u'logit',
+ u'lognormal_ccdf_log',
+ u'lognormal_cdf',
+ u'lognormal_cdf_log',
+ u'lognormal_log',
+ u'lognormal_rng',
+ u'machine_precision',
+ u'max',
+ u'mdivide_left_tri_low',
+ u'mdivide_right_tri_low',
+ u'mean',
+ u'min',
+ u'modified_bessel_first_kind',
+ u'modified_bessel_second_kind',
+ u'multi_gp_log',
+ u'multi_normal_cholesky_log',
+ u'multi_normal_cholesky_rng',
+ u'multi_normal_log',
+ u'multi_normal_prec_log',
+ u'multi_normal_rng',
+ u'multi_student_t_log',
+ u'multi_student_t_rng',
+ u'multinomial_log',
+ u'multinomial_rng',
+ u'multiply_log',
+ u'multiply_lower_tri_self_transpose',
+ u'neg_binomial_2_log',
+ u'neg_binomial_2_log_log',
+ u'neg_binomial_2_log_rng',
+ u'neg_binomial_2_rng',
+ u'neg_binomial_ccdf_log',
+ u'neg_binomial_cdf',
+ u'neg_binomial_cdf_log',
+ u'neg_binomial_log',
+ u'neg_binomial_rng',
+ u'negative_infinity',
+ u'normal_ccdf_log',
+ u'normal_cdf',
+ u'normal_cdf_log',
+ u'normal_log',
+ u'normal_rng',
+ u'not_a_number',
+ u'ordered_logistic_log',
+ u'ordered_logistic_rng',
+ u'owens_t',
+ u'pareto_ccdf_log',
+ u'pareto_cdf',
+ u'pareto_cdf_log',
+ u'pareto_log',
+ u'pareto_rng',
+ u'pi',
+ u'poisson_ccdf_log',
+ u'poisson_cdf',
+ u'poisson_cdf_log',
+ u'poisson_log',
+ u'poisson_log_log',
+ u'poisson_rng',
+ u'positive_infinity',
+ u'pow',
+ u'prod',
+ u'qr_Q',
+ u'qr_R',
+ u'quad_form',
+ u'quad_form_diag',
+ u'quad_form_sym',
+ u'rank',
+ u'rayleigh_ccdf_log',
+ u'rayleigh_cdf',
+ u'rayleigh_cdf_log',
+ u'rayleigh_log',
+ u'rayleigh_rng',
+ u'rep_array',
+ u'rep_matrix',
+ u'rep_row_vector',
+ u'rep_vector',
+ u'rising_factorial',
+ u'round',
+ u'row',
+ u'rows',
+ u'rows_dot_product',
+ u'rows_dot_self',
+ u'scaled_inv_chi_square_ccdf_log',
+ u'scaled_inv_chi_square_cdf',
+ u'scaled_inv_chi_square_cdf_log',
+ u'scaled_inv_chi_square_log',
+ u'scaled_inv_chi_square_rng',
+ u'sd',
+ u'segment',
+ u'sin',
+ u'singular_values',
+ u'sinh',
+ u'size',
+ u'skew_normal_ccdf_log',
+ u'skew_normal_cdf',
+ u'skew_normal_cdf_log',
+ u'skew_normal_log',
+ u'skew_normal_rng',
+ u'softmax',
+ u'sort_asc',
+ u'sort_desc',
+ u'sort_indices_asc',
+ u'sort_indices_desc',
+ u'sqrt',
+ u'sqrt2',
+ u'square',
+ u'squared_distance',
+ u'step',
+ u'student_t_ccdf_log',
+ u'student_t_cdf',
+ u'student_t_cdf_log',
+ u'student_t_log',
+ u'student_t_rng',
+ u'sub_col',
+ u'sub_row',
+ u'sum',
+ u'tail',
+ u'tan',
+ u'tanh',
+ u'tcrossprod',
+ u'tgamma',
+ u'to_array_1d',
+ u'to_array_2d',
+ u'to_matrix',
+ u'to_row_vector',
+ u'to_vector',
+ u'trace',
+ u'trace_gen_quad_form',
+ u'trace_quad_form',
+ u'trigamma',
+ u'trunc',
+ u'uniform_ccdf_log',
+ u'uniform_cdf',
+ u'uniform_cdf_log',
+ u'uniform_log',
+ u'uniform_rng',
+ u'variance',
+ u'von_mises_log',
+ u'von_mises_rng',
+ u'weibull_ccdf_log',
+ u'weibull_cdf',
+ u'weibull_cdf_log',
+ u'weibull_log',
+ u'weibull_rng',
+ u'wishart_log',
+ u'wishart_rng']
-DISTRIBUTIONS = [ 'bernoulli',
- 'bernoulli_logit',
- 'beta',
- 'beta_binomial',
- 'binomial',
- 'binomial_logit',
- 'categorical',
- 'categorical_logit',
- 'cauchy',
- 'chi_square',
- 'dirichlet',
- 'double_exponential',
- 'exp_mod_normal',
- 'exponential',
- 'gamma',
- 'gaussian_dlm_obs',
- 'gumbel',
- 'hypergeometric',
- 'inv_chi_square',
- 'inv_gamma',
- 'inv_wishart',
- 'lkj_corr',
- 'logistic',
- 'lognormal',
- 'multi_normal',
- 'multi_normal_cholesky',
- 'multi_normal_prec',
- 'multi_student_t',
- 'multinomial',
- 'neg_binomial',
- 'normal',
- 'ordered_logistic',
- 'pareto',
- 'poisson',
- 'poisson_log',
- 'rayleigh',
- 'scaled_inv_chi_square',
- 'skew_normal',
- 'student_t',
- 'uniform',
- 'von_mises',
- 'weibull',
- 'wishart']
+DISTRIBUTIONS = [ u'bernoulli',
+ u'bernoulli_logit',
+ u'beta',
+ u'beta_binomial',
+ u'binomial',
+ u'binomial_logit',
+ u'categorical',
+ u'categorical_logit',
+ u'cauchy',
+ u'chi_square',
+ u'dirichlet',
+ u'double_exponential',
+ u'exp_mod_normal',
+ u'exponential',
+ u'gamma',
+ u'gaussian_dlm_obs',
+ u'gumbel',
+ u'hypergeometric',
+ u'inv_chi_square',
+ u'inv_gamma',
+ u'inv_wishart',
+ u'lkj_corr',
+ u'lkj_corr_cholesky',
+ u'lkj_cov',
+ u'logistic',
+ u'lognormal',
+ u'multi_gp',
+ u'multi_normal',
+ u'multi_normal_cholesky',
+ u'multi_normal_prec',
+ u'multi_student_t',
+ u'multinomial',
+ u'neg_binomial',
+ u'neg_binomial_2',
+ u'neg_binomial_2_log',
+ u'normal',
+ u'ordered_logistic',
+ u'pareto',
+ u'poisson',
+ u'poisson_log',
+ u'rayleigh',
+ u'scaled_inv_chi_square',
+ u'skew_normal',
+ u'student_t',
+ u'uniform',
+ u'von_mises',
+ u'weibull',
+ u'wishart']
-RESERVED = [ 'alignas',
- 'alignof',
- 'and',
- 'and_eq',
- 'asm',
- 'auto',
- 'bitand',
- 'bitor',
- 'bool',
- 'break',
- 'case',
- 'catch',
- 'char',
- 'char16_t',
- 'char32_t',
- 'class',
- 'compl',
- 'const',
- 'const_cast',
- 'constexpr',
- 'continue',
- 'decltype',
- 'default',
- 'delete',
- 'do',
- 'double',
- 'dynamic_cast',
- 'enum',
- 'explicit',
- 'export',
- 'extern',
- 'false',
- 'false',
- 'float',
- 'friend',
- 'goto',
- 'inline',
- 'int',
- 'long',
- 'mutable',
- 'namespace',
- 'new',
- 'noexcept',
- 'not',
- 'not_eq',
- 'nullptr',
- 'operator',
- 'or',
- 'or_eq',
- 'private',
- 'protected',
- 'public',
- 'register',
- 'reinterpret_cast',
- 'repeat',
- 'return',
- 'short',
- 'signed',
- 'sizeof',
- 'static',
- 'static_assert',
- 'static_cast',
- 'struct',
- 'switch',
- 'template',
- 'then',
- 'this',
- 'thread_local',
- 'throw',
- 'true',
- 'true',
- 'try',
- 'typedef',
- 'typeid',
- 'typename',
- 'union',
- 'unsigned',
- 'until',
- 'using',
- 'virtual',
- 'void',
- 'volatile',
- 'wchar_t',
- 'xor',
- 'xor_eq']
+RESERVED = [ u'alignas',
+ u'alignof',
+ u'and',
+ u'and_eq',
+ u'asm',
+ u'auto',
+ u'bitand',
+ u'bitor',
+ u'bool',
+ u'break',
+ u'case',
+ u'catch',
+ u'char',
+ u'char16_t',
+ u'char32_t',
+ u'class',
+ u'compl',
+ u'const',
+ u'const_cast',
+ u'constexpr',
+ u'continue',
+ u'decltype',
+ u'default',
+ u'delete',
+ u'do',
+ u'double',
+ u'dynamic_cast',
+ u'enum',
+ u'explicit',
+ u'export',
+ u'extern',
+ u'false',
+ u'false',
+ u'float',
+ u'friend',
+ u'fvar',
+ u'goto',
+ u'inline',
+ u'int',
+ u'long',
+ u'mutable',
+ u'namespace',
+ u'new',
+ u'noexcept',
+ u'not',
+ u'not_eq',
+ u'nullptr',
+ u'operator',
+ u'or',
+ u'or_eq',
+ u'private',
+ u'protected',
+ u'public',
+ u'register',
+ u'reinterpret_cast',
+ u'repeat',
+ u'short',
+ u'signed',
+ u'sizeof',
+ u'static',
+ u'static_assert',
+ u'static_cast',
+ u'struct',
+ u'switch',
+ u'template',
+ u'then',
+ u'this',
+ u'thread_local',
+ u'throw',
+ u'true',
+ u'true',
+ u'try',
+ u'typedef',
+ u'typeid',
+ u'typename',
+ u'union',
+ u'unsigned',
+ u'until',
+ u'using',
+ u'var',
+ u'virtual',
+ u'void',
+ u'volatile',
+ u'wchar_t',
+ u'xor',
+ u'xor_eq']
diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py
index b324c614..c51403e2 100644
--- a/pygments/lexers/math.py
+++ b/pygments/lexers/math.py
@@ -1572,8 +1572,8 @@ class JagsLexer(RegexLexer):
class StanLexer(RegexLexer):
"""Pygments Lexer for Stan models.
- The Stan modeling language is specified in the *Stan Modeling Language User's Guide and Reference Manual, v2.2.0*,
- `pdf <https://github.com/stan-dev/stan/releases/download/v2.2.0/stan-reference-2.2.0.pdf>`__.
+ The Stan modeling language is specified in the *Stan Modeling Language User's Guide and Reference Manual, v2.4.0*,
+ `pdf <https://github.com/stan-dev/stan/releases/download/v2.4.0/stan-reference-2.4.0.pdf>`__.
.. versionadded:: 1.6
"""
@@ -1600,7 +1600,7 @@ class StanLexer(RegexLexer):
include('whitespace'),
# Block start
(r'(%s)(\s*)({)' %
- r'|'.join(('data', r'transformed\s+?data',
+ r'|'.join(('functions', 'data', r'transformed\s+?data',
'parameters', r'transformed\s+parameters',
'model', r'generated\s+quantities')),
bygroups(Keyword.Namespace, Text, Punctuation)),
@@ -1630,8 +1630,8 @@ class StanLexer(RegexLexer):
# Assignment operators
# SLexer makes these tokens Operators.
(r'<-|~', Operator),
- # Infix and prefix operators (and = )
- (r"\+|-|\.?\*|\.?/|\\|'|==?|!=?|<=?|>=?|\|\||&&", Operator),
+ # Infix, prefix and postfix operators (and = )
+ (r"\+|-|\.?\*|\.?/|\\|'|\^|==?|!=?|<=?|>=?|\|\||&&", Operator),
# Block delimiters
(r'[{}]', Punctuation),
]
diff --git a/tests/examplefiles/example.stan b/tests/examplefiles/example.stan
index 7eb6fdfc..716b4d12 100644
--- a/tests/examplefiles/example.stan
+++ b/tests/examplefiles/example.stan
@@ -5,6 +5,14 @@ It is not a real model and will not compile
*/
# also a comment
// also a comment
+functions {
+ void f1(void a, real b) {
+ return 1 / a;
+ }
+ real f2(int a, vector b, real c) {
+ return a + b + c;
+ }
+}
data {
// valid name
int abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abc;
@@ -20,6 +28,7 @@ data {
corr_matrix[3] grault;
cov_matrix[3] garply;
cholesky_factor_cov[3] waldo;
+ cholesky_factor_corr[3] waldo2;
real<lower=-1,upper=1> foo1;
real<lower=0> foo2;
@@ -87,6 +96,7 @@ model {
tmp / tmp;
tmp .* tmp;
tmp ./ tmp;
+ tmp ^ tmp;
! tmp;
- tmp;
+ tmp;
@@ -107,4 +117,3 @@ generated quantities {
real bar1;
bar1 <- foo + 1;
}
-