Fahad/Scala/POSIX.sc
changeset 33 8b5ed306e961
parent 31 238c98db6057
child 43 10e7a90d8e7a
equal deleted inserted replaced
32:fa92e8f089a2 33:8b5ed306e961
   245     val end = System.nanoTime()
   245     val end = System.nanoTime()
   246     println((end - start) / 1.0e9)
   246     println((end - start) / 1.0e9)
   247     result
   247     result
   248   }                                               //> time: [T](code: => T)T
   248   }                                               //> time: [T](code: => T)T
   249 
   249 
   250   val prog0 = """read n"""                        //> prog0  : String = read n
   250   
   251   //env(lexing_simp(WHILE_REGS, prog0))
   251   val abc = List('a', 'b', 'c')                   //> abc  : List[Char] = List(a, b, c)
   252 
   252   val nullRexp = null                             //> nullRexp  : Null = null
   253   println("Next test")                            //> Next test
   253   val myRexp = charlist2rexp(abc)                 //> myRexp  : greeter.POSIX.Rexp = SEQ(CHAR(a),SEQ(CHAR(b),CHAR(c)))
       
   254   val myRexp2 = string2rexp("FahadAusaf")         //> myRexp2  : greeter.POSIX.Rexp = SEQ(CHAR(F),SEQ(CHAR(a),SEQ(CHAR(h),SEQ(CHA
       
   255                                                   //| R(a),SEQ(CHAR(d),SEQ(CHAR(A),SEQ(CHAR(u),SEQ(CHAR(s),SEQ(CHAR(a),CHAR(f))))
       
   256                                                   //| ))))))
       
   257   
       
   258   RexpOps(myRexp2)                                //> res2: AnyRef{def |(s: greeter.POSIX.Rexp): greeter.POSIX.ALT; def %: greete
       
   259                                                   //| r.POSIX.STAR; def ~(s: greeter.POSIX.Rexp): greeter.POSIX.SEQ} = greeter.PO
       
   260                                                   //| SIX$$anonfun$main$1$$anon$1@37ecb28e
       
   261   
       
   262   stringOps("Fahad")                              //> res3: AnyRef{def |(r: greeter.POSIX.Rexp): greeter.POSIX.ALT; def |(r: Stri
       
   263                                                   //| ng): greeter.POSIX.ALT; def %: greeter.POSIX.STAR; def ~(r: greeter.POSIX.R
       
   264                                                   //| exp): greeter.POSIX.SEQ; def ~(r: String): greeter.POSIX.SEQ; def $(r: gree
       
   265                                                   //| ter.POSIX.Rexp): greeter.POSIX.RECD} = greeter.POSIX$$anonfun$main$1$$anon$
       
   266                                                   //| 2@14bea551
       
   267                                                   
       
   268 	size(myRexp2)                             //> res4: Int = 19
       
   269 	nullable(nullRexp)                        //> scala.MatchError: null
       
   270                                                   //| 	at greeter.POSIX$$anonfun$main$1.nullable$1(greeter.POSIX.scala:59)
       
   271                                                   //| 	at greeter.POSIX$$anonfun$main$1.apply$mcV$sp(greeter.POSIX.scala:202)
       
   272                                                   //| 	at org.scalaide.worksheet.runtime.library.WorksheetSupport$$anonfun$$exe
       
   273                                                   //| cute$1.apply$mcV$sp(WorksheetSupport.scala:76)
       
   274                                                   //| 	at org.scalaide.worksheet.runtime.library.WorksheetSupport$.redirected(W
       
   275                                                   //| orksheetSupport.scala:65)
       
   276                                                   //| 	at org.scalaide.worksheet.runtime.library.WorksheetSupport$.$execute(Wor
       
   277                                                   //| ksheetSupport.scala:75)
       
   278                                                   //| 	at greeter.POSIX$.main(greeter.POSIX.scala:3)
       
   279                                                   //| 	at greeter.POSIX.main(greeter.POSIX.scala)
       
   280 	
       
   281 	val newRexp = der('a',myRexp)
       
   282   
       
   283   
       
   284   
       
   285   
       
   286   
       
   287   
       
   288   
       
   289   
       
   290   
       
   291   
       
   292   
       
   293   
       
   294   
       
   295   
       
   296   
       
   297   
       
   298   
       
   299   
       
   300   
       
   301   
       
   302   
       
   303   //this is some crap
   254 }
   304 }