summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatth?us G. Chajdas <dev@anteru.net>2018-12-23 13:37:14 +0100
committerMatth?us G. Chajdas <dev@anteru.net>2018-12-23 13:37:14 +0100
commit899884637800cbe1b2c913647016bf98a54cbb20 (patch)
treef741a86954b4a6319a9eb447db5ba5193cbc6188
parent85bef47b4223cdbeaa6251cc69d5ede117b9c0f3 (diff)
downloadpygments-899884637800cbe1b2c913647016bf98a54cbb20.tar.gz
Fix Stan lexer changes eating whitespace, fix typos in example file.
-rw-r--r--CHANGES1
-rw-r--r--pygments/lexers/modeling.py10
-rw-r--r--tests/examplefiles/example.stan4
3 files changed, 8 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index 6d6f463a..59351ac7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -18,6 +18,7 @@ Version 2.4.0
- Updated lexers:
+ * Stan (PR#774)
* Terraform (PR#787)
- Change ANSI color names (PR#777)
diff --git a/pygments/lexers/modeling.py b/pygments/lexers/modeling.py
index 49d98d1b..481cce38 100644
--- a/pygments/lexers/modeling.py
+++ b/pygments/lexers/modeling.py
@@ -13,7 +13,7 @@ import re
from pygments.lexer import RegexLexer, include, bygroups, using, default
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
- Number, Punctuation
+ Number, Punctuation, Whitespace
from pygments.lexers.html import HtmlLexer
from pygments.lexers import _stan_builtins
@@ -326,14 +326,14 @@ class StanLexer(RegexLexer):
(r'(%s)\b' % r'|'.join(_stan_builtins.TYPES), Keyword.Type),
# < should be punctuation, but elsewhere I can't tell if it is in
# a range constraint
- (r'(<)\s*(upper|lower)\s*(=)', bygroups(Operator, Keyword, Punctuation)),
- (r'(,)\s*(upper)\s*(=)', bygroups(Punctuation, Keyword, Punctuation)),
+ (r'(<)(\s*)(upper|lower)(\s*)(=)', bygroups(Operator, Whitespace, Keyword, Whitespace, Punctuation)),
+ (r'(,)(\s*)(upper)(\s*)(=)', bygroups(Punctuation, Whitespace, Keyword, Whitespace, Punctuation)),
# Punctuation
(r"[;,\[\]()]", Punctuation),
# Builtin
(r'(%s)(?=\s*\()' % '|'.join(_stan_builtins.FUNCTIONS), Name.Builtin),
- (r'(~)\s*(%s)(?=\s*\()' % '|'.join(_stan_builtins.DISTRIBUTIONS),
- bygroups(Operator, Name.Builtin)),
+ (r'(~)(\s*)(%s)(?=\s*\()' % '|'.join(_stan_builtins.DISTRIBUTIONS),
+ bygroups(Operator, Whitespace, Name.Builtin)),
# Special names ending in __, like lp__
(r'[A-Za-z]\w*__\b', Name.Builtin.Pseudo),
(r'(%s)\b' % r'|'.join(_stan_builtins.RESERVED), Keyword.Reserved),
diff --git a/tests/examplefiles/example.stan b/tests/examplefiles/example.stan
index 69c9ac70..03b7b1b5 100644
--- a/tests/examplefiles/example.stan
+++ b/tests/examplefiles/example.stan
@@ -16,7 +16,7 @@ functions {
data {
// valid name
int abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abc;
- // all types should be highlighed
+ // all types should be highlighted
int a3;
real foo[2];
vector[3] bar;
@@ -48,7 +48,7 @@ transformed data {
thud <- -12309865;
// ./ and .* should be recognized as operators
grault2 <- grault .* garply ./ garply;
- // ' and \ should be regognized as operators
+ // ' and \ should be recognized as operators
qux2 <- qux' \ bar;
}