summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/list/library.lst1
-rw-r--r--sources/scala/collection/mutable/BitSet.scala2
-rw-r--r--sources/scala/runtime/matching/Context.scala219
-rw-r--r--sources/scala/runtime/matching/Grammar.scala168
-rw-r--r--sources/scala/runtime/matching/Match.scala105
-rw-r--r--sources/scala/runtime/matching/Pebble.scala14
-rw-r--r--sources/scala/xml/path/Parser.scala60
-rw-r--r--sources/scala/xml/path/Scanner.scala47
-rw-r--r--sources/scala/xml/path/Tokens.scala23
9 files changed, 2 insertions, 637 deletions
diff --git a/config/list/library.lst b/config/list/library.lst
index 6f319d7063..5c325bc498 100644
--- a/config/list/library.lst
+++ b/config/list/library.lst
@@ -118,6 +118,7 @@ collection/mutable/SynchronizedSet.scala
collection/mutable/SynchronizedStack.scala
collection/mutable/Undoable.scala
+collection/immutable/BitSet.scala
collection/immutable/ListMap.scala
collection/immutable/ListSet.scala
collection/immutable/Map.scala
diff --git a/sources/scala/collection/mutable/BitSet.scala b/sources/scala/collection/mutable/BitSet.scala
index 278f6d5965..def15fdb6b 100644
--- a/sources/scala/collection/mutable/BitSet.scala
+++ b/sources/scala/collection/mutable/BitSet.scala
@@ -16,7 +16,7 @@ package scala.collection.mutable ;
*/
class BitSet(initSize: Int) extends scala.collection.BitSet {
- /** default constructor, initial size of 16 bits */
+ /** default constructor, initial size of 32 bits */
def this() = this( 32 );
class ByteArray with ResizableArray[Int] {
diff --git a/sources/scala/runtime/matching/Context.scala b/sources/scala/runtime/matching/Context.scala
deleted file mode 100644
index 650a4647a1..0000000000
--- a/sources/scala/runtime/matching/Context.scala
+++ /dev/null
@@ -1,219 +0,0 @@
-package scala.runtime.matching ;
-/** contexts fully determined which derivation was used along a path,
-* thereby allowing to select the proceed the %next% derivations.
-*
-* we use here that derivations are ordered.
-*/
-abstract class PathContext with Ordered[PathContext] {
- val len = 0;
- def isCompatible( other:PathContext ):boolean ;
- def ~( other:PathContext ):boolean ;
- def prune( len:int ):PathContext = this;
- def address:List[Int] = 0::Nil;
- def toString1():String = "";
-
- def compareTo [b >: PathContext <% Ordered[b]](that: b): int = that match {
- case t:PathContext =>
- if( rctx_inf(this,t) )
- -1
- else if( rctx_eq(this,t) )
- 0
- else
- 1;
- case _ => -(that compareTo this)
- }
-
-
-
- final def rctx_inf( x:PathContext, y:PathContext ):boolean = x match {
- case EmptyContext => y match {
- case EmptyContext => false;
- case _ => true;
- }
- case RuleContext(r1, up1) => y match {
- case RuleContext(r2,up2) =>
- ((r1 == r2 ) && rctx_inf(up1, up2))
- || ( r1 < r2 )
- case _ => false;
- }
- }
-
- final def rctx_eq( x:PathContext, y:PathContext ) = x == y;
-}
-/** use HedgeNT H */
-/*
-case class HedgeContext( H:HedgeNT, outer:PathContext ) extends PathContext {
- override def toString():String = outer.toString()+":"+H.toString();
-def isCompatible( other:PathContext ):boolean = error("don't call me");
-def ~( other:PathContext ) = error("don't call me");
-}
-*/
-/** use TreeNT T */
-/*
-case class TreeContext( T:TreeNT, up:PathContext ) extends PathContext {
- override def toString():String = up.toString()+":"+T.toString();
-def isCompatible( other:PathContext ):boolean = error("don't call me");
-def ~( other:PathContext ) = error("don't call me");
-};
-*/
-/** the root context */
-case object EmptyContext extends PathContext {
- override def toString1() = "()";
- override def toString():String = "()";
- def isCompatible( other:PathContext ):boolean = true;
- override def ~( other:PathContext ) = true;
-}
-
-/* inv: up is RuleContext || EmptyContext */
-case class RuleContext( r:Rule, up:PathContext ) extends PathContext {
-
- override def toString1():String = { up.toString1()+";"+r.toString() }
-
- override def toString():String = toString1()+"["+address.reverse+"]";
- override val len = up.len + 1;
-
- def down(li:List[Int]):List[Int] = 0::li;
-
- def right(li:List[Int]):List[Int] = li match {
- case i::is => i+1::is
- }
-
- override def address:List[Int] = r match {
- case _:HedgeRule => right( up.address );
- case _:AnyNodeRule => down( up.address );
- case _:TreeRule => down( up.address );
- case _:AnyTreeRule => down( up.address );
- }
-
- /* if have common prefix */
- override def isCompatible( other:PathContext ):boolean = {
- Console.println( "isCompatible called\nthis:"+this+" len="+this.len+"\nother"+other+" len = "+other.len);
- val q = {
- if( this.len > other.len ) {
- Console.println("this.prune(otherlen) = "+ this.prune( other.len ));
-
- val tmp = this.prune( other.len );
- ( tmp == other )||( tmp ~ other )
-
- } else if( this.len < other.len ) {
- val tmp = other.prune( this.len );
- Console.println("other.prune(thislen) = "+ tmp);
- ( this == tmp )||( this ~ tmp );
- } else
- (this == other )|| this ~ other
- // ^ for x @ y @ p
- };
- Console.println("result: "+q);
- q
- }
-
- override def ~( other:PathContext ) = {
- def matchesH( H:HedgeNT, r2:Rule ) = r2 match {
- case HedgeRule( H, _, _ ) => true
- case _ => false;
- };
- def matchesT( T:TreeNT, r2:Rule ) = r2 match {
- case TreeRule( T, _, _ ) => true
- case AnyTreeRule( T ) => true
- case AnyNodeRule( T, _ ) => true
- case _ => false;
- };
- (other match {
- case RuleContext( r2, up2 ) =>
- ( (up == up2) && (this.up match {
-
- case RuleContext( HedgeRule( h, t1, h1 ), _ ) =>
- ( matchesT( t1, this.r ) && matchesH( h1, r2 ) )
- ||( matchesT( t1, r2 ) && matchesH( h1, this.r ) )
-
- case _ => false;
-
- }) || up ~ up2 )
-
- case EmptyContext => true;/*other match {
- case EmptyContext => true;
- case _ => false;
- }*/
- })
- }
-
- override def prune( len:int ):PathContext = {
- if( this.len > len ) up.prune( len ) else this;
- }
-}
-
-/*
-def ctx_inf( x:PathContext, y:PathContext ):boolean = {
- x match {
- case EmptyContext => y match {
- case EmptyContext => false;
-case _ => true;
- }
-case HedgeContext( h:HedgeNT, out:PathContext ) => y match {
- case HedgeContext( h2:HedgeNT, out2:PathContext ) =>
- (ctx_eq(out,out2) &&( h.i < h2.i )) || ctx_inf( out,out2 )
-case _ => false
-}
-case TreeContext( t:TreeNT, up:PathContext ) => y match {
- case TreeContext( t2:TreeNT, up2:PathContext ) =>
- (ctx_eq(up,up2) && (t.i < t2.i)) || ctx_inf( up, up2 )
-case _ => true
-}
- }
-}
-
-def ctx_eq( x:PathContext, y:PathContext ):boolean = {
- x match {
- case EmptyContext => y match {
- case EmptyContext => true;
-case _ => true;
- }
-case HedgeContext( h:HedgeNT, out:PathContext ) => y match {
- case HedgeContext( h2:HedgeNT, out2:PathContext ) =>
- ctx_eq(out,out2) &&( h.i == h2.i )
-case _ => false
-}
-case TreeContext( t:TreeNT, up:PathContext ) => y match {
- case TreeContext( t2:TreeNT, up2:PathContext ) =>
- ctx_eq(up,up2) && (t.i == t2.i)
-case _ => false
-}
- }
-}
-*/
-//val contextOrder = new Order[PathContext]( ctx_inf, ctx_eq ) ;
-
-// val ruleContextOrder = new Order[PathContext]( rctx_inf, rctx_eq ) ;
-
-
-/* matcher needs this operations
-isApplicableTree(1):
- given string s, and set of TreeNTs A, return a A'(\subseteq A) and a set B'
- such that for every t' in A' grammar has a rule t' -> s < h' >
-
-maybe grammar is a map Str -> Pow(P x Q) rather than P -> Str x Q or
-array P x Str_Index -> Q (use hashmap for strings that appear in a pattern!)
-(P = treents, Q = hedgeNTs) and a map Q x P -> Q rather than Q -> P x Q
-
-isApplicableTree(2):
- given a set B'' ( subseteq B' ) of hedgeNTs, and s and A' like above,
- return A''(\subseteq A') with those rules that have nonterminals from B''.
-
-see above
-
-isApplicableHedge(1)
- get epsilon closure of hedgeNTs (followChainRules) ?? needed ??
-
-isApplicableHedge(2)
- given set B of hedgeNTs h, return a set A of treeNTs t such that
- there is rule h -> ( t , _ )
-
-isApplicableHedge(3)
- given set B and set A'(subseteq A), return a set C of hedgeNTs h2 such that
- there is rule h -> ( t' , h2 )
-
-isApplicableHedge(4)
- given set C' (\subseteq C) extract B' (subseteq B) such that there is
- rule h' -> ( _ , h2' )
-
-*/
diff --git a/sources/scala/runtime/matching/Grammar.scala b/sources/scala/runtime/matching/Grammar.scala
deleted file mode 100644
index 4bd2489f59..0000000000
--- a/sources/scala/runtime/matching/Grammar.scala
+++ /dev/null
@@ -1,168 +0,0 @@
-package scala.runtime.matching ;
-
-import scala.collection.Set;
-import scala.collection.Map ;
-import scala.collection.immutable;
-import scala.collection.mutable;
-
-/** runtime representation of patterns. This class treats all variable
- * indices as sequence variables
- * @caseVars an array, field i holding the number of variables in case i
- */
-class Grammar {
-
- var treeTransitions: Array[immutable.Set[TRule]] = _; /*i:(i,test,hnt) */
- var hedgeTransitions: Array[immutable.Set[HRule]] = _; /*i:(i,tnt,hnt)*/
- /** for cases 1..n, holds max. variable index */
- var vars:Array[Int] = _;
- //val vsetTree:Array[Set[Int]] ;
- //val vsetHedge:Array[Set[Int]] ;
-
- var treeInitials:Set[TreeNT] = _;
- var hedgeInitials:Set[HedgeNT] = _;
-
- def test(test:int, inp:Any):boolean = false;
-
- final def isSequenceType = treeInitials.isEmpty;
-
- /*
- protected def allTreeNT: Array[TreeNT] = {
- val ar = new Array[TreeNT]( treeTransitions.length );
- for( val tr <- treeTransitions ) {
- tr.elements.next match {
- case TreeRule(n,_,_) =>
- case AnyTreeRule(n) =>
- case AnyNodeRule(n,_) =>
- }
- }
- }
- */
- //val hedgeNT: Array[HedgeNT];
-
- final def encode:Array[Byte] = {
- val bos = new java.io.ByteArrayOutputStream();
- val obos = new java.io.ObjectOutputStream(bos);
- obos.writeObject(this);
- bos.toByteArray();
- }
- /*
- var i = 0;
- val sb = new StringBuffer();
- sb.append( treeTransitions.length.toString() )
- sb.append('#')
- while( i < treeTransitions.length ) {
- sb.append( Grammar.encodeTRuleSet( treeTransitions( i )));
- sb.append('#')
- i = i + 1;
- }
- sb.append( hedgeTransitions.length.toString() )
- sb.append('#')
- i = 0;
- while( i < hedgeTransitions.length ) {
- sb.append( Grammar.encodeHRuleSet( hedgeTransitions( i )));
- i = i + 1;
- }
- sb.append('#')
- }
- */
-
-}
-
-
-/*
-object Grammar {
-
- new Grammar {
- override val treeTransitions = theTreeTransitions;
- override val hedgeTransitions = theHedgeTransitions;
- override val vars = theVars;
- override val treeInitials = null;//theTreeInitials;
- override val hedgeInitials = null;//theHedgeInitials;
- // @todo
- //def test( test:int, inp:Any ):boolean = { false; };
- }
- }
-
-
- final def decodeTRuleSet(trules: String): immutable.Set[TRule]= {
- new immutable.ListSet[TRule]();
- }
-
- final def decodeHRuleSet(trules: String): immutable.Set[HRule]= {
- new immutable.ListSet[HRule]();
- }
-
- final def encodeTRuleSet(trules: immutable.Set[TRule]):String = {
- "";
- }
-
- final def encodeHRuleSet(trules: immutable.Set[TRule]):String = {
- "";
- }
-
-}
-*/
-
-
- /*
- object & {
- final def x (s:String): Int = Integer.parseInt(s, 16);
- }
- def decode(s: String): Grammar = {
- val z:Array[String] = s.split("#");
- var i = 0;
- val tlength = & x z(0) ;
- var j = 1;
- var theTreeTransitions = new Array[immutable.Set[TRule]]( tlength );
- while( i < tlength ) {
- theTreeTransitions.update( i, Grammar.decodeTRuleSet(z( j )));
- i = i + 1;
- j = j + 1;
- }
- val hlength = & x z(j);
- j = j + 1;
- var theHedgeTransitions = new Array[immutable.Set[HRule]]( hlength );
- i = 0;
- j = j + 1;
- while( i < hlength ) {
- theHedgeTransitions.update( i, Grammar.decodeHRuleSet(z( j )));
- i = i + 1;
- j = j + 1;
- }
- val vlength = & x z(j);
- j = j + 1;
- var theVars = new Array[Int]( vlength );
- i = 0;
- while( i < vlength ) {
- theVars.update( i, Integer.parseInt(z( j ),16));
- i = i + 1;
- j = j + 1;
- }
-
- val tilength = & x z(j) ;
- j = j + 1;
- var theTreeInitials = new Array[TreeNT]( tilength );
- i = 0;
- while( i < vlength ) {
- theTreeInitials.update( i, new TreeNT( & x z( j )));
- i = i + 1;
- j = j + 1;
- }
-
-
- val hilength = & x z(j) ;
- j = j + 1;
- var theHedgeInitials = new Array[HedgeNT]( hilength );
- i = 0;
- while( i < hilength ) {
- val hi = & x z( j );
- theHedgeInitials.update( i, {
- if( hi < 0 )
- new HedgeNT(-hi, true);
- else
- new HedgeNT(hi, false);
- });
- i = i + 1;
- j = j + 1;
- }
- */
diff --git a/sources/scala/runtime/matching/Match.scala b/sources/scala/runtime/matching/Match.scala
deleted file mode 100644
index e0df7332ac..0000000000
--- a/sources/scala/runtime/matching/Match.scala
+++ /dev/null
@@ -1,105 +0,0 @@
-package scala.runtime.matching ;
-
-import scala.collection.Map ;
-import scala.collection.immutable ;
-import scala.xml.Node ;
-
-object Match {
-
- def res2string(res:immutable.Map[ Int, PathContext ]):String = {
- val sb = new StringBuffer();
- sb.append( "binding {\n" );
- for( val vble <- res.keys ) {
- val pc = res.get( vble ).get;
- sb.append( " " );
- sb.append( vble );
- sb.append( " <- " );
- sb.append( pc.address.reverse );
- sb.append( '\n' );
- }
- sb.append( "}\n" );
- sb.toString();
- }
-
- /* pm: remaining pebbles
- */
- def printSol( vble:Int,
- b2:PathContext,
- vctx:immutable.Set[PathContext],
- pm:immutable.Map[ Int, immutable.Set[PathContext] ],
- result:immutable.Map[ Int, PathContext] ):unit = {
- Console.println("printSol("+vble+","+vctx+","+pm+","+result+")");
- for( val b <- vctx.elements; {if( b2!=null ) b.isCompatible( b2 ) else true}) {
- val nres = result.update( vble, b );
- if( pm.isEmpty ) {
- Console.println( nres );
- Console.println( res2string(nres) );
- } else for( val nextVar <- pm.keys;
- val nextCtx <- pm.get( nextVar )) {
- printSol( nextVar, b, nextCtx, pm - nextVar, nres )
- }
- }
- }
-
-
- def decode( pebblesMap:immutable.Map[ Int, immutable.Set[PathContext] ] ) = {
-
- val it = pebblesMap.keys;
- if( it.hasNext ) {
- val first = it.next ;
- val fctx = pebblesMap.get( first ).get;
- printSol( first,
- null,
- fctx,
- pebblesMap - first,
- new immutable.TreeMap[Int,PathContext] )
- }
- }
-
-}
-
-
-class Match( k:Int,it:Iterator[Seq[scala.xml.Node]] ) {
-
- override def equals( o:Any ) = o match {
- case that:Match =>
- ( this.index == that.index )&&( this.iter.toList == that.iter.toList )
- case _ => false;
- }
-
- val index = k;
- val iter = it;
-
- /** this method is destructive
- **/
- def toString_DEBUG( vx2str:Int => String ) = {
- if( !iter.hasNext ) {
- "<empty binding>"
- } else {
- val sb = new StringBuffer("<match> with binding");
- var vx = 0;
- while( iter.hasNext ) {
- sb.append( vx2str( vx ) + " <- " + iter.next.toString + "\n" );
- }
- sb.toString();
- }
- }
-
- /** this method is destructive
- **/
- def same( that:Match ) = {
- ( this.index == that.index )&&( this.iter.toList == that.iter.toList )
- }
-
- /** this method is destructive
- **/
- override def toString() = {
- val sb = new StringBuffer("Match("+index);
- while( iter.hasNext ) {
- sb.append( "," );
- sb.append( iter.next.toString() );
- }
- sb.append(")");
- sb.toString();
- }
-}
diff --git a/sources/scala/runtime/matching/Pebble.scala b/sources/scala/runtime/matching/Pebble.scala
deleted file mode 100644
index 42f7c01c78..0000000000
--- a/sources/scala/runtime/matching/Pebble.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-package scala.runtime.matching ;
-
-case class Pebble(vx:Int,p:Address) with Ordered[Pebble] {
-
- def compareTo[ b >: Pebble <% Ordered[b] ]( y:b ) = y match {
- case Pebble( vx2, p2 ) =>
- if( vx == vx2 )
- p compareTo p2
- else
- vx compareTo vx2
- case _ => -( y compareTo this )
- }
-
-}
diff --git a/sources/scala/xml/path/Parser.scala b/sources/scala/xml/path/Parser.scala
deleted file mode 100644
index c36216cbcb..0000000000
--- a/sources/scala/xml/path/Parser.scala
+++ /dev/null
@@ -1,60 +0,0 @@
-package scala.xml.path ;
-
-class Parser( it:Iterator[char] ) with Scanner( it ) {
-
- def acc( tok:int ) = {
- if( token != tok ) error("unexpected token") else {};
- nextToken
- }
-
- def getName: String = {
- if( token != NAME ) error("expected * or a name") else {};
- val x = value;
- nextToken;
- }
-
- def parseString( xpath:String ) = {
- //initScanner( new IterableString( xpath ));
- expr
- }
-
- def expr:Expr = {
- var es : Expr = Root;
- while( token != ENDTOK ) token.match {
-
- case AT =>
- nextToken; es = Attribute( ident ) :: es;
-
- case SLASH =>
- val x = getName;
- if( x == "*" )
- es = Child(Wildcard, es)
- else
- es = Child(NameTest( x ), es)
-
- case SLASHSLASH =>
- val x = getName;
- if( x == "*" )
- es = DescOrSelf(Wildcard, es)
- else
- es = DescOrSelf(NameTest( x ), es)
-
- }
- es.reverse;
- }
-
- def conds = token match {
- case LBRACKET =>
- nextToken;
- var cond :List[List[Expression]] = List( expr );
- while( COMMA == token ) { cond = expr :: cond }
- acc( RBRACKET );
- Some( cond.reverse )
- case _ =>
- None
- }
-
- def ident = {
- val label = value; acc(IDENT); label
- }
-}
diff --git a/sources/scala/xml/path/Scanner.scala b/sources/scala/xml/path/Scanner.scala
deleted file mode 100644
index ff0631294c..0000000000
--- a/sources/scala/xml/path/Scanner.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-package scala.xml.path ;
-
-class Scanner( it:Iterator[char] ) with Tokens {
-
- val ENDCH : char = (-1).asInstanceOf[char];
-
- var c : char = '%';
- var token : int = 0;
- var value : String = "";
-
- def next = if( it.hasNext ) { c = it.next } else { c = ENDCH };
-
- def nextToken = if( ENDCH == c ) ENDTOK else c match {
- case '@' => AT
- case ',' => COMMA
- case '.' =>{
- next;
- if ( '.' == c ) { next; token = DOTDOT } else { token = DOT }
- }
- case '=' =>next; token = EQUALS
- case '[' =>next; token = LBRACKET
- case ']' =>next; token = RBRACKET
- case '/' =>{
- next;
- if ( '/' == c ) { next; token = SLASHSLASH } else { token = SLASH }
- }
- case _ =>getIdentOrKeyword;
- }
-
- def isIdentChar = ('a' <= c && c <= 'z');
-
- def getIdentOrKeyword = {
- val str = getIdent; token = IDENT /*
- keywords.get( str ) match {
- case Some( tok ) => value=""; token = tok
- case None => token = IDENT
- }*/
- }
-
- def getIdent:String = {
- var cs = c :: Nil;
- next;
- while ( isIdentChar ) { cs = c::cs; next }
- cs.foldLeft ("") { (c,s) => s+c }
- }
-
-}
diff --git a/sources/scala/xml/path/Tokens.scala b/sources/scala/xml/path/Tokens.scala
deleted file mode 100644
index 86ec396624..0000000000
--- a/sources/scala/xml/path/Tokens.scala
+++ /dev/null
@@ -1,23 +0,0 @@
-package scala.xml.path ;
-
-/** Tokens for XPath expressions
- */
-
-class Tokens {
-
- final val AT = 0;
- final val COMMA = AT + 1;
- final val DOT = COMMA + 1;
- final val DOTDOT = DOT + 1;
- final val EQUALS = DOTDOT + 1;
- final val NAME = EQUALS + 1;
- final val LBRACKET = NAME + 1;
- final val RBRACKET = LBRACKET + 1;
- final val SLASH = RBRACKET + 1;
- final val SLASHSLASH = SLASH + 1;
- final val STAR = SLASHSLASH + 1;
-
- final val ENDTOK = STAR + 1;
-
-
-}