summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authorburaq <buraq@epfl.ch>2003-07-08 10:04:48 +0000
committerburaq <buraq@epfl.ch>2003-07-08 10:04:48 +0000
commit3edab36b8911a044694d949b7ec9f1188602b8fa (patch)
tree37c1d0862d6157267fee70c0c281a44182449f99 /sources
parentd58dc0f1868b479b415c29ea264f106dc9699c21 (diff)
downloadscala-3edab36b8911a044694d949b7ec9f1188602b8fa.tar.gz
scala-3edab36b8911a044694d949b7ec9f1188602b8fa.tar.bz2
scala-3edab36b8911a044694d949b7ec9f1188602b8fa.zip
needed for binding (added temporarily)
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/SeqTrace.scala55
-rw-r--r--sources/scala/SeqTraceCons.scala22
-rw-r--r--sources/scala/SeqTraceNil.scala23
3 files changed, 100 insertions, 0 deletions
diff --git a/sources/scala/SeqTrace.scala b/sources/scala/SeqTrace.scala
new file mode 100644
index 0000000000..505d19ecff
--- /dev/null
+++ b/sources/scala/SeqTrace.scala
@@ -0,0 +1,55 @@
+// 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[ Tuple2[ Int, a ] ] {
+
+ /*abstract*/ def isEmpty:Boolean ;
+
+ /*abstract*/ def head:Tuple2[ 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 as 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)));
+*/
+
+ }
+
+
diff --git a/sources/scala/SeqTraceCons.scala b/sources/scala/SeqTraceCons.scala
new file mode 100644
index 0000000000..4b5724d8fe
--- /dev/null
+++ b/sources/scala/SeqTraceCons.scala
@@ -0,0 +1,22 @@
+package scala;
+
+ /** nonempty SeqTrace
+ */
+ final case class SeqTraceCons[ b ]( hdI:Int, hdb:b, tl: SeqTrace[ b ] )
+ extends SeqTrace[ b ] {
+
+ def isEmpty = false;
+
+ def head = Tuple2( hdI, hdb );
+
+ def headState = hdI;
+
+ def headElem = hdb;
+
+ def tail = tl;
+
+ override def toString(): String = mkString2("[ ", "; ", " ]");
+
+ }
+
+
diff --git a/sources/scala/SeqTraceNil.scala b/sources/scala/SeqTraceNil.scala
new file mode 100644
index 0000000000..56269ecd5b
--- /dev/null
+++ b/sources/scala/SeqTraceNil.scala
@@ -0,0 +1,23 @@
+// BE
+
+package scala ;
+
+ // SeqNil (empty SeqList)
+
+ final case class SeqTraceNil[ c ]() extends SeqTrace[ c ] {
+
+ def isEmpty = true;
+
+ def head: Tuple2[ Int, c ] = error("head of empty Trace");
+
+ def headState: Int = error("headState of empty Trace");
+
+ def headElem: c = error("headElem of empty Trace");
+
+ def tail: SeqTraceNil[c] = error("tail of empty Trace");
+
+ override def toString(): String = "[]";
+
+ }
+
+