This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright Shunsuke Sogame 2008-2010. | |
// Distributed under the terms of an MIT-style license. | |
import sbt._ | |
class HelloSbt(info: ProjectInfo) extends DefaultProject(info) { | |
override def compileOptions = Seq(Deprecation, Unchecked/*, ExplainTypes*/) ++ compileOptions("-Yrecursion", "50") ++ super.compileOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Func0 { | |
type A1 <: Any | |
type A2 <: Any | |
type apply2[x <: A1, y <: A2] | |
} | |
type foo[f <: Func0 { type A1 >: String; type A2 >: Any }] = f#apply2[String, Any] | |
trait f extends Func0 { | |
type A1 = String | |
type A2 = Any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright Shunsuke Sogame 2008-2009. | |
// Distributed under the terms of an MIT-style license. | |
package mada.iter | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private[mada] class OptPeg[A](p: Peg[A]) extends PegProxy[A] with Reluctant[A] { | |
override val self = p | Peg.eps[A] | |
override def before(that: Peg[A]) = (p >> ~that) | ~that | |
override def until(that: Peg[A]) = (p >> that) | that | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private[mada] class PlusPeg[A](p: Peg[A]) extends PegProxy[A] with Reluctant[A] { | |
override val self = p >> p.* | |
override def before(that: Peg[A]) = p >> (p.* before that) | |
override def until(that: Peg[A]) = p >> (p.* until that) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private[mada] class StarPeg[A](p: Peg[A]) extends Reluctant[A] { | |
override def parse(v: Vector[A], start: Int, end: Int): Int = { | |
// StarUntil(p, !p) would include unneeded parsing. | |
var cur = start | |
while (cur != end) { | |
val next = p.parse(v, cur, end) | |
if (next == Peg.FAILURE) { | |
return cur | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private[mada] case class TripleKey[A](v: Vector[A], start: Int, end: Int) { | |
override def equals(that: Any) = that match { | |
case that: TripleKey[_] => (v eq that.v) && (start == that.start) && (end == that.end) | |
case _ => false | |
} | |
override def hashCode = { | |
HashCode.ofRef(v) + HashCode.ofInt(start) * 7 + HashCode.ofInt(end) * 41 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private[mada] object Memoize { | |
def apply[A](p: Peg[A]): Peg[A] = new MemoizePeg(p) | |
} | |
private[mada] class MemoizePeg[A](override val self: Peg[A]) extends PegProxy[A] { | |
val memoTable = new scala.collection.jcl.HashMap[TripleKey[A], Int] | |
override def parse(v: Vector[A], start: Int, end: Int) = { | |
val key = new TripleKey(v, start, end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private[mada] object Fold { | |
def apply[A](v: Vector[A], z: A, op: (A, A) => A): A = { | |
(Vector.single(z) ++ v).reduce(op) | |
} | |
} | |
private[mada] object Folder { | |
def apply[A](v: Vector[A], z: A, op: (A, A) => A): Vector[A] = { | |
(Vector.single(z) ++ v).reducer(op) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright Shunsuke Sogame 2008-2009. | |
// Distributed under the terms of an MIT-style license. | |
// See: "Packrat Parsers Can Support Left Recursion" | |
package madatest.peg |
NewerOlder