summaryrefslogtreecommitdiff
path: root/pygments/lexers/math.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/math.py')
-rw-r--r--pygments/lexers/math.py27
1 files changed, 12 insertions, 15 deletions
diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py
index 4dda7372..0b757e44 100644
--- a/pygments/lexers/math.py
+++ b/pygments/lexers/math.py
@@ -1300,8 +1300,11 @@ class JagsLexer(RegexLexer):
return 0
class StanLexer(RegexLexer):
- """
- Pygments Lexer for Stan models.
+ """Pygments Lexer for Stan models.
+
+ 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.3.0.pdf>`_.
*New in Pygments 1.6.*
"""
@@ -1310,13 +1313,6 @@ class StanLexer(RegexLexer):
aliases = ['stan']
filenames = ['*.stan']
- _RESERVED = ('for', 'in', 'while', 'repeat', 'until', 'if',
- 'then', 'else', 'true', 'false', 'T',
- 'lower', 'upper', 'print')
-
- _TYPES = ('int', 'real', 'vector', 'simplex', 'ordered', 'row_vector',
- 'matrix', 'corr_matrix', 'cov_matrix', 'positive_ordered')
-
tokens = {
'whitespace' : [
(r"\s+", Text),
@@ -1340,20 +1336,21 @@ class StanLexer(RegexLexer):
'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(_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),
+ (r"[;:,\[\]()]", Punctuation),
# Builtin
(r'(%s)(?=\s*\()'
% 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),
+ (r'(%s)\b' % r'|'.join(_stan_builtins.RESERVED), Keyword.Reserved),
# Regular variable names
(r'[A-Za-z][A-Za-z0-9_]*\b', Name),
# Real Literals
@@ -1365,7 +1362,7 @@ class StanLexer(RegexLexer):
# SLexer makes these tokens Operators.
(r'<-|~', Operator),
# Infix and prefix operators (and = )
- (r"\+|-|\.?\*|\.?/|\\|'|=", Operator),
+ (r"\+|-|\.?\*|\.?/|\\|'|==?|!=?|<=?|>=?|\|\||&&", Operator),
# Block delimiters
(r'[{}]', Punctuation),
]