summaryrefslogtreecommitdiff
path: root/sources/scala/SeqTrace.scala
blob: 6439f8889b177fd791f6f7578395e0573dd23539 (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
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2002-2003, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id$

// needed for variable binding in pattern matching

package scala;

// special sequence list

// run of a left-transducer that tags its input with states

// needed for variable binding during matching

abstract class SeqTrace[A] extends List[Pair[Int,A]] {

    /*abstract*/ def isEmpty: Boolean;

    /*abstract*/ def head: Pair[Int, A];

    /*abstract*/ def headState: Int;

    /*abstract*/ def headElem: A;

    /*abstract*/ def tail: SeqTrace[A];

/*
    override def ::(zI: Int, za: A): SeqTrace[A] =
       new SeqTraceCons(zI, za, this);
*/
    // why the f&&k do I need the .as cast ?

    def add[A](state: Int, value: A): SeqTraceCons[A] =
        SeqTraceCons[A](state, value, this.asInstanceOf[SeqTrace[A]]);

    // this is copied verbatim from List... and SeqList
/*
    def mkString2(start: java.lang.String,
		  sep: java.lang.String,
		  end: java.lang.String): java.lang.String =
        start +
        (if (isEmpty) end
         else if (tail.isEmpty) head.toString() + end
         else head.toString().concat(sep).concat(
             tail.mkString2("", sep, end)));
*/
/* BUG
    override def mkString(start: java.lang.String,
		     sep: java.lang.String,
		     end: java.lang.String): java.lang.String =
        start +
        (if (isEmpty) end
         else if (tail.isEmpty) head.toString() + end
         else head.toString().concat(sep).concat(
             tail.mkString("", sep, end)));
*/

}