Commits

Jeffrey Arnold committed 64c8dc1

StanLexer: added new functions, operators, and keywords in version 1.1.0

Comments (0)

Files changed (2)

pygments/lexers/_stan_builtins.py

     'beta_log',
     'binary_log_loss',
     'binomial_coefficient_log',
+    'block',
     'categorical_log',
     'cauchy_log',
     'cbrt',
     'cols',
     'cos',
     'cosh',
+    'cumulative_sum',
     'determinant',
     'diag_matrix',
     'diagonal',
     'log1p',
     'log1p_exp',
     'log2',
+    'log_inv_logit',
+    'log1m_inv_logit',
     'log_sum_exp',
     'logistic_log',
     'logit',
     'ordered_logistic_log',
     'pareto_log',
     'poisson_log',
+    'poisson_log_log',
     'pow',
     'prod',
     'round',
     'ordered_logistic',
     'pareto',
     'poisson',
+    'poisson_log',
     'scaled_inv_chi_square',
     'student_t',
     'uniform',

pygments/lexers/math.py

 
 class StanLexer(RegexLexer):
     """
-    Pygments Lexer for Stan models.
+    Pygments Lexer for Stan models (v. 1.1.0)
 
     *New in Pygments 1.6.*
     """
     aliases = ['stan']
     filenames = ['*.stan']
 
-    _RESERVED = ('for', 'in', 'while', 'repeat', 'until', 'if',
-                 'then', 'else', 'true', 'false', 'T',
-                 'lower', 'upper', 'print')
-
+    _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')
 
                         'model', r'generated\s+quantities')),
              bygroups(Keyword.Namespace, Text, Punctuation)),
             # Reserved Words
-            (r'(%s)\b' % r'|'.join(_RESERVED), Keyword.Reserved),
+            (r'(%s)\b' % r'|'.join(_KEYWORDS), Keyword),
             # Data types
             (r'(%s)\b' % r'|'.join(_TYPES), Keyword.Type),
             # Punctuation
-            (r"[;:,\[\]()<>]", Punctuation),
+            (r"[;:,\[\]()]", Punctuation),
             # Builtin
             (r'(%s)(?=\s*\()'
              % r'|'.join(_stan_builtins.FUNCTIONS
             # SLexer makes these tokens Operators.
             (r'<-|~', Operator),
             # Infix and prefix operators (and = )
-            (r"\+|-|\.?\*|\.?/|\\|'|=", Operator),
+            (r"\+|-|\.?\*|\.?/|\\|'|==?|!=?|<=?|>=?|\|\||&&", Operator),
             # Block delimiters
             (r'[{}]', Punctuation),
             ]