summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey B. Arnold <jeffrey.arnold@gmail.com>2013-04-15 20:40:51 -0400
committerJeffrey B. Arnold <jeffrey.arnold@gmail.com>2013-04-15 20:40:51 -0400
commita3aff098ebc657a5791f428328c088f2646c2e95 (patch)
treee9d2b8615d98e34b8ab639bd42beaf2749f05ef9
parent96e33477edcbf407db8a65234a6c0576f442fd77 (diff)
downloadpygments-a3aff098ebc657a5791f428328c088f2646c2e95.tar.gz
update StanLexer to Stan modeling language v1.3.0
-rw-r--r--pygments/lexers/_stan_builtins.py273
-rw-r--r--pygments/lexers/math.py20
2 files changed, 12 insertions, 281 deletions
diff --git a/pygments/lexers/_stan_builtins.py b/pygments/lexers/_stan_builtins.py
index 05432f85..ba370ffb 100644
--- a/pygments/lexers/_stan_builtins.py
+++ b/pygments/lexers/_stan_builtins.py
@@ -10,274 +10,13 @@ This file contains the names of functions for Stan used by
:license: BSD, see LICENSE for details.
"""
-CONSTANTS=[ u'e',
- u'epsilon',
- u'log10',
- u'log2',
- u'negative_epsilon',
- u'negative_infinity',
- u'not_a_number',
- u'pi',
- u'positive_infinity',
- u'sqrt2']
+KEYWORDS = [u'else', u'for', u'if', u'in', u'lower', u'lp__', u'print', u'upper', u'while']
-CPP_RESERVED=[ 'alignas',
- 'alignof',
- 'and',
- 'and_eq',
- 'asm',
- 'auto',
- 'bitand',
- 'bitor',
- 'bool',
- 'break',
- 'case',
- 'catch',
- 'char',
- 'char16_t',
- 'char32_t',
- 'class',
- 'compl',
- 'const',
- 'constexpr',
- 'const_cast',
- 'continue',
- 'decltype',
- 'default',
- 'delete',
- 'do',
- 'double',
- 'dynamic_cast',
- 'else',
- 'enum',
- 'explicit',
- 'export',
- 'extern',
- 'false',
- 'float',
- 'for',
- 'friend',
- 'goto',
- 'if',
- 'inline',
- 'int',
- 'long',
- 'mutable',
- 'namespace',
- 'new',
- 'noexcept',
- 'not',
- 'not_eq',
- 'nullptr',
- 'operator',
- 'or',
- 'or_eq',
- 'private',
- 'protected',
- 'public',
- 'register',
- 'reinterpret_cast',
- 'return',
- 'short',
- 'signed',
- 'sizeof',
- 'static',
- 'static_assert',
- 'static_cast',
- 'struct',
- 'switch',
- 'template',
- 'this',
- 'thread_local',
- 'throw',
- 'true',
- 'try',
- 'typedef',
- 'typeid',
- 'typename',
- 'union',
- 'unsigned',
- 'using',
- 'virtual',
- 'void',
- 'volatile',
- 'wchar_t',
- 'while',
- 'xor',
- 'xor_eq']
+TYPES = [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']
-FUNCTIONS=[ u'Phi',
- u'Phi_approx',
- u'abs',
- u'acos',
- u'acosh',
- u'asin',
- u'asinh',
- u'atan',
- u'atan2',
- u'atanh',
- u'bernoulli_log',
- u'bernoulli_logit_log',
- u'beta_binomial_log',
- u'beta_log',
- u'binary_log_loss',
- u'binomial_coefficient_log',
- u'binomial_log',
- u'binomial_logit_log',
- u'block',
- u'categorical_log',
- u'cauchy_log',
- u'cbrt',
- u'ceil',
- u'chi_square_log',
- u'cholesky_decompose',
- u'col',
- u'cols',
- 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'dims',
- u'dirichlet_log',
- u'dot_product',
- u'dot_self',
- u'double_exponential_log',
- u'eigenvalues_sym',
- u'eigenvectors_sym',
- u'erf',
- u'erfc',
- u'exp',
- u'exp2',
- u'expm1',
- u'exponential_cdf',
- u'exponential_log',
- u'fabs',
- u'fdim',
- u'floor',
- u'fma',
- u'fmax',
- u'fmin',
- u'fmod',
- u'gamma_log',
- u'hypergeometric_log',
- u'hypot',
- u'if_else',
- u'int_step',
- u'inv_chi_square_log',
- u'inv_cloglog',
- u'inv_gamma_log',
- u'inv_logit',
- u'inv_wishart_log',
- u'inverse',
- u'lbeta',
- u'lgamma',
- u'lkj_corr_cholesky_log',
- u'lkj_corr_log',
- u'lkj_cov_log',
- u'lmgamma',
- u'log',
- u'log1m',
- u'log1m_inv_logit',
- u'log1p',
- u'log1p_exp',
- u'log_determinant',
- u'log_inv_logit',
- u'log_sum_exp',
- u'logistic_log',
- u'logit',
- u'lognormal_cdf',
- u'lognormal_log',
- u'max',
- u'mdivide_left_tri_low',
- u'mdivide_right_tri_low',
- u'mean',
- u'min',
- u'multi_normal_cholesky_log',
- u'multi_normal_log',
- u'multi_normal_prec_log',
- u'multi_student_t_log',
- u'multinomial_log',
- u'multiply_log',
- u'multiply_lower_tri_self_transpose',
- u'neg_binomial_log',
- u'normal_cdf',
- u'normal_log',
- u'ordered_logistic_log',
- u'pareto_log',
- u'poisson_log',
- u'poisson_log_log',
- u'pow',
- u'prod',
- u'round',
- u'row',
- u'rows',
- u'scaled_inv_chi_square_log',
- u'sd',
- u'sin',
- u'singular_values',
- u'sinh',
- u'size',
- u'softmax',
- u'sqrt',
- u'square',
- u'step',
- u'student_t_log',
- u'sum',
- u'tan',
- u'tanh',
- u'tcrossprod',
- u'tgamma',
- u'trace',
- u'trunc',
- u'uniform_log',
- u'variance',
- u'weibull_cdf',
- u'weibull_log',
- u'wishart_log']
+FUNCTIONS = [u'Phi', u'Phi_approx', u'abs', u'acos', u'acosh', u'asin', u'asinh', u'atan', u'atan2', u'atanh', u'bernoulli_cdf', u'bernoulli_log', u'bernoulli_logit_log', u'bernoulli_rng', u'beta_binomial_cdf', u'beta_binomial_log', u'beta_binomial_rng', u'beta_cdf', u'beta_log', u'beta_rng', u'binary_log_loss', u'binomial_cdf', u'binomial_coefficient_log', u'binomial_log', u'binomial_logit_log', u'binomial_rng', u'block', u'categorical_log', u'categorical_rng', u'cauchy_cdf', u'cauchy_log', u'cauchy_rng', u'cbrt', u'ceil', u'chi_square_log', u'chi_square_rng', u'cholesky_decompose', u'col', u'cols', 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'dims', u'dirichlet_log', u'dirichlet_rng', u'dot_product', u'dot_self', u'double_exponential_log', u'double_exponential_rng', u'e', u'eigenvalues_sym', u'eigenvectors_sym', u'epsilon', u'erf', u'erfc', u'exp', u'exp2', u'exp_mod_normal_cdf', u'exp_mod_normal_log', u'exp_mod_normal_rng', u'expm1', u'exponential_cdf', u'exponential_log', u'exponential_rng', u'fabs', u'fdim', u'floor', u'fma', u'fmax', u'fmin', u'fmod', u'gamma_log', u'gamma_rng', u'gumbel_cdf', u'gumbel_log', u'gumbel_rng', u'hypergeometric_log', u'hypergeometric_rng', u'hypot', u'if_else', u'int_step', u'inv_chi_square_cdf', u'inv_chi_square_log', u'inv_chi_square_rng', u'inv_cloglog', u'inv_gamma_cdf', u'inv_gamma_log', u'inv_gamma_rng', u'inv_logit', u'inv_wishart_log', u'inv_wishart_rng', u'inverse', 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_inv_logit', u'log1p', u'log1p_exp', u'log2', u'log_determinant', u'log_inv_logit', u'log_sum_exp', u'logistic_cdf', u'logistic_log', u'logistic_rng', u'logit', u'lognormal_cdf', u'lognormal_log', u'lognormal_rng', u'max', u'mdivide_left_tri_low', u'mdivide_right_tri_low', u'mean', u'min', u'multi_normal_cholesky_log', 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_cdf', u'multinomial_log', u'multinomial_rng', u'multiply_log', u'multiply_lower_tri_self_transpose', u'neg_binomial_cdf', u'neg_binomial_log', u'neg_binomial_rng', u'negative_epsilon', u'negative_infinity', u'normal_cdf', u'normal_log', u'normal_rng', u'not_a_number', u'ordered_logistic_log', u'ordered_logistic_rng', u'owens_t', u'pareto_cdf', u'pareto_log', u'pareto_rng', u'pi', u'poisson_cdf', u'poisson_log', u'poisson_log_log', u'poisson_rng', u'positive_infinity', u'pow', u'prod', u'rep_array', u'rep_matrix', u'rep_row_vector', u'rep_vector', u'round', u'row', u'rows', u'scaled_inv_chi_square_cdf', u'scaled_inv_chi_square_log', u'scaled_inv_chi_square_rng', u'sd', u'sin', u'singular_values', u'sinh', u'size', u'skew_normal_cdf', u'skew_normal_log', u'skew_normal_rng', u'softmax', u'sqrt', u'sqrt2', u'square', u'step', u'student_t_cdf', u'student_t_log', u'student_t_rng', u'sum', u'tan', u'tanh', u'tcrossprod', u'tgamma', u'trace', u'trunc', u'uniform_log', u'uniform_rng', u'variance', u'weibull_cdf', u'weibull_log', u'weibull_rng', u'wishart_log', u'wishart_rng']
-DISTRIBUTIONS=[ u'bernoulli',
- u'bernoulli_logit',
- u'beta',
- u'beta_binomial',
- u'binomial',
- u'binomial_coefficient',
- u'binomial_logit',
- u'categorical',
- u'cauchy',
- u'chi_square',
- u'dirichlet',
- u'double_exponential',
- u'exponential',
- u'gamma',
- 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_normal',
- u'multi_normal_cholesky',
- u'multi_normal_prec',
- u'multi_student_t',
- u'multinomial',
- u'multiply',
- u'neg_binomial',
- u'normal',
- u'ordered_logistic',
- u'pareto',
- u'poisson',
- u'poisson_log',
- u'scaled_inv_chi_square',
- u'student_t',
- u'uniform',
- u'weibull',
- u'wishart']
+DISTRIBUTIONS = [u'bernoulli', u'bernoulli_logit', u'beta', u'beta_binomial', u'binomial', u'binomial_coefficient', u'binomial_logit', u'categorical', u'cauchy', u'chi_square', u'dirichlet', u'double_exponential', u'exp_mod_normal', u'exponential', u'gamma', 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_normal', u'multi_normal_cholesky', u'multi_normal_prec', u'multi_student_t', u'multinomial', u'multiply', u'neg_binomial', u'normal', u'ordered_logistic', u'pareto', u'poisson', u'poisson_log', u'scaled_inv_chi_square', u'skew_normal', u'student_t', u'uniform', u'weibull', u'wishart']
+
+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'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'return', 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'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 cd21aa1a..71f07037 100644
--- a/pygments/lexers/math.py
+++ b/pygments/lexers/math.py
@@ -15,7 +15,7 @@ from pygments.util import shebang_matches
from pygments.lexer import Lexer, RegexLexer, bygroups, include, \
combined, do_insertions
from pygments.token import Comment, String, Punctuation, Keyword, Name, \
- Operator, Number, Text, Generic, Error
+ Operator, Number, Text, Generic
from pygments.lexers.agile import PythonLexer
from pygments.lexers import _scilab_builtins
@@ -1302,9 +1302,9 @@ class JagsLexer(RegexLexer):
class StanLexer(RegexLexer):
"""Pygments Lexer for Stan models.
- The Stan modeling language is specified in the *Stan 1.1.1
+ The Stan modeling language is specified in the *Stan 1.3.0
Modeling Language Manual* `pdf
- <http://code.google.com/p/stan/downloads/detail?name=stan-reference-1.1.1.pdf>`_.
+ <http://code.google.com/p/stan/downloads/detail?name=stan-reference-1.3.0.pdf>`_.
*New in Pygments 1.6.*
"""
@@ -1313,12 +1313,6 @@ class StanLexer(RegexLexer):
aliases = ['stan']
filenames = ['*.stan']
- _KEYWORDS = ('for', 'in', 'while', 'if', 'else', 'print',
- 'T', 'lower', 'upper')
-
- _TYPES = ('int', 'real', 'vector', 'simplex', 'ordered', 'row_vector',
- 'matrix', 'corr_matrix', 'cov_matrix', 'positive_ordered')
-
tokens = {
'whitespace' : [
(r"\s+", Text),
@@ -1342,11 +1336,11 @@ class StanLexer(RegexLexer):
'model', r'generated\s+quantities')),
bygroups(Keyword.Namespace, Text, Punctuation)),
# Reserved Words
- (r'(%s)\b' % r'|'.join(_KEYWORDS), Keyword),
+ (r'(%s)\b' % r'|'.join(_stan_builtins.KEYWORDS), Keyword),
# Truncation
(r'T(?=\s*\[)', Keyword),
# Data types
- (r'(%s)\b' % r'|'.join(_TYPES), Keyword.Type),
+ (r'(%s)\b' % r'|'.join(_stan_builtins.TYPES), Keyword.Type),
# Punctuation
(r"[;:,\[\]()]", Punctuation),
# Builtin
@@ -1354,11 +1348,9 @@ class StanLexer(RegexLexer):
% r'|'.join(_stan_builtins.FUNCTIONS
+ _stan_builtins.DISTRIBUTIONS),
Name.Builtin),
- (r'(%s)(?=\s*\()'
- % r'|'.join(_stan_builtins.CONSTANTS), Keyword.Constant),
# Special names ending in __, like lp__
(r'[A-Za-z][A-Za-z0-9_]*__\b', Name.Builtin.Pseudo),
- ('%s\b' % r'|'.join(_stan_builtins.CPP_RESERVED), Keyword.Reserved),
+ ('(%s)\b' % r'|'.join(_stan_builtins.RESERVED), Keyword.Reserved),
# Regular variable names
(r'[A-Za-z][A-Za-z0-9_]*\b', Name),
# Real Literals