progs/fun/fun_tokens.sc
changeset 955 47acfd7f9096
parent 870 739039774cee
child 961 c0600f8b6427
--- a/progs/fun/fun_tokens.sc	Sat Nov 11 10:08:33 2023 +0000
+++ b/progs/fun/fun_tokens.sc	Fri Nov 17 20:06:43 2023 +0000
@@ -8,7 +8,7 @@
 //     amm fun_tokens.sc defs.fun
 //
 
-
+ 
 
 import scala.language.implicitConversions    
 import scala.language.reflectiveCalls 
@@ -40,20 +40,16 @@
 implicit def string2rexp(s : String) : Rexp = 
   charlist2rexp(s.toList)
 
-implicit def RexpOps(r: Rexp) = new {
+extension (s: String) {
+  def $ (r: Rexp) = RECD(s, r)
+}
+
+extension (r: Rexp) {
   def | (s: Rexp) = ALT(r, s)
   def % = STAR(r)
   def ~ (s: Rexp) = SEQ(r, s)
 }
 
-implicit def stringOps(s: String) = new {
-  def | (r: Rexp) = ALT(s, r)
-  def | (r: String) = ALT(s, r)
-  def % = STAR(s)
-  def ~ (r: Rexp) = SEQ(s, r)
-  def ~ (r: String) = SEQ(s, r)
-  def $ (r: Rexp) = RECD(s, r)
-}
 
 def nullable (r: Rexp) : Boolean = r match {
   case ZERO => false
@@ -81,7 +77,7 @@
 // extracts a string from value
 def flatten(v: Val) : String = v match {
   case Empty => ""
-  case Chr(c) => c.toString
+  case Chr(c) => c.toString  
   case Left(v) => flatten(v)
   case Right(v) => flatten(v)
   case Sequ(v1, v2) => flatten(v1) + flatten(v2)