diff options
author | buraq <buraq@epfl.ch> | 2004-08-13 14:31:28 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2004-08-13 14:31:28 +0000 |
commit | 8912797e9b6b5e0347ec10f8bd34b5d6cba51c0d (patch) | |
tree | bc29422b067b510dd1d24ba198bdfcf7e4a59638 /sources | |
parent | e5cd07a0e8d5f62145eb10813f72d6d058fe4e0e (diff) | |
download | scala-8912797e9b6b5e0347ec10f8bd34b5d6cba51c0d.tar.gz scala-8912797e9b6b5e0347ec10f8bd34b5d6cba51c0d.tar.bz2 scala-8912797e9b6b5e0347ec10f8bd34b5d6cba51c0d.zip |
fixes to regexp -> automata implementation(s)
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/util/automata/BaseBerrySethi.scala | 5 | ||||
-rw-r--r-- | sources/scala/util/automata/NondetWordAutom.scala | 2 | ||||
-rw-r--r-- | sources/scala/util/automata/WordBerrySethi.scala | 4 | ||||
-rw-r--r-- | sources/scala/util/regexp/Alphabet.scala | 5 | ||||
-rw-r--r-- | sources/scala/util/regexp/Base.scala | 4 | ||||
-rw-r--r-- | sources/scalac/transformer/matching/BerrySethi.java | 8 |
6 files changed, 10 insertions, 18 deletions
diff --git a/sources/scala/util/automata/BaseBerrySethi.scala b/sources/scala/util/automata/BaseBerrySethi.scala index c5c0725176..99bc193d91 100644 --- a/sources/scala/util/automata/BaseBerrySethi.scala +++ b/sources/scala/util/automata/BaseBerrySethi.scala @@ -76,6 +76,7 @@ abstract class BaseBerrySethi { return tmp }; tmp + case Star(t) => compLast(t); case _ => error("unexpected pattern " + r.getClass()); } @@ -129,7 +130,6 @@ abstract class BaseBerrySethi { case x:Star => fol = fol incl compFirst( x.r ); - this.follow.update( posMap( x ), fol ); compFollow1( fol, x.r ); case x:Sequ => @@ -167,6 +167,9 @@ abstract class BaseBerrySethi { case x:Meta => traverse( x.r ) + case Star(t) => + traverse(t) + case _ => error("unexp pattern "+ r.getClass()); } } diff --git a/sources/scala/util/automata/NondetWordAutom.scala b/sources/scala/util/automata/NondetWordAutom.scala index 95290d22c1..34a0e242da 100644 --- a/sources/scala/util/automata/NondetWordAutom.scala +++ b/sources/scala/util/automata/NondetWordAutom.scala @@ -6,7 +6,7 @@ import scala.collection.{ Set, Map, mutable }; /** 0 is always the only initial state */ abstract class NondetWordAutom[ A <: Alphabet ] { - val nstates: Int; + val nstates: Int; val labels: Set[A] ; val finals: Map[Int,Int] ; val delta: Function1[Int,Map[A,List[Int]]]; diff --git a/sources/scala/util/automata/WordBerrySethi.scala b/sources/scala/util/automata/WordBerrySethi.scala index 890c8cae1d..680de0b460 100644 --- a/sources/scala/util/automata/WordBerrySethi.scala +++ b/sources/scala/util/automata/WordBerrySethi.scala @@ -62,7 +62,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 = { this.posMap.update( r, i ); - this.labelAt.update( i, label ); + this.labelAt = this.labelAt.update( i, label ); //@ifdef if( label != Wildcard ) { this.labels += label ; //@ifdef } @@ -157,7 +157,7 @@ abstract class WordBerrySethi[ A <: Alphabet ] extends BaseBerrySethi { collectTransitions(); if( x.isNullable ) // initial state is final - finals.update( 0, finalTag ); + finals = finals.update( 0, finalTag ); var delta1: immutable.TreeMap[Int,Map[A,List[Int]]] = new immutable.TreeMap[Int,Map[A,List[Int]]]; diff --git a/sources/scala/util/regexp/Alphabet.scala b/sources/scala/util/regexp/Alphabet.scala deleted file mode 100644 index 718eea4c2f..0000000000 --- a/sources/scala/util/regexp/Alphabet.scala +++ /dev/null @@ -1,5 +0,0 @@ -// $Id$ - -package scala.util.regexp ; - -trait Alphabet ; diff --git a/sources/scala/util/regexp/Base.scala b/sources/scala/util/regexp/Base.scala index 58d80927f6..502efc8cf3 100644 --- a/sources/scala/util/regexp/Base.scala +++ b/sources/scala/util/regexp/Base.scala @@ -32,8 +32,8 @@ trait Base { final val isNullable = { val it = rs.elements; - while( it.hasNext && !it.next.isNullable ) {} - it.hasNext + while( it.hasNext && it.next.isNullable ) {} + !it.hasNext } } diff --git a/sources/scalac/transformer/matching/BerrySethi.java b/sources/scalac/transformer/matching/BerrySethi.java index e56fc548c3..589e147e87 100644 --- a/sources/scalac/transformer/matching/BerrySethi.java +++ b/sources/scalac/transformer/matching/BerrySethi.java @@ -291,9 +291,7 @@ class BerrySethi { } return first; - case Bind( Name n, Tree t ): - - Integer p = (Integer) this.posMap.get( pat ); + case Bind( Name n, Tree t ): // == can also be star TreeSet first = compFirst( t ); //System.out.print("BIND" + first); @@ -304,10 +302,6 @@ class BerrySethi { if( isStar( n ) ) fol.addAll( first ); // an iterated pattern - this.follow.put( p, fol.clone() ); - //System.out.println("Bind("+n+",...) first:"+first); - //System.out.println("Bind("+n+",...) follow:"+fol); - // continue to compute follow sets with adjusted fol return compFollow1( fol, t ); |