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.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py
index 537c6d0e..0b757e44 100644
--- a/pygments/lexers/math.py
+++ b/pygments/lexers/math.py
@@ -59,7 +59,7 @@ class JuliaLexer(RegexLexer):
(r'(begin|while|for|in|return|break|continue|'
r'macro|quote|let|if|elseif|else|try|catch|end|'
r'bitstype|ccall|do|using|module|import|export|'
- r'importall|baremodule)\b', Keyword),
+ r'importall|baremodule|immutable)\b', Keyword),
(r'(local|global|const)\b', Keyword.Declaration),
(r'(Bool|Int|Int8|Int16|Int32|Int64|Uint|Uint8|Uint16|Uint32|Uint64'
r'|Float32|Float64|Complex64|Complex128|Any|Nothing|None)\b',
@@ -99,11 +99,17 @@ class JuliaLexer(RegexLexer):
(r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
# numbers
+ (r'(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?', Number.Float),
(r'(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?', Number.Float),
+ (r'\d+(_\d+)+[eEf][+-]?[0-9]+', Number.Float),
(r'\d+[eEf][+-]?[0-9]+', Number.Float),
+ (r'0b[01]+(_[01]+)+', Number.Binary),
(r'0b[01]+', Number.Binary),
+ (r'0o[0-7]+(_[0-7]+)+', Number.Oct),
(r'0o[0-7]+', Number.Oct),
+ (r'0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+', Number.Hex),
(r'0x[a-fA-F0-9]+', Number.Hex),
+ (r'\d+(_\d+)+', Number.Integer),
(r'\d+', Number.Integer)
],
@@ -1294,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.*
"""
@@ -1304,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),
@@ -1334,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
@@ -1359,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),
]