summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey B. Arnold <jeffrey.arnold@gmail.com>2014-07-27 22:04:39 -0400
committerJeffrey B. Arnold <jeffrey.arnold@gmail.com>2014-07-27 22:04:39 -0400
commit04682453bfada53ed746b306f7a8c0553c8610ab (patch)
treee04e6e10acf5955de059c60e5ac5095eb7479194
parent76f1913368ca68af86dbdc235c5531ae209ea3a3 (diff)
downloadpygments-04682453bfada53ed746b306f7a8c0553c8610ab.tar.gz
Update StanLexer to support Stan v2.4.0
-rw-r--r--pygments/lexers/_stan_builtins.py15
-rw-r--r--pygments/lexers/math.py8
-rw-r--r--tests/examplefiles/example.stan8
3 files changed, 22 insertions, 9 deletions
diff --git a/pygments/lexers/_stan_builtins.py b/pygments/lexers/_stan_builtins.py
index e148724a..4c4a27c1 100644
--- a/pygments/lexers/_stan_builtins.py
+++ b/pygments/lexers/_stan_builtins.py
@@ -4,7 +4,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This file contains the names of functions for Stan used by
- ``pygments.lexers.math.StanLexer. This is for Stan language version 2.3.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.
@@ -14,12 +14,14 @@ KEYWORDS = [ u'else',
u'for',
u'if',
u'in',
+ u'increment_log_prob',
u'lp__',
u'print',
u'return',
u'while']
-TYPES = [ u'cholesky_factor_cov',
+TYPES = [ u'cholesky_factor_corr',
+ u'cholesky_factor_cov',
u'corr_matrix',
u'cov_matrix',
u'int',
@@ -155,7 +157,6 @@ FUNCTIONS = [ u'Phi',
u'hypergeometric_rng',
u'hypot',
u'if_else',
- u'increment_log_prob',
u'int_step',
u'inv',
u'inv_chi_square_ccdf_log',
@@ -178,8 +179,11 @@ FUNCTIONS = [ u'Phi',
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',
@@ -217,6 +221,7 @@ FUNCTIONS = [ u'Phi',
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',
@@ -337,6 +342,7 @@ FUNCTIONS = [ u'Phi',
u'uniform_rng',
u'variance',
u'von_mises_log',
+ u'von_mises_rng',
u'weibull_ccdf_log',
u'weibull_cdf',
u'weibull_cdf_log',
@@ -367,6 +373,8 @@ DISTRIBUTIONS = [ u'bernoulli',
u'inv_gamma',
u'inv_wishart',
u'lkj_corr',
+ u'lkj_corr_cholesky',
+ u'lkj_cov',
u'logistic',
u'lognormal',
u'multi_gp',
@@ -473,6 +481,7 @@ RESERVED = [ u'alignas',
u'using',
u'var',
u'virtual',
+ u'void',
u'volatile',
u'wchar_t',
u'xor',
diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py
index d005c0e8..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.3.0*,
- `pdf <https://github.com/stan-dev/stan/releases/download/v2.3.0/stan-reference-2.3.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
"""
@@ -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 341089ae..716b4d12 100644
--- a/tests/examplefiles/example.stan
+++ b/tests/examplefiles/example.stan
@@ -6,9 +6,12 @@ It is not a real model and will not compile
# also a comment
// also a comment
functions {
- void func1(real a) {
+ void f1(void a, real b) {
return 1 / a;
}
+ real f2(int a, vector b, real c) {
+ return a + b + c;
+ }
}
data {
// valid name
@@ -25,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;
@@ -92,6 +96,7 @@ model {
tmp / tmp;
tmp .* tmp;
tmp ./ tmp;
+ tmp ^ tmp;
! tmp;
- tmp;
+ tmp;
@@ -112,4 +117,3 @@ generated quantities {
real bar1;
bar1 <- foo + 1;
}
-