progs/token.scala
changeset 521 95af9beb4b7f
parent 520 2849c305b12d
child 529 5c28e4134ee1
equal deleted inserted replaced
520:2849c305b12d 521:95af9beb4b7f
   252 
   252 
   253 val prog1 = """read  n; write (n)"""
   253 val prog1 = """read  n; write (n)"""
   254 println(env(lexing_simp(WHILE_REGS, prog1)))
   254 println(env(lexing_simp(WHILE_REGS, prog1)))
   255 
   255 
   256 
   256 
   257 // Big Test
   257 // Bigger Test
   258 //==========
   258 //=============
   259 
   259 
   260 val prog2 = """
   260 val prog2 = """
   261 write "fib";
   261 write "fib";
   262 read n;
   262 read n;
   263 minus1 := 0;
   263 minus1 := 0;
   274 
   274 
   275 println("Tokens")
   275 println("Tokens")
   276 println(env(lexing_simp(WHILE_REGS, prog2)))
   276 println(env(lexing_simp(WHILE_REGS, prog2)))
   277 println(env(lexing_simp(WHILE_REGS, prog2)).filterNot{_._1 == "w"}.mkString("\n"))
   277 println(env(lexing_simp(WHILE_REGS, prog2)).filterNot{_._1 == "w"}.mkString("\n"))
   278 
   278 
   279 // some more timing tests
   279 // some more timing tests with
   280 for (i <- 1 to 101 by 10) {
   280 // i copies of the program
       
   281 
       
   282 for (i <- 1 to 21 by 10) {
   281   print(i.toString + ":  ")
   283   print(i.toString + ":  ")
   282   time(lexing_simp(WHILE_REGS, prog2 * i))
   284   time(lexing_simp(WHILE_REGS, prog2 * i))
   283 }
   285 }
   284 
   286 
   285 
   287