progs/lexer/token.sc
changeset 827 67c8a6e6a305
parent 729 b147a10be8dd
equal deleted inserted replaced
826:b0352633bf48 827:67c8a6e6a305
    39   lexing_simp(WHILE_REGS, s).collect(token)
    39   lexing_simp(WHILE_REGS, s).collect(token)
    40 
    40 
    41 
    41 
    42 
    42 
    43 
    43 
    44 @doc("Tokens for fib and loops programs.")
    44 @arg(doc = "Tokens for fib and loops programs.")
    45 @main
    45 @main
    46 def main() = {
    46 def main() = {
    47   println("Fib program")
    47   println("Fib program")
    48   println(tokenise(prog2))
    48   println(tokenise(prog2))
    49   println("Loops program")
    49   println("Loops program")
    52   for (i <- 0 to 20 by 5) {
    52   for (i <- 0 to 20 by 5) {
    53     println(f"$i%2.0f: ${time(tokenise(prog3 * i))._2}")
    53     println(f"$i%2.0f: ${time(tokenise(prog3 * i))._2}")
    54   }
    54   }
    55 
    55 
    56 }
    56 }
    57 
       
    58 
       
    59 
       
    60 
       
    61 
       
    62 
       
    63 
       
    64 
       
    65 
       
    66 
       
    67 
    57 
    68 
    58 
    69 
    59 
    70 
    60 
    71 // Primes program
    61 // Primes program
   100         n := n / f
    90         n := n / f
   101     };
    91     };
   102     f := f + 1
    92     f := f + 1
   103 }
    93 }
   104 */
    94 */
       
    95 
       
    96 
       
    97 // runs with amm2 and amm3