blob: 91ff03a93a6320f5f296062d9f0d50b0c800af53 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala
package xml.dtd.impl
/** Basic regular expressions.
*
* @author Burak Emir
* @version 1.0
*/
@deprecated("This class will be removed", "2.10.0")
private[dtd] abstract class Base {
type _regexpT <: RegExp
abstract class RegExp {
val isNullable: Boolean
}
object Alt {
/** `Alt( R,R,R* )`. */
def apply(rs: _regexpT*) =
if (rs.size < 2) throw new SyntaxError("need at least 2 branches in Alt")
else new Alt(rs: _*)
// Can't enforce that statically without changing the interface
// def apply(r1: _regexpT, r2: _regexpT, rs: _regexpT*) = new Alt(Seq(r1, r2) ++ rs: _*)
def unapplySeq(x: Alt) = Some(x.rs)
}
class Alt private (val rs: _regexpT*) extends RegExp {
final val isNullable = rs exists (_.isNullable)
}
object Sequ {
/** Sequ( R,R* ) */
def apply(rs: _regexpT*) = if (rs.isEmpty) Eps else new Sequ(rs: _*)
def unapplySeq(x: Sequ) = Some(x.rs)
}
class Sequ private (val rs: _regexpT*) extends RegExp {
final val isNullable = rs forall (_.isNullable)
}
case class Star(r: _regexpT) extends RegExp {
final lazy val isNullable = true
}
// The empty Sequ.
case object Eps extends RegExp {
final lazy val isNullable = true
override def toString() = "Eps"
}
/** this class can be used to add meta information to regexps. */
class Meta(r1: _regexpT) extends RegExp {
final val isNullable = r1.isNullable
def r = r1
}
}
|