summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Van Doren <thomas.vandoren@gmail.com>2013-11-25 20:50:31 -0800
committerThomas Van Doren <thomas.vandoren@gmail.com>2013-11-25 20:50:31 -0800
commit8f979cf8c74adaf11af453ad08fc86dec42fedfe (patch)
tree58ea2b46a1d4d6b9f787d0d10b01d0594b6456cc
parentcc0ef1938aefd9e093e2f846c561e227671f80c8 (diff)
downloadpygments-8f979cf8c74adaf11af453ad08fc86dec42fedfe.tar.gz
Fix class and proc names in ChapelLexer.
Also adds class, unions, records, and modules to the example file.
-rw-r--r--pygments/lexers/compiled.py16
-rw-r--r--tests/examplefiles/99_bottles_of_beer.chpl50
2 files changed, 58 insertions, 8 deletions
diff --git a/pygments/lexers/compiled.py b/pygments/lexers/compiled.py
index 4aff2f5a..19946100 100644
--- a/pygments/lexers/compiled.py
+++ b/pygments/lexers/compiled.py
@@ -3741,19 +3741,19 @@ class ChapelLexer(RegexLexer):
(r'//(.*?)\n', Comment.Single),
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
- (r'(config|const|in|inout|out|param|proc|ref|type|var)\b',
+ (r'(config|const|in|inout|out|param|ref|type|var)\b',
Keyword.Declaration),
+ (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'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|'
'subdomain|sync|then|use|when|where|while|yield|zip)\b',
Keyword),
- (r'(false|nil|true)\b', Keyword.Constant),
- (r'(bool|complex|imag|int|opaque|range|real|string|uint)\b',
- Keyword.Type),
- (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
- (r'(module|record|union)(\s+)', bygroups(Keyword, Text), 'names'),
+ (r'(proc)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'procname'),
+ (r'(class|module|record|union)(\s+)', bygroups(Keyword, Text), 'classname'),
# imaginary integers
(r'\d+i', Number),
@@ -3791,7 +3791,7 @@ class ChapelLexer(RegexLexer):
'classname': [
(r'[a-zA-Z_][a-zA-Z0-9_$]*', Name.Class, '#pop'),
],
- 'names': [
- (r'[a-zA-Z_][a-zA-Z0-9_$]*', Name, '#pop'),
+ 'procname': [
+ (r'[a-zA-Z_][a-zA-Z0-9_$]*', Name.Function, '#pop'),
],
}
diff --git a/tests/examplefiles/99_bottles_of_beer.chpl b/tests/examplefiles/99_bottles_of_beer.chpl
index b3a31ab1..f73be7b1 100644
--- a/tests/examplefiles/99_bottles_of_beer.chpl
+++ b/tests/examplefiles/99_bottles_of_beer.chpl
@@ -66,3 +66,53 @@ proc computeAction(bottleNum) {
return if (bottleNum == 0) then "Go to the store and buy some more, "
else "Take one down and pass it around, ";
}
+
+
+// Modules...
+module M1 {
+ var x = 10;
+}
+
+module M2 {
+ use M1;
+ proc main() {
+ writeln("M2 -> M1 -> x " + x);
+ }
+}
+
+
+// Classes, records, unions...
+const PI: real = 3.14159;
+
+record Point {
+ var x, y: real;
+}
+var p: Point;
+writeln("Distance from origin: " + sqrt(p.x ** 2 + p.y ** 2));
+p = new Point(1.0, 2.0);
+writeln("Distance from origin: " + sqrt(p.x ** 2 + p.y ** 2));
+
+class Circle {
+ var p: Point;
+ var r: real;
+}
+var c = new Circle(r=2.0);
+proc Circle.area()
+ return PI * r ** 2;
+writeln("Area of circle: " + c.area());
+
+class Oval: Circle {
+ var r2: real;
+}
+proc Oval.area()
+ return PI * r * r2;
+
+delete c;
+c = nil;
+c = new Oval(r=1.0, r2=2.0);
+writeln("Area of oval: " + c.area());
+
+union U {
+ var i: int;
+ var r: real;
+}