Skip to content

Commit da92973

Browse files
author
Antonio Cunei
committed
Backport of r25948
1 parent c4e1b28 commit da92973

File tree

684 files changed

+7260
-3486
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

684 files changed

+7260
-3486
lines changed

docs/examples/actors/producers.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import scala.actors.Actor._
66
abstract class Producer[T] {
77

88
/** A signal that the next value should be produced. */
9-
private val Next = new Object
9+
private val Next = new Object
1010

1111
/** A label for an undefined state of the iterators. */
1212
private val Undefined = new Object
1313

1414
/** A signal to stop the coordinator. */
15-
private val Stop = new Object
15+
private val Stop = new Object
1616

1717
protected def produce(x: T) {
1818
coordinator ! Some(x)
@@ -53,10 +53,10 @@ abstract class Producer[T] {
5353
}
5454

5555
private val producer: Actor = actor {
56-
receive {
57-
case Next =>
56+
receive {
57+
case Next =>
5858
produceValues
59-
coordinator ! None
59+
coordinator ! None
6060
}
6161
}
6262
}
@@ -70,7 +70,7 @@ object producers extends Application {
7070
def tree = node(node(node(3), 4, node(6)), 8, node(node(9), 10, node(11)))
7171

7272
class PreOrder(n: Tree) extends Producer[Int] {
73-
def produceValues = traverse(n)
73+
def produceValues = traverse(n)
7474
def traverse(n: Tree) {
7575
if (n != null) {
7676
produce(n.elem)
@@ -81,7 +81,7 @@ object producers extends Application {
8181
}
8282

8383
class PostOrder(n: Tree) extends Producer[Int] {
84-
def produceValues = traverse(n)
84+
def produceValues = traverse(n)
8585
def traverse(n: Tree) {
8686
if (n != null) {
8787
traverse(n.left)
@@ -92,7 +92,7 @@ object producers extends Application {
9292
}
9393

9494
class InOrder(n: Tree) extends Producer[Int] {
95-
def produceValues = traverse(n)
95+
def produceValues = traverse(n)
9696
def traverse(n: Tree) {
9797
if (n != null) {
9898
traverse(n.left)

docs/examples/jolib/Ref.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import concurrent.SyncVar;
1212
import concurrent.jolib._;
1313
1414
class Ref[a](init: a) extends Join {
15-
15+
1616
object get extends Synchr[a](this) { case class C() extends SyncVar[a]; }
1717
object set extends Synchr[unit](this) { case class C(x: a) extends SyncVar[unit]; }
1818
object state extends Asynchr(this) { case class C(x: a); }
@@ -25,7 +25,7 @@ class Ref[a](init: a) extends Join {
2525
);
2626
2727
state(state.C(init));
28-
28+
2929
def Get: a = get(get.C());
3030
def Set(x: a): unit = set(set.C(x));
3131
}

docs/examples/jolib/parallelOr.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ import concurrent.SyncVar;
1313
1414
/** Implementation in the join-calculus of a parallel OR. */
1515
object or extends Join {
16-
16+
1717
object res extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
1818
object res1 extends Asynchr(this) { case class C(b: boolean); }
1919
object res2 extends Asynchr(this) { case class C(b: boolean); }
2020
object res1False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
2121
object res2False extends Synchr[boolean](this) { case class C() extends SyncVar[boolean] };
22-
22+
2323
rules(
2424
Pair(List(res, res1), { case List(r @ res.C(), res1.C(b)) =>
2525
if (b) r.set(b) else r.set(res1False(res1False.C())) }),
26-
26+
2727
Pair(List(res, res2), { case List(r @ res.C(), res2.C(b)) =>
2828
if (b) r.set(b) else r.set(res2False(res2False.C())) }),
29-
29+
3030
Pair(List(res1False, res2), { case List(r @ res1False.C(), res2.C(b)) =>
3131
r.set(b) }),
32-
32+
3333
Pair(List(res2False, res1), { case List(r @ res2False.C(), res1.C(b)) =>
3434
r.set(b) })
3535
);
36-
36+
3737
def apply(b1: => boolean, b2: => boolean): boolean = {
3838
concurrent.ops.spawn(res1(res1.C(b1)));
3939
concurrent.ops.spawn(res2(res2.C(b2)));
@@ -42,7 +42,7 @@ object or extends Join {
4242
}
4343
*/
4444
object parallelOr {
45-
45+
4646
def main(args: Array[String]): unit = {
4747
def loop: boolean = { while (true) {}; true };
4848
/*

docs/examples/monads/callccInterpreter.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object callccInterpreter {
1414

1515
def showM(m: M[Value]): String = (m in id).toString();
1616

17-
def callCC[A](h: (A => M[A]) => M[A]) =
17+
def callCC[A](h: (A => M[A]) => M[A]) =
1818
M[A](c => h(a => M[A](d => c(a))) in c);
1919

2020
type Name = String;
@@ -30,7 +30,7 @@ object callccInterpreter {
3030
trait Value;
3131
case object Wrong extends Value {
3232
override def toString() = "wrong"
33-
}
33+
}
3434
case class Num(n: Int) extends Value {
3535
override def toString() = n.toString();
3636
}
@@ -70,7 +70,7 @@ object callccInterpreter {
7070
case Ccc(x, t) => callCC(k => interp(t, Pair(x, Fun(k)) :: e))
7171
}
7272

73-
def test(t: Term): String =
73+
def test(t: Term): String =
7474
showM(interp(t, List()));
7575

7676
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));

docs/examples/monads/directInterpreter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ object directInterpreter {
4545
case App(f, t) => apply(interp(f, e), interp(t, e))
4646
}
4747

48-
def test(t: Term): String =
48+
def test(t: Term): String =
4949
showval(interp(t, List()));
5050

5151
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));
5252

53-
def main(args: Array[String]) =
53+
def main(args: Array[String]) =
5454
System.out.println(test(term0));
5555
}

docs/examples/monads/simpleInterpreter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object simpleInterpreter {
2222
trait Value;
2323
case object Wrong extends Value {
2424
override def toString() = "wrong"
25-
}
25+
}
2626
case class Num(n: Int) extends Value {
2727
override def toString() = n.toString();
2828
}
@@ -61,7 +61,7 @@ object simpleInterpreter {
6161
yield c
6262
}
6363

64-
def test(t: Term): String =
64+
def test(t: Term): String =
6565
showM(interp(t, List()));
6666

6767
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));

docs/examples/monads/stateInterpreter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object stateInterpreter {
77
val tickS = new M(s => Pair((), s + 1));
88

99
case class M[A](in: State => Pair[A, State]) {
10-
def bind[B](k: A => M[B]) = M[B]{ s0 =>
10+
def bind[B](k: A => M[B]) = M[B]{ s0 =>
1111
val Pair(a, s1) = this in s0; k(a) in s1
1212
}
1313
def map[B](f: A => B): M[B] = bind(x => unitM(f(x)));
@@ -72,7 +72,7 @@ object stateInterpreter {
7272
yield c
7373
}
7474

75-
def test(t: Term): String =
75+
def test(t: Term): String =
7676
showM(interp(t, List()));
7777

7878
val term0 = App(Lam("x", Add(Var("x"), Var("x"))), Add(Con(10), Con(11)));

docs/examples/parsing/ArithmeticParser.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ import scala.util.parsing.combinator.syntactical.StdTokenParsers
1515
* a term is a sequence of factors, separated by * or /
1616
* a factor is a parenthesized expression or a number
1717
*
18-
* @author Adriaan Moors
19-
*/
20-
object arithmeticParser extends StdTokenParsers {
18+
* @author Adriaan Moors
19+
*/
20+
object arithmeticParser extends StdTokenParsers {
2121
type Tokens = StdLexical ; val lexical = new StdLexical
2222
lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
2323

2424
lazy val expr = term*("+" ^^^ {(x: int, y: int) => x + y} | "-" ^^^ {(x: int, y: int) => x - y})
2525
lazy val term = factor*("*" ^^^ {(x: int, y: int) => x * y} | "/" ^^^ {(x: int, y: int) => x / y})
2626
lazy val factor: Parser[int] = "(" ~> expr <~ ")" | numericLit ^^ (_.toInt)
27-
27+
2828
def main(args: Array[String]) {
2929
println(
3030
if (args.length == 1) {
@@ -37,14 +37,14 @@ object arithmeticParser extends StdTokenParsers {
3737
}
3838

3939

40-
object arithmeticParserDesugared extends StdTokenParsers {
40+
object arithmeticParserDesugared extends StdTokenParsers {
4141
type Tokens = StdLexical ; val lexical = new StdLexical
4242
lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
4343

4444
lazy val expr = chainl1(term, (keyword("+").^^^{(x: int, y: int) => x + y}).|(keyword("-").^^^{(x: int, y: int) => x - y}))
4545
lazy val term = chainl1(factor, (keyword("*").^^^{(x: int, y: int) => x * y}).|(keyword("/").^^^{(x: int, y: int) => x / y}))
46-
lazy val factor: Parser[int] = keyword("(").~>(expr.<~(keyword(")"))).|(numericLit.^^(x => x.toInt))
47-
46+
lazy val factor: Parser[int] = keyword("(").~>(expr.<~(keyword(")"))).|(numericLit.^^(x => x.toInt))
47+
4848
def main(args: Array[String]) {
4949
println(
5050
if (args.length == 1) {

docs/examples/parsing/ArithmeticParsers.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package examples.parsing
22

33
import scala.util.parsing.combinator1.syntactical.StandardTokenParsers
44

5-
object ArithmeticParsers extends StandardTokenParsers {
5+
object ArithmeticParsers extends StandardTokenParsers {
66
lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
77

88
def expr: Parser[Any] = term ~ rep("+" ~ term | "-" ~ term)
@@ -16,11 +16,11 @@ object ArithmeticParsers extends StandardTokenParsers {
1616
}
1717
}
1818

19-
object ArithmeticParsers1 extends StandardTokenParsers {
19+
object ArithmeticParsers1 extends StandardTokenParsers {
2020
lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
2121

2222
val reduceList: Int ~ List[String ~ Int] => Int = {
23-
case i ~ ps => (i /: ps)(reduce)
23+
case i ~ ps => (i /: ps)(reduce)
2424
}
2525

2626
def reduce(x: Int, r: String ~ Int) = (r: @unchecked) match {
@@ -45,11 +45,11 @@ class Expr
4545
case class BinOp(op: String, l: Expr, r: Expr) extends Expr
4646
case class Num(n: Int) extends Expr
4747

48-
object ArithmeticParsers2 extends StandardTokenParsers {
48+
object ArithmeticParsers2 extends StandardTokenParsers {
4949
lexical.delimiters ++= List("(", ")", "+", "-", "*", "/")
5050

5151
val reduceList: Expr ~ List[String ~ Expr] => Expr = {
52-
case i ~ ps => (i /: ps)(reduce)
52+
case i ~ ps => (i /: ps)(reduce)
5353
}
5454

5555
def reduce(l: Expr, r: String ~ Expr) = BinOp(r._1, l, r._2)

docs/examples/parsing/JSON.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package examples.parsing
22

33
import scala.util.parsing.combinator1.syntactical.StandardTokenParsers
44

5-
object JSON extends StandardTokenParsers {
5+
object JSON extends StandardTokenParsers {
66
lexical.delimiters += ("{", "}", "[", "]", ":", ",")
77
lexical.reserved += ("null", "true", "false")
88

99
def obj : Parser[Any] = "{" ~ repsep(member, ",") ~ "}"
1010
def arr : Parser[Any] = "[" ~ repsep(value, ",") ~ "]"
1111
def member: Parser[Any] = ident ~ ":" ~ value
12-
def value : Parser[Any] = ident | numericLit | obj | arr |
12+
def value : Parser[Any] = ident | numericLit | obj | arr |
1313
"null" | "true" | "false"
1414

1515
def main(args: Array[String]) {
@@ -18,20 +18,20 @@ object JSON extends StandardTokenParsers {
1818
println(phrase(value)(tokens))
1919
}
2020
}
21-
object JSON1 extends StandardTokenParsers {
21+
object JSON1 extends StandardTokenParsers {
2222
lexical.delimiters += ("{", "}", "[", "]", ":", ",")
2323
lexical.reserved += ("null", "true", "false")
2424

25-
def obj: Parser[Map[String, Any]] =
25+
def obj: Parser[Map[String, Any]] =
2626
"{" ~> repsep(member, ",") <~ "}" ^^ (Map() ++ _)
2727

2828
def arr: Parser[List[Any]] =
29-
"[" ~> repsep(value, ",") <~ "]"
29+
"[" ~> repsep(value, ",") <~ "]"
3030

31-
def member: Parser[(String, Any)] =
31+
def member: Parser[(String, Any)] =
3232
ident ~ ":" ~ value ^^ { case name ~ ":" ~ value => (name -> value) }
3333

34-
def value: Parser[Any] =
34+
def value: Parser[Any] =
3535
ident | numericLit ^^ (_.toInt) | obj | arr |
3636
"null" ^^^ null | "true" ^^^ true | "false" ^^^ false
3737

0 commit comments

Comments
 (0)