From 4ba5a222f53f03fab58b4991c3ddf5f556e2c080 Mon Sep 17 00:00:00 2001 From: buraq Date: Fri, 12 Nov 2004 11:46:33 +0000 Subject: scala.util cleanup --- .../scala/runtime/matching/PatternGrammar.scala | 2 +- sources/scala/runtime/matching/TestAlphabet.scala | 8 +- sources/scala/tools/dtd2scala/DeclToScala.scala | 2 +- .../tools/scalac/transformer/TransMatch.scala | 19 +- .../matching/FullRegularTranslator.scala | 387 --------------------- .../transformer/matching/MutableGrammar.scala | 233 ------------- .../transformer/matching/NonTermFactory.scala | 41 --- .../scalac/transformer/matching/PatternExp.scala | 130 ------- .../scalac/transformer/matching/PatternInfo.scala | 0 .../scalac/transformer/matching/PatternTest.scala | 17 - sources/scala/util/alphabet/Alphabet.scala | 3 - .../scala/util/alphabet/AlphabetPlusWildcard.scala | 3 - sources/scala/util/automata/NondetWordAutom.scala | 29 +- sources/scala/util/automata/WordBerrySethi.scala | 51 +-- .../util/grammar/ImmutableTreeHedgeGrammar.scala | 3 +- .../util/grammar/MutableTreeHedgeGrammar.scala | 3 +- sources/scala/util/grammar/TreeHedgeGrammar.scala | 3 +- sources/scala/util/grammar/TreeRHS.scala | 4 +- sources/scala/util/regexp/Base.scala | 2 + sources/scala/util/regexp/PointedHedgeExp.scala | 10 +- sources/scala/util/regexp/WildcardBase.scala | 2 +- sources/scala/util/regexp/WordExp.scala | 11 +- sources/scala/xml/dtd/ContentModel.scala | 11 +- 23 files changed, 89 insertions(+), 885 deletions(-) delete mode 100644 sources/scala/tools/scalac/transformer/matching/FullRegularTranslator.scala delete mode 100644 sources/scala/tools/scalac/transformer/matching/MutableGrammar.scala delete mode 100644 sources/scala/tools/scalac/transformer/matching/NonTermFactory.scala delete mode 100644 sources/scala/tools/scalac/transformer/matching/PatternExp.scala delete mode 100644 sources/scala/tools/scalac/transformer/matching/PatternInfo.scala delete mode 100644 sources/scala/tools/scalac/transformer/matching/PatternTest.scala delete mode 100644 sources/scala/util/alphabet/Alphabet.scala delete mode 100644 sources/scala/util/alphabet/AlphabetPlusWildcard.scala (limited to 'sources') diff --git a/sources/scala/runtime/matching/PatternGrammar.scala b/sources/scala/runtime/matching/PatternGrammar.scala index e1fe1f85c6..c98ac350cd 100644 --- a/sources/scala/runtime/matching/PatternGrammar.scala +++ b/sources/scala/runtime/matching/PatternGrammar.scala @@ -126,7 +126,7 @@ object PatternGrammar { * following pre-order of occurrence in pattern * @caseVars an array, field i holding the number of variables in case i */ -abstract class PatternGrammar extends scala.util.grammar.ImmutableTreeHedgeGrammar[TestAlphabet] { +abstract class PatternGrammar extends scala.util.grammar.ImmutableTreeHedgeGrammar { val vars:Array[Int]; diff --git a/sources/scala/runtime/matching/TestAlphabet.scala b/sources/scala/runtime/matching/TestAlphabet.scala index c0c070d378..9ef4698ebc 100644 --- a/sources/scala/runtime/matching/TestAlphabet.scala +++ b/sources/scala/runtime/matching/TestAlphabet.scala @@ -1,13 +1,9 @@ package scala.runtime.matching ; -import scala.util.alphabet.{ AlphabetPlusWildcard, WildcardLabel }; - -trait TestAlphabet extends AlphabetPlusWildcard ; +trait TestAlphabet; case class TestLabel(i: Int) extends TestAlphabet ; -case object AnyNode extends TestAlphabet with WildcardLabel ; - -object TestAlphabetView { +case object AnyNode extends TestAlphabet { def view(x: Int): TestLabel = TestLabel(x); } diff --git a/sources/scala/tools/dtd2scala/DeclToScala.scala b/sources/scala/tools/dtd2scala/DeclToScala.scala index 7b21cb01ca..282909064b 100644 --- a/sources/scala/tools/dtd2scala/DeclToScala.scala +++ b/sources/scala/tools/dtd2scala/DeclToScala.scala @@ -12,7 +12,7 @@ import scala.collection.Map ; import scala.collection.mutable.HashMap ; import scala.xml._ ; -import scala.xml.dtd.{AttrDecl, ContentModel, ElemName, ElemDecl}; +import scala.xml.dtd.{AttrDecl, ContentModel, ElemDecl}; import ContentModel._ ; import scala.xml.dtd.{REQUIRED,IMPLIED,DEFAULT}; diff --git a/sources/scala/tools/scalac/transformer/TransMatch.scala b/sources/scala/tools/scalac/transformer/TransMatch.scala index 6cfc0d2122..1ec204f240 100644 --- a/sources/scala/tools/scalac/transformer/TransMatch.scala +++ b/sources/scala/tools/scalac/transformer/TransMatch.scala @@ -28,8 +28,7 @@ import scalac.transformer.matching.AlgebraicMatcher ; */ package scala.tools.scalac.transformer { - -import matching.FullRegularTranslator ; +//import matching.FullRegularTranslator ; class TransMatch( global:scalac_Global ) extends scalac_transformer_OwnerTransformer( global ) { @@ -112,14 +111,14 @@ class TransMatch( global:scalac_Global ) def transform( root:Tree, cases:Array[CaseDef], restpe:Type ):Tree = { if( global.newMatch ) { - val fm = new FullRegularTranslator( global ); - val gram = fm.MakeGrammar( scala.Iterator.fromArray( cases ) ); - Console.println("writing out the grammar to /tmp/encodedGrammar.bin"); - //val f = new FileOutputStream(new File("/tmp/encodedGrammar.bin")); - //f.write( gram.encode ); - //f.close(); - // val gram = Predef.decode( Predef.Array[] ); - Console.println( gram.encode); + //val fm = new FullRegularTranslator( global ); + //val gram = fm.MakeGrammar( scala.Iterator.fromArray( cases ) ); + //Console.println("writing out the grammar to /tmp/encodedGrammar.bin"); + ////val f = new FileOutputStream(new File("/tmp/encodedGrammar.bin")); + ////f.write( gram.encode ); + ////f.close(); + //// val gram = Predef.decode( Predef.Array[] ); + //Console.println( gram.encode); throw new ApplicationError("not impl."); }; diff --git a/sources/scala/tools/scalac/transformer/matching/FullRegularTranslator.scala b/sources/scala/tools/scalac/transformer/matching/FullRegularTranslator.scala deleted file mode 100644 index e5ce6b867d..0000000000 --- a/sources/scala/tools/scalac/transformer/matching/FullRegularTranslator.scala +++ /dev/null @@ -1,387 +0,0 @@ -import scala.runtime.matching._ ; - -import scala.collection.Set; -import scala.collection.Map; -import scala.collection.mutable; -import scala.collection.immutable; - -import scalac.ast._ ; -import scalac.{Global => scalac_Global} -import scalac.symtab._; -import scalac.util.Names ; - -package scala.tools.scalac.transformer.matching { - -/** generates from a pattern (with variable names v_1,..,v_k) - * a set of regular hedge grammar rules, - * together with an variable index mapping 1,..,k - * @todo: handle x @ z @ p correctly - */ -class FullRegularTranslator(global: scalac_Global) { - - val pe = new matching.PatternExp( global.definitions ); - import pe._ ; - - /* --- real variables --- */ - - /** the grammar that we build up incrementally */ - var cur:MutableGrammar = _; - - var isSequenceType = false; - - /** counter for variables indices */ - var varCounter = 0; - - /** counter for test indices */ - var testCounter = 0; - - /* initialized when Subst is encountered */ - var iteration:HedgeNT = _; - - /* initialized when Iter is encountered */ - var iterationEnd:HedgeNT = _; - - /* --- methods --- */ - - /** returns a variable index for this variable */ - def newVar( vble:Symbol ):Int = - cur.varMap.get( vble ) match { - case Some( x ) => x - case None => - val v = varCounter; - varCounter = v + 1; - cur.varMap.update( vble, v ); - v - } - - /** returns a test index for this variable */ - def newTest( test:PatternTest ):Int = - cur.invTest.get( test ) match { - case Some( x ) => x; - case None => - val x = testCounter; - testCounter = testCounter + 1; - cur.invTest.update( test, x ); - cur.tests.update( x, test ); - x - } - - /** returns a test index for this variable - def newTest( test:Tree ):Int = { - 0 // bogus - } - */ - - - - /** - * precondition: p.length > 0 - */ - def MakeGrammar( it:Iterator[Tree$CaseDef] ):PatternGrammar = { - DEBUGPRINT("MakeGrammar"); - var k = 0; - cur = InitialGrammar.make; - while( it.hasNext ) - translate( pe.fromTree(it.next.pat), { k = k + 1; k } ); - DEBUGPRINT(cur.toString()); - cur.toGrammar; - } - - /** p must be a pattern - */ - protected def translate( p:RegExp, k:Int ):unit = { - DEBUGPRINT("translate"); - this.varCounter = 0; - this.isSequenceType = isSequenceValued( p ); - if( this.isSequenceType ) { - MakeHedgeRule( cur.make.initialHedgeNT, EMPTYHEDGE, emptyVars, p ); - } else { - val in = cur.make.initialTreeNT; - try { - MakeTreeRule( in, emptyVars, p ); - } catch { - case _:WildcardException => - cur.treeRules += new AnyTreeRule( in ); - } - } - - if( global.debug ) { - for( val rule <- cur.treeRules ) { - DEBUGPRINT( rule.toString() ); - } - for( val rule <- cur.hedgeRules ) { - DEBUGPRINT( rule.toString() ); - } - DEBUGPRINT("=== Now Removing Chain Rules ==="); - }; - - RemoveChainRules; - - // update variable array with nvariable + 1 - cur.caseVars.update( k, this.varCounter ); - - } - - //val s: mutable.Set[Rule] = new mutable.HashSet[Rule](); /* the grammar */ - - //s += AnyTreeRule( ANYTREE ); - -/* TO BE DONE - -Afterwards: Chain rules need not be applied anymore. They only exist with - the unique rhs "h0" which produces empty hedge. - So, a Chainrule of NT only means that NT can derive the empty hedge -*/ - - def RemoveChainRules: unit = { - var replaced = true; - while (replaced==true) { - replaced = false; - for( val rule <- cur.hedgeRules ) { - rule match { - case HedgeChainRule( a, b ) => { - replaced = true; - DEBUGPRINT("chain rule"+rule); - cur.hedgeRules -= rule; - val B = b; - DEBUGPRINT( "b.nullable " + b.nullable); - DEBUGPRINT( "1a.nullable" + a.nullable ); - a.nullable = a.nullable || b.nullable; - DEBUGPRINT( "2a.nullable" + a.nullable ); - for( val brule <- cur.hedgeRules ) { - brule match { - case HedgeRule( B, t, h ) => - cur.hedgeRules += new HedgeRule( a, t, h ); - case HedgeChainRule( B, h ) => - cur.hedgeRules += new HedgeChainRule( a, h ) - case _ => - } - }; - } - case _ => - } - - } - }; - //Reachables; - } - - /* - def Reachables: unit = { - var reached = new mutable.HashSet[HedgeNT](); - reached += InitialHedgeNT; - var changed = true; - while( changed ) { - changed = false; - for( val rule <- rules ) { - rule match { - case HedgeRule( h, _,h2 ) => - if( !reached.contains(h2) ) { - changed = true; - reached += h2; - } - case _ => - } - } - }; - for( val rule <- rules ) { - rule match { - case HedgeRule( h, _,h2 ) => - if( !reached.contains(h) ) { - rules = rules - rule; - } - case HedgeChainRule(h , _ ) => - if( !reached.contains(h) ) { - rules = rules - rule; - } - case _ => - } - } - } - */ - - def sortByWidth( xs:Iterator[RegExp] ):List[RegExp] = { - - - def view( x:Pair[RegExp,int] ):Ordered[Pair[RegExp,int]] = - new Ordered[Pair[RegExp,int]] with Proxy( x ) { - def compareTo [b >: Pair[RegExp,int] <% Ordered[b]](that: b): int = - that match { - case Pair(p:RegExp,i:int) => - if( minimalWidth( x._1 ) == minimalWidth( p ) ) { - if( x._2 < i ) -1 else - if( x._2 == i ) 0 else 1 - } else if ( minimalWidth( x._1 ) > minimalWidth( p ) ) { - -1 - } else { - 1 - } - case _ => error("unexpected"); - } - }; - - var mySet = new immutable.TreeSet[Pair[RegExp,int]](); - var j = 1; - for( val p <- xs ) { - mySet = mySet + Pair(p,j); - j = j + 1; - }; - {for( val Pair(p,i) <- mySet.elements ) yield p}.toList.reverse; - - } - - /* invariant: (in < out) || (out == 0) - */ - def MakeHedgeRule( in:HedgeNT, - out:HedgeNT, - vset: immutable.Set[Int], - it:Iterator[RegExp] ):unit = { - DEBUGPRINT("MakeHedgeRule("+in+","+out+","+vset+","+it+")"); - var i = in; - if( !it.hasNext ) { - cur.hedgeRules += new HedgeChainRule(in, out); - } else { - while( it.hasNext ) { - val pat = it.next; - val nt = if( it.hasNext ) { cur.make.HedgeNT } else { out }; - MakeHedgeRule( i, nt, vset, pat ); - i = nt; - } - } - } - - /* - */ - def MakeHedgeRule( in:HedgeNT, nt:HedgeNT, vset:immutable.Set[Int], pat:RegExp):unit = - pat match { - - case Eps => - cur.hedgeRules += new HedgeChainRule( in, nt ); - /* - case Point() => - cur.hedgeRules += new HedgeChainRule(in, iteration); - cur.hedgeRules += new HedgeChainRule(in, iterationEnd); - */ - case x:Sequ => - MakeHedgeRule( in, nt, vset, x.rs.elements ); - - case x:Alt => - for( val z <- sortByWidth( x.rs.elements ) ) { - MakeHedgeRule( in, nt, vset, z ); - } - - case Star( p ) => - //case Tree$Bind(n, p) if TreeInfo.isNameOfStarPattern( n ) => - MakeHedgeRule( in, in, vset, p ); - cur.hedgeRules += new HedgeChainRule( in, nt ); - - // p^[ x ], nt - /* - case Iter( p, x ) => - - // sort by width - case 1 - if( minimalWidth( p ) < minimalWidth( x ) ) { - MakeHedgeRule( i, nt, vset, x ); // no iteration ==> x, nt - } - - iteration = cur.make.HedgeNT; - iterationEnd = cur.make.HedgeNT; - - MakeHedgeRule( i, nt, vset, p ); // unfold p [ # <- x ], nt - - MakeHedgeRule( iteration, EMPTYHEDGE, emptyVars, p ); - // unfold p [ # <- x + p] $END - MakeHedgeRule( iterationEnd, EMPTYHEDGE, emptyVars, x ); // x $END - // sort by width - case 2 - if( minimalWidth( p ) >= minimalWidth( x ) ) { - MakeHedgeRule( i, nt, vset, x ); // no iteration ==> x, nt - } - - // cleanup - iteration = null; - iterationEnd = null; - */ - case Binding( vble, p ) => - //case Tree$Bind( vble, p:Tree ) => - if (isSequenceValued( p )) { - MakeHedgeRule( in, nt, vset + newVar( vble ), p ); - } else { - Console.println(p); - Console.println(isSequenceValued( p )); - try { - val trNT = cur.make.TreeNT( vset ); - Console.println("made treeNT:"+trNT); - MakeTreeRule( trNT, vset, pat ); - cur.hedgeRules += new HedgeRule( in, trNT, nt ); - } catch { - case _:WildcardException => - cur.hedgeRules += new HedgeRule( in, ANYTREE, nt ); - } - } - case _ => - Console.println(pat); - Console.println(isSequenceValued( pat )); - try { - val trNT = cur.make.TreeNT( vset ); - Console.println("made treeNT:"+trNT); - MakeTreeRule( trNT, vset, pat ); - cur.hedgeRules += new HedgeRule( in, trNT, nt ); - } catch { - case _:WildcardException => - cur.hedgeRules += new HedgeRule( in, ANYTREE, nt ); - - } - } - - - def MakeTreeRule( in:TreeNT, vset: immutable.Set[Int], pat:RegExp):unit = { - DEBUGPRINT("MakeTreeRule("+in+","+vset+","+pat+")"); - pat match { - case Wildcard => - // WildcardTree() - // case Tree$Ident( Names.PATTERN_WILDCARD ) => - if( vset.isEmpty ) { - DEBUGPRINT("WILDCARD! discarding "+in); - throw new WildcardException(); // OPTIMIZATION to collapse _ rules - } else - cur.treeRules += new AnyTreeRule( in ); - // WildcardNode( x @ _* ) - case Node(WildcardTest, sequ) => - //case Tree$Apply( Tree$Ident( Names.PATTERN_WILDCARD ), xs ) => - { - val Children = cur.make.HedgeNT; - cur.treeRules += new AnyNodeRule( in, Children ); - MakeHedgeRule( Children, EMPTYHEDGE, emptyVars, sequ); - } - // Node( label:String, x @ _* ) => //p.type - case Node( theTest, sequ ) => - //case Tree$Apply( theTest, xs ) => - val test = newTest( theTest ); //p.type - val childrenNT = cur.make.HedgeNT; // make a new NT - cur.treeRules += new TreeRule(in, test, childrenNT ); - MakeHedgeRule( childrenNT, EMPTYHEDGE, emptyVars, sequ); - - case x:Alt => // is tree valued - for(val pat <- x.rs.elements ) - MakeTreeRule( in, vset, pat ); - - case Binding( vble, p ) => - in.vset = in.vset + newVar( vble ); - MakeTreeRule( in, in.vset, p ); - - case _ => //DEBUGPRINT("error, we found "+p.getClass()); - } - } // end MakeTreeRule - - - /* misc stuff */ - - def DEBUGPRINT( s:String ):unit = // misc DEBUG - if (global.debug) Console.println( s ); - - class WildcardException extends Exception ; // backtrack - - final val emptyVars = new immutable.TreeSet[Int](); // convenience - -} -} diff --git a/sources/scala/tools/scalac/transformer/matching/MutableGrammar.scala b/sources/scala/tools/scalac/transformer/matching/MutableGrammar.scala deleted file mode 100644 index 5829c2410d..0000000000 --- a/sources/scala/tools/scalac/transformer/matching/MutableGrammar.scala +++ /dev/null @@ -1,233 +0,0 @@ - -import scala.collection.immutable; -import scala.collection.mutable; -import scala.runtime.matching._; -import scalac.symtab._; - -import scala.util.grammar.{ AnyTreeRHS, LabelledRHS, TreeRHS, ConsRHS, HedgeRHS }; - -package scala.tools.scalac.transformer.matching { - - - -object InitialGrammar { - /** returns an initial grammar, with any tree rule and any hedge rule */ - def make:MutableGrammar = { - val initialTreeRules = new mutable.HashSet[TRule](); - initialTreeRules += AnyTreeRule( ANYTREE ); - val initialHedgeRules = new mutable.HashSet[HRule](); - val vars = new mutable.HashMap[Int,Int](); - val tests = new mutable.HashMap[Int,PatternTest]() ; - val z = new MutableGrammar( - initialTreeRules, - initialHedgeRules, - vars, - tests, - new NonTermFactory( ANYTREE.i+1, ANYHEDGE.i+1 ) - ); - z.varMap = new mutable.HashMap[Symbol, Int](); - z.invTest = new mutable.HashMap[PatternTest, Int](); - z - } -} - - -/** compile-time representation of patterns. This class treats all variable - * indices as sequence variables. - */ -case class MutableGrammar( treeRules:mutable.Set[TRule], - hedgeRules:mutable.Set[HRule], - caseVars:mutable.Map[Int,Int], - tests:mutable.Map[int,PatternTest], - make:NonTermFactory ) -{ - - var invTest:mutable.Map[PatternTest,int] = _; - - /** from variable names to indices. */ - var varMap:mutable.Map[Symbol, Int] = _; - - final def hedgeRulesToString:String = { - hedgeRules.foldLeft ("") { - (s:String,r:Rule) => s + (r match { - case HedgeRule( h, _, _ ) if ( make.hedgeInitials contains h ) => "*" - case _ => " " - }) + r.toString() + "\n" - } ; - } - - final def treeRulesToString:String = { - treeRules.foldLeft ("") { - (s:String,r:Rule) => s + (r match { - case TreeRule( t, _, _ ) if ( make.treeInitials contains t ) => "*" - case _ => " " - }) + r.toString() + "\n" - } ; - } - - override def toString(): String = { - val sb = new StringBuffer(); - sb.append( { if( treeRules.isEmpty ) - "Set of rules is EMPTY.\n" else treeRulesToString }); - sb.append( { if( hedgeRules.isEmpty ) - "Set of rules is EMPTY.\n" else hedgeRulesToString }); - - sb.append( "hedgeInitials:"+make.hedgeInitials ); - sb.append( "treeInitials:"+make.treeInitials ); - - //sb.append( "\nvariables :"+( caseVars( 0 ).map { debugVarMapping }) ); - sb.toString() - } - - protected def add[A]( i:Int, r:A, m:immutable.TreeMap[Int,immutable.Set[A]] ):immutable.TreeMap[Int,immutable.Set[A]] = - m.update( i, m.get( i ) match { - case Some( s ) => s + r; - case None => immutable.ListSet.Empty[A] + r; - }); - - /** converts this grammar in a pattern grammar (an ImmutableTreeHedgeGrammar with variable info) - */ - def toGrammar: PatternGrammar = { - val rbsNullable = new mutable.BitSet(); - var tnt = 0; - var renumber = new immutable.TreeMap[Int,Int]; - var invnum = new immutable.TreeMap[Int,Int]; - val _treeTransitions:Array[immutable.Set[TreeRHS]] = { - val theTreeTransitionsMap: immutable.TreeMap[Int,immutable.Set[TreeRHS]] = { - var tmp = immutable.TreeMap.Empty[Int,immutable.Set[TreeRHS]]; - val it = treeRules.elements; - while(it.hasNext) { - val tr = it.next; - //Console.print(tr.toString()+" ###"); - tr match { - case AnyTreeRule( t ) => - tmp = add( tnt, AnyTreeRHS, tmp ); - //Console.println(tnt); - //Console.println(tmp); - renumber = renumber.update(t.i, tnt); - invnum = invnum.update(tnt, t.i); - tnt = tnt+1; - case AnyNodeRule( t, _ ) => - Console.println("?!?! "+t); - // ?! - throw new RuntimeException("cannot handle!"); - case TreeRule( t, i, h ) => - tmp = add( tnt, LabelledRHS(TestLabel(i),h.i), tmp ); - - //Console.println(tnt); - //Console.println(tmp); - renumber = renumber.update(t.i, tnt); - invnum = invnum.update(tnt, t.i); - tnt = tnt+1; - } - } - tmp - }; - //Console.println("map size"+theTreeTransitionsMap.size); - //Console.println("mumap size"+treeRules.size); - val arr = new Array[immutable.Set[TreeRHS]]( theTreeTransitionsMap.size ); - val it = theTreeTransitionsMap.keys; - while( it.hasNext ) { - val k = it.next; - //Console.println(k+" which is t"+invnum(k)); - arr.update( k, theTreeTransitionsMap( k )); - } - arr - } - //Console.println("renumer T "+renumber); - //Console.println("DONE with trees"); - val _nTreeNT = _treeTransitions.length; - var renumberH = new immutable.TreeMap[Int,Int].update(0,0); - val it = hedgeRules.elements; - var hnt = 1; - while(it.hasNext) - it.next match { - case HedgeRule( h, t, h2 ) => - if(!renumberH.contains(h.i)) { - renumberH = renumberH.update(h.i,hnt); - hnt = hnt + 1; - } - if(!renumberH.contains(h2.i)) { - renumberH = renumberH.update(h2.i,hnt); - hnt = hnt + 1; - } - } - //Console.println("hedge renum"); - //Console.println(renumberH); - val _hedgeTransitions: Array[immutable.Set[HedgeRHS]] = { - val theHedgeTransitionsMap: immutable.TreeMap[Int,immutable.Set[HedgeRHS]] = { - var tmp = - immutable.TreeMap.Empty[Int,immutable.Set[HedgeRHS]] - // to maintain assumption that every hedge nt is present - .update(0, immutable.ListSet.Empty[HedgeRHS]); - - val it2 = hedgeRules.elements; - while(it2.hasNext) { - val hedgeRule = it2.next; - hedgeRule match { - case HedgeRule( h, t, h2 ) => - //Console.println(hedgeRule); - //Console.println("h"+h.i+" ===> "+renumberH(h.i)); - rbsNullable.ensureSize( renumberH(h2.i) ); - rbsNullable.set( renumberH(h2.i), h2.nullable ); - tmp = add( renumberH(h.i), ConsRHS(renumber(t.i),renumberH(h2.i)), tmp ); - Console.println("tmp = "+tmp); - }}; - tmp - }; - Console.println("hello, "+theHedgeTransitionsMap); - val arr = new Array[immutable.Set[HedgeRHS]]( theHedgeTransitionsMap.size ); - val it = theHedgeTransitionsMap.keys; - while( it.hasNext ) { - val k = it.next; - arr.update( k, theHedgeTransitionsMap( k )); - } - arr - } - //Console.println("DONE with hedges"); - val _nHedgeNT = _hedgeTransitions.length ; - - Console.println("caseVars: "+caseVars); - val _vars = new Array[Int]( caseVars.size ); - val it3 = caseVars.keys; - while( it3.hasNext ) { - val k = it3.next; - Console.println("caseVar: "+k); - _vars.update( k-1, caseVars( k )); - } - - val _treeInitials = { - val rbs = new mutable.BitSet( _nTreeNT ); - for( val k <- make.treeInitials ) { - rbs.set( k.i ) - } - new immutable.BitSet(rbs) - } - - val _hedgeInitials = { - val rbs = new mutable.BitSet( _nHedgeNT ); - for( val k <- make.hedgeInitials ) { - rbsNullable.ensureSize( k.i ); - rbsNullable.set( k.i, k.nullable ); - rbs.set( k.i ) - } - new immutable.BitSet(rbs) - } - val _isNullable = new immutable.BitSet( rbsNullable ); - new PatternGrammar { - val nTreeNT = _nTreeNT; - val nHedgeNT = _nHedgeNT; - val treeTransitions = _treeTransitions; - val hedgeTransitions = _hedgeTransitions; - val vars = _vars; - val treeInitials = _treeInitials; - val hedgeInitials = _hedgeInitials; - val isNullable = _isNullable; - // @todo - def test( test:int, inp:Any ):boolean = { false; }; - } - } - -} - -} diff --git a/sources/scala/tools/scalac/transformer/matching/NonTermFactory.scala b/sources/scala/tools/scalac/transformer/matching/NonTermFactory.scala deleted file mode 100644 index 50197b162e..0000000000 --- a/sources/scala/tools/scalac/transformer/matching/NonTermFactory.scala +++ /dev/null @@ -1,41 +0,0 @@ -package scala.tools.scalac.transformer.matching; - -import scala.runtime.matching.{TreeNT, HedgeNT}; -import scala.collection.immutable; - -/** factory for nonterminals. maintains list of initial nonterminals - */ -class NonTermFactory(treeInit: Int, hedgeInit: Int) { - - var treeInitials:immutable.Set[TreeNT] = new immutable.TreeSet[TreeNT](); - var hedgeInitials:immutable.Set[HedgeNT] = new immutable.TreeSet[HedgeNT](); - - private var treeCounter = treeInit; - private var hedgCounter = hedgeInit; - - def HedgeNT: HedgeNT = { - val x = new HedgeNT( hedgCounter ); - hedgCounter = hedgCounter + 1; - x - } - - def TreeNT( vs:immutable.Set[Int] ): TreeNT = { - val x = new TreeNT( treeCounter ); - x.vset = vs; - treeCounter = treeCounter + 1; - x - } - - def initialHedgeNT = { - val h = HedgeNT; - hedgeInitials = hedgeInitials + h; - h - } - - def initialTreeNT = { - val t = TreeNT( immutable.ListSet.Empty[Int] ); - treeInitials = treeInitials + t; - t - } - -} diff --git a/sources/scala/tools/scalac/transformer/matching/PatternExp.scala b/sources/scala/tools/scalac/transformer/matching/PatternExp.scala deleted file mode 100644 index d05413b799..0000000000 --- a/sources/scala/tools/scalac/transformer/matching/PatternExp.scala +++ /dev/null @@ -1,130 +0,0 @@ -import scalac.ast._ ; -import scalac.atree.AConstant ; -import scalac.symtab.{ Definitions, Modifiers, Symbol, Type} ; -import scalac.util.Name ; - -package scala.tools.scalac.transformer.matching { - - import scala.util.regexp.{ PointedHedgeExp, WildcardBase }; - - class PatternExp(defs: Definitions) - extends PointedHedgeExp[PatternTest] with WildcardBase { - type regexp = RegExp ; - - case class Binding(vble:Symbol, re:regexp) extends Meta( re ) ; - - def fromTrees( ts:Array[Tree] ):Seq[RegExp] = { - var nts: List[RegExp] = Nil; - val it = Iterator.fromArray( ts ); - while( it.hasNext ) - nts = fromTree( it.next ) :: nts; - nts.reverse - } - - def fromTree( t:Tree ):RegExp = { - import Tree._ ; - t match { - case Alternative(choices:Array[Tree]) => - Alt( fromTrees(choices):_* ) - - case Apply(s:Ident, args) if (s.symbol() == defs.PATTERN_WILDCARD) => - Node(WildcardTest, mkSequ(fromTrees( args ):_*)) - - case x @ Apply(_, args) => - if (isSeqApply( x )) // List(1,2,3) - Node(TypeTest( x.getType() ), mkSequ(fromTrees( args ):_*)) - - else if (isObjectRef( x )) // uncurry: foo.bar => foo.bar() - Node(EqualsValue( t ), Eps); - - else // case class constructor - Node(Constructor( t.getType() ), mkSequ(fromTrees( args ):_*)); - - case Bind(n: Name, t:Tree) => - if( TreeInfo.isNameOfStarPattern( n ) ) - Star(fromTree( t )) - else - Binding( t.symbol(), fromTree( t )) - - case Literal( c ) => - Node(EqualsValue( t ), Star(Wildcard)) - - case Ident( n:Name ) => - if( t.symbol() == defs.PATTERN_WILDCARD ) - Wildcard - else if( TreeInfo.isNameOfStarPattern( n ) ) - Eps; - else Node(EqualsValue( t ), Star(Wildcard)) - - case Select(_,_) => - Node(EqualsValue( t ), Star(Wildcard)) - - case Sequence( trees ) => - mkSequ(fromTrees( trees ):_*); - - case Typed(_,_) => - Node(TypeTest( t.getType() ), Eps) - - } - } - - /** these are treated like constant value */ - final def isObjectRef( t:Tree.Apply ):Boolean = { - val sym = t.fun.symbol(); - (sym != null) - && sym.isStable() - && !(sym.isModule() - && ((sym.flags & Modifiers.CASE) != 0)); - } - - final def isSeqApply( tree:Tree.Apply ):Boolean = { - ((tree.getType().symbol().flags & Modifiers.CASE) == 0) - && ( tree.args.length == 1 ) - && tree.args(0).isInstanceOf[Tree.Sequence] - } - - final def isSequenceValued( p:RegExp ):Boolean = p match { - case x:Alt => - val it = x.rs.elements; - while (it.hasNext) - if (isSequenceValued( it.next )) - return true; - return false; - case Binding(_,r) => isSequenceValued( r ) - case Eps => true; - case _:Node => false; - case _:Sequ => true; - case TopIter(l, r) => isSequenceValued( l )||isSequenceValued( r ); - case Point => false; - case Wildcard => false; - } - - /** returns width */ - private def getLowerBoundWidth( it:Iterator[RegExp] ):Int = { - if( !it.hasNext ) 0 else { - var wid = minimalWidth( it.next ); - for( val h <- it ) { - val hw = minimalWidth( h ); - if( hw < wid ) { - wid = hw - } - } - wid - } - } - - /** @todo translate this from ems pattern - */ - def minimalWidth( pat:RegExp ):Int = pat match { - case x:Alt => getLowerBoundWidth( x.rs.elements ); - case _:Node => 1 - case x:Sequ => - x.rs.elements.foldLeft (0) { - (s:int,x:RegExp) => s + minimalWidth( x ) - } - case Binding( _, r ) => minimalWidth( r ); - case _ => 0 - - } - } -} diff --git a/sources/scala/tools/scalac/transformer/matching/PatternInfo.scala b/sources/scala/tools/scalac/transformer/matching/PatternInfo.scala deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/sources/scala/tools/scalac/transformer/matching/PatternTest.scala b/sources/scala/tools/scalac/transformer/matching/PatternTest.scala deleted file mode 100644 index d2a2f31252..0000000000 --- a/sources/scala/tools/scalac/transformer/matching/PatternTest.scala +++ /dev/null @@ -1,17 +0,0 @@ -import scalac.ast.Tree ; -import scalac.atree.AConstant ; -import scalac.symtab.Type ; -import scala.util.alphabet.{ AlphabetPlusWildcard, WildcardLabel }; - -package scala.tools.scalac.transformer.matching { - - abstract class PatternTest extends AlphabetPlusWildcard ; - - case class Constructor( tpe:Type ) extends PatternTest ; - case class EqualsValue( value:Tree ) extends PatternTest; - case class TypeTest( tpe:Type ) extends PatternTest; - - case object WildcardTest extends PatternTest with WildcardLabel; - - -} diff --git a/sources/scala/util/alphabet/Alphabet.scala b/sources/scala/util/alphabet/Alphabet.scala deleted file mode 100644 index 57d10b6a7f..0000000000 --- a/sources/scala/util/alphabet/Alphabet.scala +++ /dev/null @@ -1,3 +0,0 @@ -package scala.util.alphabet ; - -trait Alphabet ; diff --git a/sources/scala/util/alphabet/AlphabetPlusWildcard.scala b/sources/scala/util/alphabet/AlphabetPlusWildcard.scala deleted file mode 100644 index 32b4c6a09a..0000000000 --- a/sources/scala/util/alphabet/AlphabetPlusWildcard.scala +++ /dev/null @@ -1,3 +0,0 @@ -package scala.util.alphabet ; - -trait AlphabetPlusWildcard extends Alphabet ; diff --git a/sources/scala/util/automata/NondetWordAutom.scala b/sources/scala/util/automata/NondetWordAutom.scala index 34a0e242da..9023bbd7e2 100644 --- a/sources/scala/util/automata/NondetWordAutom.scala +++ b/sources/scala/util/automata/NondetWordAutom.scala @@ -1,15 +1,16 @@ package scala.util.automata ; -import scala.util.alphabet.Alphabet ; import scala.collection.{ Set, Map, mutable }; /** 0 is always the only initial state */ -abstract class NondetWordAutom[ A <: Alphabet ] { +abstract class NondetWordAutom { + + type T_label; val nstates: Int; - val labels: Set[A] ; + val labels: Set[T_label] ; val finals: Map[Int,Int] ; - val delta: Function1[Int,Map[A,List[Int]]]; + val delta: Function1[Int,Map[T_label,List[Int]]]; val default: Array[List[Int]]; /** returns true if the state is final */ @@ -30,4 +31,24 @@ abstract class NondetWordAutom[ A <: Alphabet ] { /** returns true if there are no finite states */ final def isEmpty = finals.isEmpty; + override def toString() = { + val sb = new StringBuffer(); + sb.append("[nfa nstates="); + sb.append(nstates); + sb.append(" labels="); + sb.append(labels.toString()); + sb.append(" finals="); + sb.append(finals.toString()); + sb.append(" delta=\n"); + for( val i <- Iterator.range(0,nstates)) { + sb.append( i ); + sb.append("->"); + sb.append(delta(i).toString()); + sb.append('\n'); + sb.append(" _>"); + sb.append(default(i).mkString("",",","")); + sb.append('\n'); + } + sb.toString(); + } } diff --git a/sources/scala/util/automata/WordBerrySethi.scala b/sources/scala/util/automata/WordBerrySethi.scala index 680de0b460..dd37bf47d6 100644 --- a/sources/scala/util/automata/WordBerrySethi.scala +++ b/sources/scala/util/automata/WordBerrySethi.scala @@ -1,26 +1,29 @@ package scala.util.automata ; -import scala.util.alphabet.Alphabet ; import scala.util.regexp.WordExp ; -import scala.collection.{ mutable, Map } ; -import scala.collection.immutable ; +import scala.collection.{immutable, + mutable, + Map } ; -/** this turns a regexp over A into a NondetWordAutom over A using the +/** this turns a regexp into a NondetWordAutom using the * celebrated position automata construction (also called Berry-Sethi or * Glushkov) */ -abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { +abstract class WordBerrySethi extends BaseBerrySethi { - override val lang: WordExp[ A ]; - import lang.{Alt,Eps,Letter,Meta,RegExp,Sequ,Star} ; + override val lang: WordExp; + type T_label = this.lang.T_label; - protected var labels:mutable.HashSet[A] = _ ; + import lang.{Alt, Eps, Letter, Meta, RegExp, Sequ, Star} ; + + + protected var labels:mutable.HashSet[T_label] = _ ; // don't let this fool you, only labelAt is a real, surjective mapping - protected var labelAt: immutable.TreeMap[int, A] = _; // new alphabet "gamma" + protected var labelAt: immutable.TreeMap[Int, T_label] = _; // new alphabet "gamma" - protected var deltaq: Array[mutable.HashMap[A,List[Int]]] = _; // delta + protected var deltaq: Array[mutable.HashMap[T_label,List[Int]]] = _; // delta protected var defaultq: Array[List[Int]] = _; // default transitions @@ -60,7 +63,7 @@ abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { /** called at the leaves of the regexp */ - protected def seenLabel( r:RegExp, i:Int, label: A ): Unit = { + protected def seenLabel( r:RegExp, i:Int, label: T_label ): Unit = { this.posMap.update( r, i ); this.labelAt = this.labelAt.update( i, label ); //@ifdef if( label != Wildcard ) { @@ -69,7 +72,7 @@ abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { } // overriden in BindingBerrySethi - protected def seenLabel( r: RegExp, label: A ): Unit = { + protected def seenLabel( r: RegExp, label: T_label ): Unit = { pos = pos + 1; seenLabel( r, pos, label ); } @@ -82,7 +85,7 @@ abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { } - protected def makeTransition(src: Int, dest:Int, label: A ):Unit = { + protected def makeTransition(src: Int, dest:Int, label: T_label ):Unit = { //@ifdef compiler if( label == Wildcard ) //@ifdef compiler defaultq.update(src, dest::defaultq( src )) //@ifdef compiler else @@ -95,9 +98,9 @@ abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { protected def initialize(subexpr: Seq[RegExp]): Unit = { this.posMap = new mutable.HashMap[RegExp,Int](); - this.labelAt = new immutable.TreeMap[Int,A](); + this.labelAt = new immutable.TreeMap[Int,T_label](); this.follow = new mutable.HashMap[Int,immutable.Set[Int]](); - this.labels = new mutable.HashSet[A](); + this.labels = new mutable.HashSet[T_label](); this.pos = 0; @@ -114,26 +117,25 @@ abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { protected def initializeAutom(): Unit = { finals = immutable.TreeMap.Empty[Int,Int]; // final states - deltaq = new Array[mutable.HashMap[A,List[Int]]]( pos ); // delta + deltaq = new Array[mutable.HashMap[T_label,List[Int]]]( pos ); // delta defaultq = new Array[List[Int]]( pos ); // default transitions var j = 0; while( j < pos ) { - deltaq( j ) = new mutable.HashMap[A,List[Int]](); + deltaq( j ) = new mutable.HashMap[T_label,List[Int]](); defaultq( j ) = Nil; j = j + 1 } } protected def collectTransitions(): Unit = { // make transitions - var j = 0; - while( j < pos ) { + var j = 0; while( j < pos ) { val fol = this.follow( j ); val it = fol.elements; while( it.hasNext ) { val k = it.next; if( pos == k ) - finals.update( k, finalTag ) + finals = finals.update( k, finalTag ) else makeTransition( j, k, labelAt( k )) } @@ -141,7 +143,7 @@ abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { } } - def automatonFrom(pat: RegExp, finalTag: Int): NondetWordAutom[ A ] = { + def automatonFrom(pat: RegExp, finalTag: Int): NondetWordAutom = { this.finalTag = finalTag; pat match { @@ -159,8 +161,8 @@ abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { if( x.isNullable ) // initial state is final finals = finals.update( 0, finalTag ); - var delta1: immutable.TreeMap[Int,Map[A,List[Int]]] = - new immutable.TreeMap[Int,Map[A,List[Int]]]; + var delta1: immutable.TreeMap[Int,Map[T_label,List[Int]]] = + new immutable.TreeMap[Int,Map[T_label,List[Int]]]; var i = 0; while( i < deltaq.length ) { @@ -168,7 +170,8 @@ abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { i = i + 1; } - new NondetWordAutom[ A ] { + new NondetWordAutom { + type T_label = WordBerrySethi.this.T_label; val nstates = pos; val labels = WordBerrySethi.this.labels; val initials = WordBerrySethi.this.initials; diff --git a/sources/scala/util/grammar/ImmutableTreeHedgeGrammar.scala b/sources/scala/util/grammar/ImmutableTreeHedgeGrammar.scala index 85e1b779cc..74b331b1b9 100644 --- a/sources/scala/util/grammar/ImmutableTreeHedgeGrammar.scala +++ b/sources/scala/util/grammar/ImmutableTreeHedgeGrammar.scala @@ -1,6 +1,5 @@ package scala.util.grammar; -import scala.util.alphabet.Alphabet ; import scala.collection.immutable ; /** a mutable representation of hedge grammars. A hedge grammar over an @@ -9,7 +8,7 @@ import scala.collection.immutable ; * can derive the empty hedge are called "nullable". initials tree * or hedge nonterminals. */ -abstract class ImmutableTreeHedgeGrammar[ A <: Alphabet ] extends TreeHedgeGrammar { +abstract class ImmutableTreeHedgeGrammar extends TreeHedgeGrammar { /** number of tree nonterminals*/ val nTreeNT: Int; diff --git a/sources/scala/util/grammar/MutableTreeHedgeGrammar.scala b/sources/scala/util/grammar/MutableTreeHedgeGrammar.scala index d1ac0b0560..4eae49c01c 100644 --- a/sources/scala/util/grammar/MutableTreeHedgeGrammar.scala +++ b/sources/scala/util/grammar/MutableTreeHedgeGrammar.scala @@ -1,6 +1,5 @@ package scala.util.grammar; -import scala.util.alphabet.Alphabet ; import scala.collection.mutable ; /** a mutable representation of hedge grammars. A hedge grammar over an @@ -9,7 +8,7 @@ import scala.collection.mutable ; * can derive the empty hedge are called "nullable". initials tree * or hedge nonterminals. */ -class MutableTreeHedgeGrammar[ A <: Alphabet ] extends TreeHedgeGrammar[ A ] { +class MutableTreeHedgeGrammar[ A ] extends TreeHedgeGrammar { /** number of tree nonterminals*/ var nTreeNT: Int = 0; diff --git a/sources/scala/util/grammar/TreeHedgeGrammar.scala b/sources/scala/util/grammar/TreeHedgeGrammar.scala index 06af102869..f4807a31aa 100644 --- a/sources/scala/util/grammar/TreeHedgeGrammar.scala +++ b/sources/scala/util/grammar/TreeHedgeGrammar.scala @@ -1,6 +1,5 @@ package scala.util.grammar; -import scala.util.alphabet.Alphabet ; import scala.collection.{ BitSet, Set, mutable } ; /** a mutable representation of hedge grammars. A hedge grammar over an @@ -9,7 +8,7 @@ import scala.collection.{ BitSet, Set, mutable } ; * can derive the empty hedge are called "nullable". initials tree * or hedge nonterminals. */ -abstract class TreeHedgeGrammar[ A <: Alphabet ] { +abstract class TreeHedgeGrammar { /** number of tree nonterminals*/ def nTreeNT: Int; diff --git a/sources/scala/util/grammar/TreeRHS.scala b/sources/scala/util/grammar/TreeRHS.scala index 5c50b82370..e4d391e12f 100644 --- a/sources/scala/util/grammar/TreeRHS.scala +++ b/sources/scala/util/grammar/TreeRHS.scala @@ -1,11 +1,9 @@ package scala.util.grammar; -import scala.util.alphabet.Alphabet ; - /** right hand side of a tree production */ abstract class TreeRHS; /** right hand side of a tree production, labelled with a letter from an alphabet */ -case class LabelledRHS[A <: Alphabet](label: A, hnt: Int) extends TreeRHS; +case class LabelledRHS[A](label: A, hnt: Int) extends TreeRHS; case object AnyTreeRHS extends TreeRHS; diff --git a/sources/scala/util/regexp/Base.scala b/sources/scala/util/regexp/Base.scala index 502efc8cf3..ccaa820663 100644 --- a/sources/scala/util/regexp/Base.scala +++ b/sources/scala/util/regexp/Base.scala @@ -16,6 +16,7 @@ trait Base { case class Alt(rs: regexp*) extends RegExp { // check rs \in R,R,R* + // @todo: flattening if({ val it = rs.elements; !it.hasNext || {it.next; !it.hasNext }}) throw new SyntaxError("need at least 2 branches in Alt"); @@ -26,6 +27,7 @@ trait Base { } } case class Sequ(rs: regexp*) extends RegExp { + // @todo: flattening // check rs \in R,R* if({ val it = rs.elements; !it.hasNext }) throw new SyntaxError("need at least 1 item in Sequ"); diff --git a/sources/scala/util/regexp/PointedHedgeExp.scala b/sources/scala/util/regexp/PointedHedgeExp.scala index 0c1ce64f8f..cd32021d7f 100644 --- a/sources/scala/util/regexp/PointedHedgeExp.scala +++ b/sources/scala/util/regexp/PointedHedgeExp.scala @@ -2,20 +2,18 @@ package scala.util.regexp ; -import scala.util.alphabet.Alphabet ; - /** pointed regular hedge expressions, a useful subclass of * regular hedge expressions. */ -trait PointedHedgeExp[ A <: Alphabet ] extends Base { - - type label = A; +trait PointedHedgeExp extends Base { + type T_label; type regexp <: RegExp; - case class Node(label: A, r: regexp) extends RegExp { + case class Node(label: T_label, r: regexp) extends RegExp { final val isNullable = false; } + case class TopIter(r1: regexp, r2: regexp) extends RegExp { final val isNullable = r1.isNullable && r2.isNullable; //? } diff --git a/sources/scala/util/regexp/WildcardBase.scala b/sources/scala/util/regexp/WildcardBase.scala index d69192221d..0c1a62545c 100644 --- a/sources/scala/util/regexp/WildcardBase.scala +++ b/sources/scala/util/regexp/WildcardBase.scala @@ -6,7 +6,7 @@ package scala.util.regexp ; trait WildcardBase extends Base { type regexp <: RegExp; - case object Wildcard extends RegExp { + case object Wildcard extends RegExp { final val isNullable = false; } } diff --git a/sources/scala/util/regexp/WordExp.scala b/sources/scala/util/regexp/WordExp.scala index 875dd292a1..14557d9578 100644 --- a/sources/scala/util/regexp/WordExp.scala +++ b/sources/scala/util/regexp/WordExp.scala @@ -2,8 +2,6 @@ package scala.util.regexp ; -import scala.util.alphabet.Alphabet ; - /** regular word expressions. use them with an alphabet:
 abstract class IntLabels extends Alphabet;
 object IntWordExp extends WordExp[IntLabels] {
@@ -11,9 +9,14 @@ object IntWordExp extends WordExp[IntLabels] {
 };
  * 
*/ -trait WordExp[ A <: Alphabet ] extends Base { +trait WordExp extends Base { + + trait Label; + + type T_label <: Label; + type regexp <: RegExp ; - case class Letter(a: A) extends RegExp { + case class Letter(a: T_label) extends RegExp { final val isNullable = false; } diff --git a/sources/scala/xml/dtd/ContentModel.scala b/sources/scala/xml/dtd/ContentModel.scala index 2f9cc60080..09fd89d7e9 100644 --- a/sources/scala/xml/dtd/ContentModel.scala +++ b/sources/scala/xml/dtd/ContentModel.scala @@ -1,13 +1,14 @@ package scala.xml.dtd ; -abstract class ElemNames extends scala.util.alphabet.Alphabet; -case class ElemName(name: String) extends ElemNames { - override def toString() = "ElemName(\""+name+"\")"; -} -object ContentModel extends scala.util.regexp.WordExp[ElemNames] { +object ContentModel extends scala.util.regexp.WordExp { + type T_label = ElemName; type regexp = RegExp; + case class ElemName(name: String) extends Label { + override def toString() = "ElemName(\""+name+"\")"; + } + case object PCDATA_ extends RegExp { final val isNullable = false; override def toString() = "PCDATA_"; -- cgit v1.2.3