diff -r 47acfd7f9096 -r ae9782e62bdd progs/while-arrays/compile_bfc.sc --- a/progs/while-arrays/compile_bfc.sc Fri Nov 17 20:06:43 2023 +0000 +++ b/progs/while-arrays/compile_bfc.sc Tue Nov 28 11:42:31 2023 +0000 @@ -22,8 +22,6 @@ // fastparse used in this file is not yet supported // under ammonite. - -//> using toolkit latest //> using file compile_arrays2.sc import compile_arrays2._ @@ -120,8 +118,8 @@ def Fa[$ : P]: P[AExp] = P( "(" ~ AExp ~ ")" | P (Ident ~ "[" ~ AExp ~ "]").map{Ref(_, _)} - | P(Number).map{Num} - | P(Ident).map{Var} ) + | P(Number).map{Num(_)} + | P(Ident).map{Var(_)} ) // boolean expressions def BExp[$ : P]: P[BExp] = @@ -141,7 +139,7 @@ | P("if" ~ BExp ~ "then" ~ Block ~ "else" ~ Block).map{If(_, _, _)} | P("while" ~ BExp ~ "do" ~ Block).map{While(_, _)} | P("new(" ~ Ident ~ "[" ~ Number ~ "])").map{ArrayDef(_, _)} - | P("write(" ~ Ident ~ ")").map{Write} ) + | P("write(" ~ Ident ~ ")").map{Write(_)} ) def Stmts[$ : P]: P[Block] = P( P(Stmt ~ ";" ~ Stmts).map{ case (x, z) => x :: z } @@ -192,7 +190,6 @@ case '+' => "mem[ptr] := mem[ptr] + 1;" case '-' => "mem[ptr] := mem[ptr] - 1;" case '.' => "x := mem[ptr]; write x;" - //case ',' => "XXX" // "ptr = getchar();\n" case '[' => "while (mem[ptr] != 0) do {" case ']' => "skip};" case _ => "" @@ -322,8 +319,8 @@ //@main def all() = { bfc0(); bfc1(); bfc2(); bfc3(); bfc4() } -all() - +//all() +bfc4() @@ -341,4 +338,4 @@ //import compile_arrays2._ // // load fastparse -//import $ivy.`com.lihaoyi::fastparse:3.0.2` \ No newline at end of file +//import $ivy.`com.lihaoyi::fastparse:3.0.2`