Jeffrey Arnold avatar Jeffrey Arnold committed aa19b6e

moved Stan builtins to new file; added functions for Stan v.1.0.2

Comments (0)

Files changed (2)

pygments/lexers/_stan_builtins.py

+# -*- coding: utf-8 -*-
+"""
+pygments.lexers._stan_builtins
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This file contains the names of functions for Stan used by
+``pygments.lexers.math.StanLexer.
+
+:copyright: Copyright 2012 by the Pygments team, see AUTHORS.
+:license: BSD, see LICENSE for details.
+"""
+
+CONSTANTS=[   'e',
+    'epsilon',
+    'log10',
+    'log2',
+    'negative_epsilon',
+    'negative_infinity',
+    'not_a_number',
+    'pi',
+    'positive_infinity',
+    'sqrt2']
+
+FUNCTIONS=[   'Phi',
+    'abs',
+    'acos',
+    'acosh',
+    'asin',
+    'asinh',
+    'atan',
+    'atan2',
+    'atanh',
+    'bernoulli_log',
+    'beta_binomial_log',
+    'beta_log',
+    'binary_log_loss',
+    'binomial_coefficient_log',
+    'categorical_log',
+    'cauchy_log',
+    'cbrt',
+    'ceil',
+    'chi_square_log',
+    'cholesky_decompose',
+    'col',
+    'cols',
+    'cos',
+    'cosh',
+    'determinant',
+    'diag_matrix',
+    'diagonal',
+    'dirichlet_log',
+    'dot_product',
+    'dot_self',
+    'double_exponential_log',
+    'eigenvalues',
+    'eigenvalues_sym',
+    'erf',
+    'erfc',
+    'exp',
+    'exp2',
+    'expm1',
+    'exponential_cdf',
+    'exponential_log',
+    'fabs',
+    'fdim',
+    'floor',
+    'fma',
+    'fmax',
+    'fmin',
+    'fmod',
+    'gamma_log',
+    'hypergeometric_log',
+    'hypot',
+    'if_else',
+    'int_step',
+    'inv_chi_square_log',
+    'inv_cloglog',
+    'inv_gamma_log',
+    'inv_logit',
+    'inv_wishart_log',
+    'inverse',
+    'lbeta',
+    'lgamma',
+    'lkj_corr_cholesky_log',
+    'lkj_corr_log',
+    'lkj_cov_log',
+    'lmgamma',
+    'log',
+    'log10',
+    'log1m',
+    'log1p',
+    'log1p_exp',
+    'log2',
+    'log_sum_exp',
+    'logistic_log',
+    'logit',
+    'lognormal_cdf',
+    'lognormal_log',
+    'max',
+    'mean',
+    'min',
+    'multi_normal_cholesky_log',
+    'multi_normal_log',
+    'multi_student_t_log',
+    'multinomial_log',
+    'multiply_log',
+    'multiply_lower_tri_self_transpose',
+    'neg_binomial_log',
+    'normal_cdf',
+    'normal_log',
+    'ordered_logistic_log',
+    'pareto_log',
+    'poisson_log',
+    'pow',
+    'prod',
+    'round',
+    'row',
+    'rows',
+    'scaled_inv_chi_square_log',
+    'sd',
+    'sin',
+    'singular_values',
+    'sinh',
+    'softmax',
+    'sqrt',
+    'square',
+    'step',
+    'student_t_log',
+    'sum',
+    'tan',
+    'tanh',
+    'tgamma',
+    'trace',
+    'trunc',
+    'uniform_log',
+    'variance',
+    'weibull_cdf',
+    'weibull_log',
+    'wishart_log']
+
+DISTRIBUTIONS=[   'bernoulli',
+    'beta',
+    'beta_binomial',
+    'categorical',
+    'cauchy',
+    'chi_square',
+    'dirichlet',
+    'double_exponential',
+    'exponential',
+    'gamma',
+    'hypergeometric',
+    'inv_chi_square',
+    'inv_gamma',
+    'inv_wishart',
+    'lkj_corr',
+    'lkj_corr_cholesky',
+    'lkj_cov',
+    'logistic',
+    'lognormal',
+    'multi_normal',
+    'multi_normal_cholesky',
+    'multi_student_t',
+    'multinomial',
+    'neg_binomial',
+    'normal',
+    'ordered_logistic',
+    'pareto',
+    'poisson',
+    'scaled_inv_chi_square',
+    'student_t',
+    'uniform',
+    'weibull',
+    'wishart']
+

pygments/lexers/math.py

 
 from pygments.lexers.agile import PythonLexer
 from pygments.lexers import _scilab_builtins
+from pygments.lexers import _stan_builtins
 
 __all__ = ['JuliaLexer', 'JuliaConsoleLexer', 'MuPADLexer', 'MatlabLexer',
            'MatlabSessionLexer', 'OctaveLexer', 'ScilabLexer', 'NumPyLexer',
     _TYPES = ('int', 'real', 'vector', 'simplex', 'ordered', 'row_vector',
               'matrix', 'corr_matrix', 'cov_matrix', 'positive_ordered')
 
-    # STAN 1.0 Manual, Chapter 20
-    _CONSTANTS = ['pi', 'e', 'sqrt2', 'log2', 'log10', 'nan', 'infinity',
-                  'epsilon', 'negative_epsilon']
-    _FUNCTIONS = ['abs', 'int_step', 'min', 'max',
-                  'if_else', 'step', 'fabs', 'fdim', 'fmin', 'fmax', 'fmod',
-                  'floor', 'ceil', 'round', 'trunc',
-                  'sqrt', 'cbrt', 'square', 'exp', 'exp2', 'expm1',
-                  'log', 'log2', 'log10', 'pow', 'logit', 'inv_logit',
-                  'inv_cloglog', 'hypot', 'cos', 'sin', 'tan', 'acos',
-                  'asin', 'atan', 'atan2', 'cosh', 'sinh', 'tanh',
-                  'acosh', 'asinh', 'atanh', 'erf', 'erfc', 'Phi',
-                  'log_loss', 'tgamma', 'lgamma', 'lmgamma', 'lbeta',
-                  'binomial_coefficient_log',
-                  'fma', 'multiply_log', 'log1p', 'log1m', 'log1p_exp',
-                  'log_sum_exp',
-                  'rows', 'cols',
-                  'dot_product', 'prod', 'mean', 'variance', 'sd',
-                  'diagonal', 'diag_matrix', 'col', 'row',
-                  'softmax', 'trace', 'determinant', 'inverse', 'eigenvalue',
-                  'eigenvalues_sym', 'cholesky', 'singular_values',
-                  '(log)?normal_p', 'exponential_p', 'gamma_p', 'weibull_p']
-    _DISTRIBUTIONS = ['bernoulli', 'bernoulli_logit', 'binomial',
-                      'beta_binomial', 'hypergeometric', 'categorical',
-                      'ordered_logistic', 'neg_binomial', 'poisson',
-                      'multinomial', 'normal', 'student_t',
-                      'cauchy', 'double_exponential', 'logistic',
-                      'lognormal', 'chi_square', 'inv_chi_square',
-                      'scaled_inv_chi_square', 'exponential',
-                      'gamma', 'inv_gamma', 'weibull', 'pareto',
-                      'beta', 'uniform', 'dirichlet', 'multi_normal',
-                      'multi_normal_cholesky', 'multi_student_t',
-                      'wishart', 'inv_wishart', 'lkj_cov',
-                      'lkj_corr_cholesky']
-
     tokens = {
         'whitespace' : [
             (r"\s+", Text),
             (r"[;:,\[\]()<>]", Punctuation),
             # Builtin
             (r'(%s)(?=\s*\()'
-             % r'|'.join(_FUNCTIONS
-                         + _DISTRIBUTIONS 
-                         + ['%s_log' % x for x in _DISTRIBUTIONS]),
+             % r'|'.join(_stan_builtins.FUNCTIONS
+                         + _stan_builtins.DISTRIBUTIONS),
              Name.Builtin),
             (r'(%s)(?=\s*\()'
-             % r'|'.join(_CONSTANTS),
-             Keyword.Constant),
+             % 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),
             # Regular variable names
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.