---input---
/***********************************************************************
 * Chapel implementation of "99 bottles of beer"
 *
 * by Brad Chamberlain and Steve Deitz
 * 07/13/2006 in Knoxville airport while waiting for flight home from
 *            HPLS workshop
 * compiles and runs with chpl compiler version 1.12.0
 * for more information, contact: chapel_info@cray.com
 * 
 *
 * Notes: 
 * o as in all good parallel computations, boundary conditions
 *   constitute the vast bulk of complexity in this code (invite Brad to
 *   tell you about his zany boundary condition simplification scheme)
 * o uses type inference for variables, arguments
 * o relies on integer->string coercions
 * o uses named argument passing (for documentation purposes only)
 ***********************************************************************/
 
// allow executable command-line specification of number of bottles 
// (e.g., ./a.out -snumBottles=999999)
config const numBottles = 99;
const numVerses = numBottles+1;
 
// a domain to describe the space of lyrics
var LyricsSpace: domain(1) = {1..numVerses};
 
// array of lyrics
var Lyrics: [LyricsSpace] string;
 
// parallel computation of lyrics array
[verse in LyricsSpace] Lyrics(verse) = computeLyric(verse);
 
// as in any good parallel language, I/O to stdout is serialized.
// (Note that I/O to a file could be parallelized using a parallel
// prefix computation on the verse strings' lengths with file seeking)
writeln(Lyrics);
 
 
// HELPER FUNCTIONS:
 
proc computeLyric(verseNum) {
  var bottleNum = numBottles - (verseNum - 1);
  var nextBottle = (bottleNum + numVerses - 1)%numVerses;
  return "\n" // disguise space used to separate elements in array I/O
    + describeBottles(bottleNum, startOfVerse=true) + " on the wall, "
    + describeBottles(bottleNum) + ".\n"
    + computeAction(bottleNum)
    + describeBottles(nextBottle) + " on the wall.\n";
}
 
 
proc describeBottles(bottleNum, startOfVerse:bool = false) {
  // NOTE: bool should not be necessary here (^^^^); working around bug
  var bottleDescription = if (bottleNum) then bottleNum:string 
    else (if startOfVerse then "N" 
            else "n") 
           + "o more";
  return bottleDescription 
    + " bottle" + (if (bottleNum == 1) then "" else "s") 
    + " of beer";
}
 
 
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;

  var y = 13.0;
}

module M2 {
  use M1 except y;
  use M1 only y;
  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());

// 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);

var targetDom = {1..10},
  target: [targetDom] int;
coforall i in targetDom with (ref target) {
  target[i] = i ** 3;
}

var wideOpen = 0o777,
  mememe = 0o600,
  clique_y = 0O660,
  zeroOct = 0o0,
  minPosOct = 0O1;

private module M3 {
  private proc foo() {

  }

  private iter bar() {
    for i in 1..10 {
      yield i;
    }
  }

  private var x: int;

}
prototype module X {

  proc f() throws {
    throw new Error();
  }

  proc g() {
    try {
      f();
      try! f();
    } catch e {
      writeln("Caught ", e);
    }
  }

  proc int.add() { }

  g();

  override proc test() throws {
    var a = new borrowed IntPair();
    var b = new owned IntPair();
    var c = new shared IntPair();
    throw new unmanaged Error();
  }
}


---tokens---
'/***********************************************************************\n * Chapel implementation of "99 bottles of beer"\n *\n * by Brad Chamberlain and Steve Deitz\n * 07/13/2006 in Knoxville airport while waiting for flight home from\n *            HPLS workshop\n * compiles and runs with chpl compiler version 1.12.0\n * for more information, contact: chapel_info@cray.com\n * \n *\n * Notes: \n * o as in all good parallel computations, boundary conditions\n *   constitute the vast bulk of complexity in this code (invite Brad to\n *   tell you about his zany boundary condition simplification scheme)\n * o uses type inference for variables, arguments\n * o relies on integer->string coercions\n * o uses named argument passing (for documentation purposes only)\n ***********************************************************************/' Comment.Multiline
'\n'          Text

' \n'         Text

'// allow executable command-line specification of number of bottles \n' Comment.Single

'// (e.g., ./a.out -snumBottles=999999)\n' Comment.Single

'config'      Keyword.Declaration
' '           Text
'const'       Keyword.Declaration
' '           Text
'numBottles'  Name.Other
' '           Text
'='           Operator
' '           Text
'99'          Literal.Number.Integer
';'           Punctuation
'\n'          Text

'const'       Keyword.Declaration
' '           Text
'numVerses'   Name.Other
' '           Text
'='           Operator
' '           Text
'numBottles'  Name.Other
'+'           Operator
'1'           Literal.Number.Integer
';'           Punctuation
'\n'          Text

' \n'         Text

'// a domain to describe the space of lyrics\n' Comment.Single

'var'         Keyword.Declaration
' '           Text
'LyricsSpace' Name.Other
':'           Punctuation
' '           Text
'domain'      Keyword
'('           Punctuation
'1'           Literal.Number.Integer
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'{'           Punctuation
'1'           Literal.Number.Integer
'..'          Operator
'numVerses'   Name.Other
'}'           Punctuation
';'           Punctuation
'\n'          Text

' \n'         Text

'// array of lyrics\n' Comment.Single

'var'         Keyword.Declaration
' '           Text
'Lyrics'      Name.Other
':'           Punctuation
' '           Text
'['           Punctuation
'LyricsSpace' Name.Other
']'           Punctuation
' '           Text
'string'      Keyword.Type
';'           Punctuation
'\n'          Text

' \n'         Text

'// parallel computation of lyrics array\n' Comment.Single

'['           Punctuation
'verse'       Name.Other
' '           Text
'in'          Keyword.Declaration
' '           Text
'LyricsSpace' Name.Other
']'           Punctuation
' '           Text
'Lyrics'      Name.Other
'('           Punctuation
'verse'       Name.Other
')'           Punctuation
' '           Text
'='           Operator
' '           Text
'computeLyric' Name.Other
'('           Punctuation
'verse'       Name.Other
')'           Punctuation
';'           Punctuation
'\n'          Text

' \n'         Text

'// as in any good parallel language, I/O to stdout is serialized.\n' Comment.Single

'// (Note that I/O to a file could be parallelized using a parallel\n' Comment.Single

"// prefix computation on the verse strings' lengths with file seeking)\n" Comment.Single

'writeln'     Name.Other
'('           Punctuation
'Lyrics'      Name.Other
')'           Punctuation
';'           Punctuation
'\n'          Text

' \n \n'      Text

'// HELPER FUNCTIONS:\n' Comment.Single

' \n'         Text

'proc'        Keyword
' '           Text
'computeLyric' Name.Function
'('           Punctuation
'verseNum'    Name.Other
')'           Punctuation
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'bottleNum'   Name.Other
' '           Text
'='           Operator
' '           Text
'numBottles'  Name.Other
' '           Text
'-'           Operator
' '           Text
'('           Punctuation
'verseNum'    Name.Other
' '           Text
'-'           Operator
' '           Text
'1'           Literal.Number.Integer
')'           Punctuation
';'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'nextBottle'  Name.Other
' '           Text
'='           Operator
' '           Text
'('           Punctuation
'bottleNum'   Name.Other
' '           Text
'+'           Operator
' '           Text
'numVerses'   Name.Other
' '           Text
'-'           Operator
' '           Text
'1'           Literal.Number.Integer
')'           Punctuation
'%'           Operator
'numVerses'   Name.Other
';'           Punctuation
'\n'          Text

'  '          Text
'return'      Keyword
' '           Text
'"\\n"'       Literal.String.Double
' '           Text
'// disguise space used to separate elements in array I/O\n' Comment.Single

'    '        Text
'+'           Operator
' '           Text
'describeBottles' Name.Other
'('           Punctuation
'bottleNum'   Name.Other
','           Punctuation
' '           Text
'startOfVerse' Name.Other
'='           Operator
'true'        Keyword.Constant
')'           Punctuation
' '           Text
'+'           Operator
' '           Text
'" on the wall, "' Literal.String.Double
'\n'          Text

'    '        Text
'+'           Operator
' '           Text
'describeBottles' Name.Other
'('           Punctuation
'bottleNum'   Name.Other
')'           Punctuation
' '           Text
'+'           Operator
' '           Text
'".\\n"'      Literal.String.Double
'\n'          Text

'    '        Text
'+'           Operator
' '           Text
'computeAction' Name.Other
'('           Punctuation
'bottleNum'   Name.Other
')'           Punctuation
'\n'          Text

'    '        Text
'+'           Operator
' '           Text
'describeBottles' Name.Other
'('           Punctuation
'nextBottle'  Name.Other
')'           Punctuation
' '           Text
'+'           Operator
' '           Text
'" on the wall.\\n"' Literal.String.Double
';'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

' \n \n'      Text

'proc'        Keyword
' '           Text
'describeBottles' Name.Function
'('           Punctuation
'bottleNum'   Name.Other
','           Punctuation
' '           Text
'startOfVerse' Name.Other
':'           Punctuation
'bool'        Keyword.Type
' '           Text
'='           Operator
' '           Text
'false'       Keyword.Constant
')'           Punctuation
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'// NOTE: bool should not be necessary here (^^^^); working around bug\n' Comment.Single

'  '          Text
'var'         Keyword.Declaration
' '           Text
'bottleDescription' Name.Other
' '           Text
'='           Operator
' '           Text
'if'          Keyword
' '           Text
'('           Punctuation
'bottleNum'   Name.Other
')'           Punctuation
' '           Text
'then'        Keyword
' '           Text
'bottleNum'   Name.Other
':'           Punctuation
'string'      Keyword.Type
' \n    '     Text
'else'        Keyword
' '           Text
'('           Punctuation
'if'          Keyword
' '           Text
'startOfVerse' Name.Other
' '           Text
'then'        Keyword
' '           Text
'"N"'         Literal.String.Double
' \n            ' Text
'else'        Keyword
' '           Text
'"n"'         Literal.String.Double
')'           Punctuation
' \n           ' Text
'+'           Operator
' '           Text
'"o more"'    Literal.String.Double
';'           Punctuation
'\n'          Text

'  '          Text
'return'      Keyword
' '           Text
'bottleDescription' Name.Other
' \n    '     Text
'+'           Operator
' '           Text
'" bottle"'   Literal.String.Double
' '           Text
'+'           Operator
' '           Text
'('           Punctuation
'if'          Keyword
' '           Text
'('           Punctuation
'bottleNum'   Name.Other
' '           Text
'='           Operator
'='           Operator
' '           Text
'1'           Literal.Number.Integer
')'           Punctuation
' '           Text
'then'        Keyword
' '           Text
'""'          Literal.String.Double
' '           Text
'else'        Keyword
' '           Text
'"s"'         Literal.String.Double
')'           Punctuation
' \n    '     Text
'+'           Operator
' '           Text
'" of beer"'  Literal.String.Double
';'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

' \n \n'      Text

'proc'        Keyword
' '           Text
'computeAction' Name.Function
'('           Punctuation
'bottleNum'   Name.Other
')'           Punctuation
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'return'      Keyword
' '           Text
'if'          Keyword
' '           Text
'('           Punctuation
'bottleNum'   Name.Other
' '           Text
'='           Operator
'='           Operator
' '           Text
'0'           Literal.Number.Integer
')'           Punctuation
' '           Text
'then'        Keyword
' '           Text
'"Go to the store and buy some more, "' Literal.String.Double
'\n'          Text

'    '        Text
'else'        Keyword
' '           Text
'"Take one down and pass it around, "' Literal.String.Double
';'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

'\n'          Text

'\n'          Text

'// Modules...\n' Comment.Single

'module'      Keyword
' '           Text
'M1'          Name.Class
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'x'           Name.Other
' '           Text
'='           Operator
' '           Text
'10'          Literal.Number.Integer
';'           Punctuation
'\n'          Text

'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'y'           Name.Other
' '           Text
'='           Operator
' '           Text
'13.0'        Literal.Number.Float
';'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

'\n'          Text

'module'      Keyword
' '           Text
'M2'          Name.Class
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'use'         Keyword
' '           Text
'M1'          Name.Other
' '           Text
'except'      Keyword
' '           Text
'y'           Name.Other
';'           Punctuation
'\n'          Text

'  '          Text
'use'         Keyword
' '           Text
'M1'          Name.Other
' '           Text
'only'        Keyword
' '           Text
'y'           Name.Other
';'           Punctuation
'\n'          Text

'  '          Text
'proc'        Keyword
' '           Text
'main'        Name.Function
'('           Punctuation
')'           Punctuation
' '           Text
'{'           Punctuation
'\n'          Text

'    '        Text
'writeln'     Name.Other
'('           Punctuation
'"M2 -> M1 -> x "' Literal.String.Double
' '           Text
'+'           Operator
' '           Text
'x'           Name.Other
')'           Punctuation
';'           Punctuation
'\n'          Text

'  '          Text
'}'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

'\n'          Text

'\n'          Text

'// Classes, records, unions...\n' Comment.Single

'const'       Keyword.Declaration
' '           Text
'PI'          Name.Other
':'           Punctuation
' '           Text
'real'        Keyword.Type
' '           Text
'='           Operator
' '           Text
'3.14159'     Literal.Number.Float
';'           Punctuation
'\n'          Text

'\n'          Text

'record'      Keyword
' '           Text
'Point'       Name.Class
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'x'           Name.Other
','           Punctuation
' '           Text
'y'           Name.Other
':'           Punctuation
' '           Text
'real'        Keyword.Type
';'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

'var'         Keyword.Declaration
' '           Text
'p'           Name.Other
':'           Punctuation
' '           Text
'Point'       Name.Other
';'           Punctuation
'\n'          Text

'writeln'     Name.Other
'('           Punctuation
'"Distance from origin: "' Literal.String.Double
' '           Text
'+'           Operator
' '           Text
'sqrt'        Name.Other
'('           Punctuation
'p'           Name.Other
'.'           Punctuation
'x'           Name.Other
' '           Text
'*'           Operator
'*'           Operator
' '           Text
'2'           Literal.Number.Integer
' '           Text
'+'           Operator
' '           Text
'p'           Name.Other
'.'           Punctuation
'y'           Name.Other
' '           Text
'*'           Operator
'*'           Operator
' '           Text
'2'           Literal.Number.Integer
')'           Punctuation
')'           Punctuation
';'           Punctuation
' \n'         Text

'p'           Name.Other
' '           Text
'='           Operator
' '           Text
'new'         Name.Other
' '           Text
'Point'       Name.Other
'('           Punctuation
'1.0'         Literal.Number.Float
','           Punctuation
' '           Text
'2.0'         Literal.Number.Float
')'           Punctuation
';'           Punctuation
'\n'          Text

'writeln'     Name.Other
'('           Punctuation
'"Distance from origin: "' Literal.String.Double
' '           Text
'+'           Operator
' '           Text
'sqrt'        Name.Other
'('           Punctuation
'p'           Name.Other
'.'           Punctuation
'x'           Name.Other
' '           Text
'*'           Operator
'*'           Operator
' '           Text
'2'           Literal.Number.Integer
' '           Text
'+'           Operator
' '           Text
'p'           Name.Other
'.'           Punctuation
'y'           Name.Other
' '           Text
'*'           Operator
'*'           Operator
' '           Text
'2'           Literal.Number.Integer
')'           Punctuation
')'           Punctuation
';'           Punctuation
' \n\n'       Text

'class'       Keyword
' '           Text
'Circle'      Name.Class
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'p'           Name.Other
':'           Punctuation
' '           Text
'Point'       Name.Other
';'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'r'           Name.Other
':'           Punctuation
' '           Text
'real'        Keyword.Type
';'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

'var'         Keyword.Declaration
' '           Text
'c'           Name.Other
' '           Text
'='           Operator
' '           Text
'new'         Name.Other
' '           Text
'Circle'      Name.Other
'('           Punctuation
'r'           Name.Other
'='           Operator
'2.0'         Literal.Number.Float
')'           Punctuation
';'           Punctuation
'\n'          Text

'proc'        Keyword
' '           Text
'Circle.area' Name.Function
'('           Punctuation
')'           Punctuation
'\n'          Text

'  '          Text
'return'      Keyword
' '           Text
'PI'          Name.Other
' '           Text
'*'           Operator
' '           Text
'r'           Name.Other
' '           Text
'*'           Operator
'*'           Operator
' '           Text
'2'           Literal.Number.Integer
';'           Punctuation
'\n'          Text

'writeln'     Name.Other
'('           Punctuation
'"Area of circle: "' Literal.String.Double
' '           Text
'+'           Operator
' '           Text
'c'           Name.Other
'.'           Punctuation
'area'        Name.Other
'('           Punctuation
')'           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'\n'          Text

'class'       Keyword
' '           Text
'Oval'        Name.Class
':'           Punctuation
' '           Text
'Circle'      Name.Other
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'r2'          Name.Other
':'           Punctuation
' '           Text
'real'        Keyword.Type
';'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

'proc'        Keyword
' '           Text
'Oval.area'   Name.Function
'('           Punctuation
')'           Punctuation
'\n'          Text

'  '          Text
'return'      Keyword
' '           Text
'PI'          Name.Other
' '           Text
'*'           Operator
' '           Text
'r'           Name.Other
' '           Text
'*'           Operator
' '           Text
'r2'          Name.Other
';'           Punctuation
'\n'          Text

'\n'          Text

'delete'      Keyword
' '           Text
'c'           Name.Other
';'           Punctuation
'\n'          Text

'c'           Name.Other
' '           Text
'='           Operator
' '           Text
'nil'         Keyword.Constant
';'           Punctuation
'\n'          Text

'c'           Name.Other
' '           Text
'='           Operator
' '           Text
'new'         Name.Other
' '           Text
'Oval'        Name.Other
'('           Punctuation
'r'           Name.Other
'='           Operator
'1.0'         Literal.Number.Float
','           Punctuation
' '           Text
'r2'          Name.Other
'='           Operator
'2.0'         Literal.Number.Float
')'           Punctuation
';'           Punctuation
'\n'          Text

'writeln'     Name.Other
'('           Punctuation
'"Area of oval: "' Literal.String.Double
' '           Text
'+'           Operator
' '           Text
'c'           Name.Other
'.'           Punctuation
'area'        Name.Other
'('           Punctuation
')'           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'\n'          Text

'// This is a valid decimal integer:\n' Comment.Single

'var'         Keyword.Declaration
' '           Text
'x'           Name.Other
' '           Text
'='           Operator
' '           Text
'0000000000012' Literal.Number.Integer
';'           Punctuation
'\n'          Text

'\n'          Text

'union'       Keyword
' '           Text
'U'           Name.Class
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'i'           Name.Other
':'           Punctuation
' '           Text
'int'         Keyword.Type
';'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'r'           Name.Other
':'           Punctuation
' '           Text
'real'        Keyword.Type
';'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

'\n'          Text

'// chapel ranges are awesome.\n' Comment.Single

'var'         Keyword.Declaration
' '           Text
'r1'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'10'          Literal.Number.Integer
','           Punctuation
'            ' Text
'// 1 2 3 4 5 6 7 8 9 10\n' Comment.Single

'  '          Text
'r2'          Name.Other
' '           Text
'='           Operator
' '           Text
'10'          Literal.Number.Integer
'..'          Operator
'1'           Literal.Number.Integer
','           Punctuation
'              ' Text
'// no values in this range\n' Comment.Single

'  '          Text
'r3'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'10'          Literal.Number.Integer
' '           Text
'by'          Keyword
' '           Text
'-'           Operator
'1'           Literal.Number.Integer
','           Punctuation
'        '    Text
'// 10 9 8 7 6 5 4 3 2 1\n' Comment.Single

'  '          Text
'r4'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'10'          Literal.Number.Integer
' '           Text
'by'          Keyword
' '           Text
'2'           Literal.Number.Integer
','           Punctuation
'         '   Text
'// 1 3 5 7 9\n' Comment.Single

'  '          Text
'r5'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'10'          Literal.Number.Integer
' '           Text
'by'          Keyword
' '           Text
'2'           Literal.Number.Integer
' '           Text
'align'       Keyword
' '           Text
'0'           Literal.Number.Integer
','           Punctuation
' '           Text
'// 2 4 6 8 10\n' Comment.Single

'  '          Text
'r6'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'10'          Literal.Number.Integer
' '           Text
'by'          Keyword
' '           Text
'2'           Literal.Number.Integer
' '           Text
'align'       Keyword
' '           Text
'2'           Literal.Number.Integer
','           Punctuation
' '           Text
'// 2 4 6 8 10\n' Comment.Single

'  '          Text
'r7'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'10'          Literal.Number.Integer
' '           Text
'#'           Operator
' '           Text
'3'           Literal.Number.Integer
','           Punctuation
'          '  Text
'// 1 2 3\n'  Comment.Single

'  '          Text
'r8'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'10'          Literal.Number.Integer
' '           Text
'#'           Operator
' '           Text
'-'           Operator
'2'           Literal.Number.Integer
','           Punctuation
'         '   Text
'// 9 10\n'   Comment.Single

'  '          Text
'r9'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'100'         Literal.Number.Integer
' '           Text
'#'           Operator
' '           Text
'10'          Literal.Number.Integer
' '           Text
'by'          Keyword
' '           Text
'2'           Literal.Number.Integer
','           Punctuation
'   '         Text
'// 1 3 5 7 9\n' Comment.Single

'  '          Text
'ra'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'100'         Literal.Number.Integer
' '           Text
'by'          Keyword
' '           Text
'2'           Literal.Number.Integer
' '           Text
'#'           Operator
' '           Text
'10'          Literal.Number.Integer
','           Punctuation
'   '         Text
'// 1 3 5 7 9 11 13 15 17 19\n' Comment.Single

'  '          Text
'rb'          Name.Other
' '           Text
'='           Operator
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
' '           Text
'#'           Operator
' '           Text
'100'         Literal.Number.Integer
' '           Text
'by'          Keyword
' '           Text
'10'          Literal.Number.Integer
';'           Punctuation
'    '        Text
'// 1 11 21 31 41 51 61 71 81 91\n' Comment.Single

'\n'          Text

'// create a variable with default initialization\n' Comment.Single

'var'         Keyword.Declaration
' '           Text
'myVarWithoutInit' Name.Other
':'           Punctuation
' '           Text
'real'        Keyword.Type
' '           Text
'='           Operator
' '           Text
'noinit'      Keyword
';'           Punctuation
'\n'          Text

'myVarWithoutInit' Name.Other
' '           Text
'='           Operator
' '           Text
'1.0'         Literal.Number.Float
';'           Punctuation
'\n'          Text

'\n'          Text

'// Chapel has <~> operator for read and write I/O operations.\n' Comment.Single

'class'       Keyword
' '           Text
'IntPair'     Name.Class
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'x'           Name.Other
':'           Punctuation
' '           Text
'int'         Keyword.Type
';'           Punctuation
'\n'          Text

'  '          Text
'var'         Keyword.Declaration
' '           Text
'y'           Name.Other
':'           Punctuation
' '           Text
'int'         Keyword.Type
';'           Punctuation
'\n'          Text

'  '          Text
'proc'        Keyword
' '           Text
'readWriteThis' Name.Function
'('           Punctuation
'f'           Name.Other
')'           Punctuation
' '           Text
'{'           Punctuation
'\n'          Text

'    '        Text
'f'           Name.Other
' '           Text
'<~>'         Operator
' '           Text
'x'           Name.Other
' '           Text
'<~>'         Operator
' '           Text
'new'         Name.Other
' '           Text
'ioLiteral'   Name.Other
'('           Punctuation
'","'         Literal.String.Double
')'           Punctuation
' '           Text
'<~>'         Operator
' '           Text
'y'           Name.Other
' '           Text
'<~>'         Operator
' '           Text
'new'         Name.Other
' '           Text
'ioNewline'   Name.Other
'('           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'  '          Text
'}'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

'var'         Keyword.Declaration
' '           Text
'ip'          Name.Other
' '           Text
'='           Operator
' '           Text
'new'         Name.Other
' '           Text
'IntPair'     Name.Other
'('           Punctuation
'17'          Literal.Number.Integer
','           Punctuation
'2'           Literal.Number.Integer
')'           Punctuation
';'           Punctuation
'\n'          Text

'write'       Name.Other
'('           Punctuation
'ip'          Name.Other
')'           Punctuation
';'           Punctuation
'\n'          Text

'\n'          Text

'var'         Keyword.Declaration
' '           Text
'targetDom'   Name.Other
' '           Text
'='           Operator
' '           Text
'{'           Punctuation
'1'           Literal.Number.Integer
'..'          Operator
'10'          Literal.Number.Integer
'}'           Punctuation
','           Punctuation
'\n'          Text

'  '          Text
'target'      Name.Other
':'           Punctuation
' '           Text
'['           Punctuation
'targetDom'   Name.Other
']'           Punctuation
' '           Text
'int'         Keyword.Type
';'           Punctuation
'\n'          Text

'coforall'    Keyword
' '           Text
'i'           Name.Other
' '           Text
'in'          Keyword.Declaration
' '           Text
'targetDom'   Name.Other
' '           Text
'with'        Keyword
' '           Text
'('           Punctuation
'ref'         Keyword.Declaration
' '           Text
'target'      Name.Other
')'           Punctuation
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'target'      Name.Other
'['           Punctuation
'i'           Name.Other
']'           Punctuation
' '           Text
'='           Operator
' '           Text
'i'           Name.Other
' '           Text
'*'           Operator
'*'           Operator
' '           Text
'3'           Literal.Number.Integer
';'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text

'\n'          Text

'var'         Keyword.Declaration
' '           Text
'wideOpen'    Name.Other
' '           Text
'='           Operator
' '           Text
'0o777'       Literal.Number.Oct
','           Punctuation
'\n'          Text

'  '          Text
'mememe'      Name.Other
' '           Text
'='           Operator
' '           Text
'0o600'       Literal.Number.Oct
','           Punctuation
'\n'          Text

'  '          Text
'clique_y'    Name.Other
' '           Text
'='           Operator
' '           Text
'0O660'       Literal.Number.Oct
','           Punctuation
'\n'          Text

'  '          Text
'zeroOct'     Name.Other
' '           Text
'='           Operator
' '           Text
'0o0'         Literal.Number.Oct
','           Punctuation
'\n'          Text

'  '          Text
'minPosOct'   Name.Other
' '           Text
'='           Operator
' '           Text
'0O1'         Literal.Number.Oct
';'           Punctuation
'\n'          Text

'\n'          Text

'private'     Keyword
' '           Text
'module'      Keyword
' '           Text
'M3'          Name.Class
' '           Text
'{'           Punctuation
'\n'          Text

'  '          Text
'private'     Keyword
' '           Text
'proc'        Keyword
' '           Text
'foo'         Name.Function
'('           Punctuation
')'           Punctuation
' '           Text
'{'           Punctuation
'\n'          Text

'\n'          Text

'  '          Text
'}'           Punctuation
'\n'          Text

'\n'          Text

'  '          Text
'private'     Keyword
' '           Text
'iter'        Keyword
' '           Text
'bar'         Name.Function
'('           Punctuation
')'           Punctuation
' '           Text
'{'           Punctuation
'\n'          Text

'    '        Text
'for'         Keyword
' '           Text
'i'           Name.Other
' '           Text
'in'          Keyword.Declaration
' '           Text
'1'           Literal.Number.Integer
'..'          Operator
'10'          Literal.Number.Integer
' '           Text
'{'           Punctuation
'\n'          Text

'      '      Text
'yield'       Keyword
' '           Text
'i'           Name.Other
';'           Punctuation
'\n'          Text

'    '        Text
'}'           Punctuation
'\n'          Text

'  '          Text
'}'           Punctuation
'\n'          Text

'\n'          Text

'  '          Text
'private'     Keyword
' '           Text
'var'         Keyword.Declaration
' '           Text
'x'           Name.Other
':'           Punctuation
' '           Text
'int'         Keyword.Type
';'           Punctuation
'\n'          Text

'\n'          Text

'}'           Punctuation
'\n'          Text

'prototype'   Keyword
' '           Text
'module'      Keyword
' '           Text
'X'           Name.Class
' '           Text
'{'           Punctuation
'\n'          Text

'\n'          Text

'  '          Text
'proc'        Keyword
' '           Text
'f'           Name.Function
'('           Punctuation
')'           Punctuation
' '           Text
'throws'      Keyword
' '           Text
'{'           Punctuation
'\n'          Text

'    '        Text
'throw'       Keyword
' '           Text
'new'         Name.Other
' '           Text
'Error'       Name.Other
'('           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'  '          Text
'}'           Punctuation
'\n'          Text

'\n'          Text

'  '          Text
'proc'        Keyword
' '           Text
'g'           Name.Function
'('           Punctuation
')'           Punctuation
' '           Text
'{'           Punctuation
'\n'          Text

'    '        Text
'try'         Keyword
' '           Text
'{'           Punctuation
'\n'          Text

'      '      Text
'f'           Name.Other
'('           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'      '      Text
'try'         Keyword
'!'           Operator
' '           Text
'f'           Name.Other
'('           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'    '        Text
'}'           Punctuation
' '           Text
'catch'       Keyword
' '           Text
'e'           Name.Other
' '           Text
'{'           Punctuation
'\n'          Text

'      '      Text
'writeln'     Name.Other
'('           Punctuation
'"Caught "'   Literal.String.Double
','           Punctuation
' '           Text
'e'           Name.Other
')'           Punctuation
';'           Punctuation
'\n'          Text

'    '        Text
'}'           Punctuation
'\n'          Text

'  '          Text
'}'           Punctuation
'\n'          Text

'\n'          Text

'  '          Text
'proc'        Keyword
' '           Text
'int.add'     Name.Function
'('           Punctuation
')'           Punctuation
' '           Text
'{'           Punctuation
' '           Text
'}'           Punctuation
'\n'          Text

'\n'          Text

'  '          Text
'g'           Name.Other
'('           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'\n'          Text

'  '          Text
'override'    Keyword
' '           Text
'proc'        Keyword
' '           Text
'test'        Name.Function
'('           Punctuation
')'           Punctuation
' '           Text
'throws'      Keyword
' '           Text
'{'           Punctuation
'\n'          Text

'    '        Text
'var'         Keyword.Declaration
' '           Text
'a'           Name.Other
' '           Text
'='           Operator
' '           Text
'new'         Name.Other
' '           Text
'borrowed'    Keyword
' '           Text
'IntPair'     Name.Other
'('           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'    '        Text
'var'         Keyword.Declaration
' '           Text
'b'           Name.Other
' '           Text
'='           Operator
' '           Text
'new'         Name.Other
' '           Text
'owned'       Keyword
' '           Text
'IntPair'     Name.Other
'('           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'    '        Text
'var'         Keyword.Declaration
' '           Text
'c'           Name.Other
' '           Text
'='           Operator
' '           Text
'new'         Name.Other
' '           Text
'shared'      Keyword
' '           Text
'IntPair'     Name.Other
'('           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'    '        Text
'throw'       Keyword
' '           Text
'new'         Name.Other
' '           Text
'unmanaged'   Keyword
' '           Text
'Error'       Name.Other
'('           Punctuation
')'           Punctuation
';'           Punctuation
'\n'          Text

'  '          Text
'}'           Punctuation
'\n'          Text

'}'           Punctuation
'\n'          Text
