summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Van Doren <thomas.vandoren@gmail.com>2014-07-03 15:00:21 -0700
committerThomas Van Doren <thomas.vandoren@gmail.com>2014-07-03 15:00:21 -0700
commita0f35d17627456cdc8e608cc0dc2fa6a32dec6d0 (patch)
tree37fbd41e68d879b9169617542200dd8dd7f9b7d9
parent2f1c724903db081f1d6941d366ca95070049e94b (diff)
downloadpygments-a0f35d17627456cdc8e608cc0dc2fa6a32dec6d0.tar.gz
Update ChapelLexer prior to Pygments 2.0 release.
* Adds `align`, `noinit`, and `pragma` keywords. * Updates decimal integer definition to allow any number of leading zeros, as per spec. * Adds `<~>` operator, which is used for convenience when reading or writing input and output.
-rw-r--r--pygments/lexers/compiled.py10
-rw-r--r--tests/examplefiles/99_bottles_of_beer.chpl31
2 files changed, 36 insertions, 5 deletions
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 25c7a4d8..041d56e2 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -3920,10 +3920,10 @@ class ChapelLexer(RegexLexer):
(r'(false|nil|true)\b', Keyword.Constant),
(r'(bool|complex|imag|int|opaque|range|real|string|uint)\b',
Keyword.Type),
- (r'(atomic|begin|break|by|cobegin|coforall|continue|iter|'
+ (r'(align|atomic|begin|break|by|cobegin|coforall|continue|'
r'delete|dmapped|do|domain|else|enum|export|extern|for|forall|'
- r'if|index|inline|label|lambda|let|local|new|on|otherwise|'
- r'reduce|return|scan|select|serial|single|sparse|'
+ r'if|index|inline|iter|label|lambda|let|local|new|noinit|on|'
+ r'otherwise|pragma|reduce|return|scan|select|serial|single|sparse|'
r'subdomain|sync|then|use|when|where|while|yield|zip)\b',
Keyword),
(r'(proc)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'procname'),
@@ -3947,14 +3947,14 @@ class ChapelLexer(RegexLexer):
# -- hex
(r'0[xX][0-9a-fA-F]+', Number.Hex),
# -- decimal
- (r'(0|[1-9][0-9]*)', Number.Integer),
+ (r'[0-9]+', Number.Integer),
# strings
(r'["\'](\\\\|\\"|[^"\'])*["\']', String),
# tokens
(r'(=|\+=|-=|\*=|/=|\*\*=|%=|&=|\|=|\^=|&&=|\|\|=|<<=|>>=|'
- r'<=>|\.\.|by|#|\.\.\.|'
+ r'<=>|<~>|\.\.|by|#|\.\.\.|'
r'&&|\|\||!|&|\||\^|~|<<|>>|'
r'==|!=|<=|>=|<|>|'
r'[+\-*/%]|\*\*)', Operator),
diff --git a/tests/examplefiles/99_bottles_of_beer.chpl b/tests/examplefiles/99_bottles_of_beer.chpl
index f73be7b1..10c3e48a 100644
--- a/tests/examplefiles/99_bottles_of_beer.chpl
+++ b/tests/examplefiles/99_bottles_of_beer.chpl
@@ -112,7 +112,38 @@ c = nil;
c = new Oval(r=1.0, r2=2.0);
writeln("Area of oval: " + c.area());
+// This is a valid decimal integer:
+var x = 0000000000012;
+
union U {
var i: int;
var r: real;
}
+
+// chapel ranges are awesome.
+var r1 = 1..10, // 1 2 3 4 5 6 7 8 9 10
+ r2 = 10..1, // no values in this range
+ r3 = 1..10 by -1, // 10 9 8 7 6 5 4 3 2 1
+ r4 = 1..10 by 2, // 1 3 5 7 9
+ r5 = 1..10 by 2 align 0, // 2 4 6 8 10
+ r6 = 1..10 by 2 align 2, // 2 4 6 8 10
+ r7 = 1..10 # 3, // 1 2 3
+ r8 = 1..10 # -2, // 9 10
+ r9 = 1..100 # 10 by 2, // 1 3 5 7 9
+ ra = 1..100 by 2 # 10, // 1 3 5 7 9 11 13 15 17 19
+ rb = 1.. # 100 by 10; // 1 11 21 31 41 51 61 71 81 91
+
+// create a variable with default initialization
+var myVarWithoutInit: real = noinit;
+myVarWithoutInit = 1.0;
+
+// Chapel has <~> operator for read and write I/O operations.
+class IntPair {
+ var x: int;
+ var y: int;
+ proc readWriteThis(f) {
+ f <~> x <~> new ioLiteral(",") <~> y <~> new ioNewline();
+ }
+}
+var ip = new IntPair(17,2);
+write(ip);