diff options
author | Jeffrey B. Arnold <jeffrey.arnold@gmail.com> | 2012-08-22 03:45:15 -0400 |
---|---|---|
committer | Jeffrey B. Arnold <jeffrey.arnold@gmail.com> | 2012-08-22 03:45:15 -0400 |
commit | aa10b337c917219367b3b29f7dc4157e1f45b292 (patch) | |
tree | b323f77ac29f6efac42a304c1454c541d5f26623 | |
parent | af52e156fc2567f3da307ce1cbc3bb596a4a1625 (diff) | |
download | pygments-aa10b337c917219367b3b29f7dc4157e1f45b292.tar.gz |
StanLexer: accounted for new bound syntax
-rw-r--r-- | pygments/lexers/math.py | 17 | ||||
-rw-r--r-- | tests/examplefiles/example.stan | 10 |
2 files changed, 15 insertions, 12 deletions
diff --git a/pygments/lexers/math.py b/pygments/lexers/math.py index d9f679da..40663fd5 100644 --- a/pygments/lexers/math.py +++ b/pygments/lexers/math.py @@ -1089,7 +1089,7 @@ class SLexer(RegexLexer): class BugsLexer(RegexLexer): """ - Pygments Lexer for Stan models. + Pygments Lexer for OpenBugs and WinBugs models. *New in Pygments 1.6.* """ @@ -1307,7 +1307,7 @@ class StanLexer(RegexLexer): '(log)?normal_p', 'exponential_p', 'gamma_p', 'weibull_p'] _DISTRIBUTIONS = ['bernoulli', 'bernoulli_logit', 'binomial', 'beta_binomial', 'hypergeometric', 'categorical', - 'ordered_logistic', 'negative_binomial', 'poisson', + 'ordered_logistic', 'neg_binomial', 'poisson', 'multinomial', 'normal', 'student_t', 'cauchy', 'double_exponential', 'logistic', 'lognormal', 'chi_square', 'inv_chi_square', @@ -1323,7 +1323,6 @@ class StanLexer(RegexLexer): (r"\s+", Text), ], 'comments' : [ - # do not use stateful comments (r'(?s)/\*.*?\*/', Comment.Multiline), # Comments (r'(//|#).*$', Comment.Single), @@ -1344,7 +1343,7 @@ class StanLexer(RegexLexer): # Data types (r'(%s)\b' % r'|'.join(_TYPES), Keyword.Type), # Punctuation - (r"[;:,\[\]()]", Punctuation), + (r"[;:,\[\]()<>]", Punctuation), # Builtin (r'(%s)(?=\s*\()' % r'|'.join(_FUNCTIONS @@ -1355,9 +1354,9 @@ class StanLexer(RegexLexer): % r'|'.join(_CONSTANTS), Keyword.Constant), # Special names ending in __, like lp__ - (r'\b[A-Za-z][A-Za-z0-9_]*__\b', Name.Builtin.Pseudo), + (r'[A-Za-z][A-Za-z0-9_]*__\b', Name.Builtin.Pseudo), # Regular variable names - (r'\b[A-Za-z][A-Za-z0-9_]*\b', Name), + (r'[A-Za-z][A-Za-z0-9_]*\b', Name), # Real Literals (r'-?[0-9]+(\.[0-9]+)?[eE]-?[0-9]+', Number.Float), (r'-?[0-9]*\.[0-9]*', Number.Float), @@ -1365,9 +1364,9 @@ class StanLexer(RegexLexer): (r'-?[0-9]+', Number.Integer), # Assignment operators # SLexer makes these tokens Operators. - (r'(<-|~)', Operator), - # Infix and prefix operators - (r"(\+|-|\.?\*|\.?/|\\|')", Operator), + (r'<-|~', Operator), + # Infix and prefix operators (and = ) + (r"\+|-|\.?\*|\.?/|\\|'|=", Operator), # Block delimiters (r'[{}]', Punctuation), ] diff --git a/tests/examplefiles/example.stan b/tests/examplefiles/example.stan index 3d88bb5e..e86ae42f 100644 --- a/tests/examplefiles/example.stan +++ b/tests/examplefiles/example.stan @@ -19,9 +19,13 @@ data { corr_matrix[3] grault; cov_matrix[3] garply; + real<lower=-1,upper=1> foo1; + real<lower=0> foo2; + real<upper=0> foo3; + // bad names // includes . - real foo.; + // real foo.; // beings with number //real 0foo; // begins with _ @@ -71,8 +75,8 @@ model { } generated quantities { - real foo1; - foo1 <- foo + 1; + real bar1; + bar1 <- foo + 1; } ## Baddness |