solutions/cw3/parser.sc
changeset 921 bb54e7aa1a3f
parent 919 53f08d873e09
child 959 64ec1884d860
equal deleted inserted replaced
920:7af2eea19646 921:bb54e7aa1a3f
   243 }
   243 }
   244 
   244 
   245 def eval(bl: Block) : Env = eval_bl(bl, Map())
   245 def eval(bl: Block) : Env = eval_bl(bl, Map())
   246 
   246 
   247 @main
   247 @main
   248 def main(file: String) = {
   248 def run(file: String) = {
   249   val contents = os.read(os.pwd / file)
   249   val contents = os.read(os.pwd / file)
   250   println(s"Lex $file: ")
   250   println(s"Lex $file: ")
   251   println(tokenise(contents))
   251   println(tokenise(contents))
   252   println(s"Parse $file: ")
   252   println(s"Parse $file: ")
   253   println(Stmts.parse_all(tokenise(contents)).head)
   253   println(Stmts.parse_all(tokenise(contents)).head)
   254   println(s"Eval $file: ")
   254   println(s"Eval $file: ")
   255   println(eval(Stmts.parse_all(tokenise(contents)).head))
   255   println(eval(Stmts.parse_all(tokenise(contents)).head))
       
   256 }
       
   257 
       
   258 @main
       
   259 def test(file: String) = {
       
   260   val contents = os.read(os.pwd / file)
       
   261   println(s"Lex $file: ")
       
   262   println(tokenise(contents))
       
   263   println(s"Parse $file: ")
       
   264   println(Stmts.parse_all(tokenise(contents)).head)
   256 }
   265 }
   257 
   266 
   258 /*
   267 /*
   259 println("Loops eval")
   268 println("Loops eval")
   260 val start = System.nanoTime()
   269 val start = System.nanoTime()