blob: 9f7d427b10e8871d9377c7703641908a0e1f173c (
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
|
package scala.xml.path;
object Expression {
final def testFromString(x: String): Test = {
x.charAt(0) match {
case '*' if( x.length == 1 ) => WildcardTest;
case _ => NameTest(x);
}
}
case class FExp(e:Expr, c:Cond) {
def eval(n: Node): NodeSeq = new NodeSeq { val theSeq=Nil}; // @todo
}
abstract class GenExp ;
case class Attrib(test: NameTest, e: Expr) extends GenExp;
abstract class Expr extends GenExp {
def \ (x: String) =
if( x=="*")
Child(WildcardTest, this)
else
Child(NameTest(x), this);
def \\ (x: String) =
if( x=="*")
DescOrSelf(WildcardTest, this)
else
DescOrSelf(NameTest(x), this);
def apply(c: Cond) = FExp(this, c);
def eval(n: Node): NodeSeq = new NodeSeq { val theSeq=Nil}; // @todo
}
case object Root extends Expr;
case class Child(test: Test, e: Expr) extends Expr;
case class DescOrSelf(test: Test, e: Expr) extends Expr;
abstract class Test;
case object WildcardTest extends Test; // "x \ * "
case class NameTest(label: String) extends Test; // "x \ bar"
abstract class Cond;
case class Exists(p: GenExp) extends Cond ; // "p [ p ]"
case class Equals(p: Expr, c:String) extends Cond ; // "p [ @p == bla ]"
}
|