diff --git a/legacy/examples/avl_tree/lib/avl.mbt b/legacy/examples/avl_tree/lib/avl.mbt index a331c3c3..7f48f0ca 100644 --- a/legacy/examples/avl_tree/lib/avl.mbt +++ b/legacy/examples/avl_tree/lib/avl.mbt @@ -164,7 +164,7 @@ pub fn to_string[U : Show](self : T[U]) -> String { match self { Empty => "()" Node(Empty, v, Empty, _) => v.to_string() - Node(l, v, r, _) => "(\(l), \(v), \(r))" + Node(l, v, r, _) => "(\{l}, \{v}, \{r})" } } diff --git a/legacy/examples/avl_tree/main/main.mbt b/legacy/examples/avl_tree/main/main.mbt index 7b171a62..d04a88da 100644 --- a/legacy/examples/avl_tree/main/main.mbt +++ b/legacy/examples/avl_tree/main/main.mbt @@ -21,7 +21,7 @@ fn main { v = v.add(i) } let height = v.height() - println("height of the tree: \(height)") + println("height of the tree: \{height}") v.print_tree() // Check values from 0 to iter-1 in the AVL tree diff --git a/moonbit-docs/docs/examples/gmachine-1/index.md b/moonbit-docs/docs/examples/gmachine-1/index.md index 72130a98..49eb8c6b 100644 --- a/moonbit-docs/docs/examples/gmachine-1/index.md +++ b/moonbit-docs/docs/examples/gmachine-1/index.md @@ -445,7 +445,7 @@ The `PushGlobal` instruction retrieves the address of the specified super combin fn pushglobal(self : GState, name : String) { let sc = self.globals[name] match sc { - None => abort("pushglobal(): cant find super combinator \(name)") + None => abort("pushglobal(): cant find super combinator \{name}") Some(addr) => { self.putStack(addr) } @@ -462,7 +462,7 @@ fn pusharg(self : GState, offset : Int) { let appaddr = nth(self.stack, offset + 1) let arg = match self.heap[appaddr] { NApp(_, arg) => arg - otherwise => abort("pusharg: stack offset \(offset) address \(appaddr) node \(otherwise), not a applicative node") + otherwise => abort("pusharg: stack offset \{offset} address \{appaddr} node \{otherwise}, not a applicative node") } self.putStack(arg) } @@ -517,7 +517,7 @@ fn unwind(self : GState) { self.putStack(a) self.putCode(Cons(Unwind, Nil)) } - otherwise => abort("unwind() : wrong kind of node \(otherwise), address \(addr)") + otherwise => abort("unwind() : wrong kind of node \{otherwise}, address \{addr}") } } ``` @@ -651,9 +651,9 @@ fn reify(self : GState) { match stack { Cons(addr, Nil) => { let res = self.heap[addr] - println("\(res)") + println("\{res}") } - _ => abort("wrong stack \(stack)") + _ => abort("wrong stack \{stack}") } } } diff --git a/moonbit-docs/docs/examples/gmachine-2.md b/moonbit-docs/docs/examples/gmachine-2.md index 4fc99b7e..4cd76d9c 100644 --- a/moonbit-docs/docs/examples/gmachine-2.md +++ b/moonbit-docs/docs/examples/gmachine-2.md @@ -246,7 +246,7 @@ fn liftArith2(self : GState, op : (Int, Int) -> Int) -> Unit { let addr = self.heap.alloc(newnode) self.putStack(addr) } - (node1, node2) => abort("liftArith2: \(a1) = \(node1) \(a2) = \(node2)") + (node1, node2) => abort("liftArith2: \{a1} = \{node1} \{a2} = \{node2}") } } @@ -260,7 +260,7 @@ fn liftCmp2(self : GState, op : (Int, Int) -> Bool) -> Unit { let addr = self.heap.alloc(newnode) self.putStack(addr) } - (node1, node2) => abort("liftCmp2: \(a1) = \(node1) \(a2) = \(node2)") + (node1, node2) => abort("liftCmp2: \{a1} = \{node1} \{a2} = \{node2}") } } @@ -274,7 +274,7 @@ fn negate(self : GState) -> Unit { } otherwise => { // If not NNum, throw an error - abort("negate: wrong kind of node \(otherwise), address \(addr) ") + abort("negate: wrong kind of node \{otherwise}, address \{addr} ") } } } @@ -294,7 +294,7 @@ fn condition(self : GState, i1 : List[Instruction], i2 : List[Instruction]) -> U // If true, jump to i1 self.code = append(i1, self.code) } - otherwise => abort("cond : \(addr) = \(otherwise)") + otherwise => abort("cond : \{addr} = \{otherwise}") } } ``` diff --git a/moonbit-docs/docs/examples/gmachine-3.md b/moonbit-docs/docs/examples/gmachine-3.md index 7aae97d4..e6cb7625 100644 --- a/moonbit-docs/docs/examples/gmachine-3.md +++ b/moonbit-docs/docs/examples/gmachine-3.md @@ -233,7 +233,7 @@ fn casejump(self : GState, table : List[(Int, List[Instruction])]) -> Unit { } } } - otherwise => abort("casejump(): addr = \(addr) node = \(otherwise)") + otherwise => abort("casejump(): addr = \{addr} node = \{otherwise}") } } ``` diff --git a/moonbit-docs/docs/examples/lambda.md b/moonbit-docs/docs/examples/lambda.md index 727039e4..d8a1ddac 100644 --- a/moonbit-docs/docs/examples/lambda.md +++ b/moonbit-docs/docs/examples/lambda.md @@ -72,7 +72,7 @@ fn subst(self : Term, var : String, term : Term) -> Term { Abs(variable, body) => { if freeVars.contains(variable) { // The variable name is in the set of free variables of the current inner Lambda, indicating variable capture - abort("subst(): error while encountering \(variable)") + abort("subst(): error while encountering \{variable}") } else { ...... } @@ -114,8 +114,8 @@ However, directly writing and reading Lambda terms in de Bruijn index form is pa fn to_string(self : TermDBI) -> String { match self { Var(name, _) => name - Abs(name, body) => "(\\\(name).\(body))" - App(t1, t2) => "\(t1) \(t2)" + Abs(name, body) => "(\\\{name}.\{body})" + App(t1, t2) => "\{t1} \{t2}" } } ``` @@ -214,7 +214,7 @@ fn eval(self : TermDBI) -> TermDBI { } } Abs(_) => self - otherwise => abort("eval(): \(otherwise) ") + otherwise => abort("eval(): \{otherwise} ") // eval should not encounter free variables } } diff --git a/moonbit-docs/docs/examples/myers-diff2.md b/moonbit-docs/docs/examples/myers-diff2.md index b20dec5b..10fe761b 100644 --- a/moonbit-docs/docs/examples/myers-diff2.md +++ b/moonbit-docs/docs/examples/myers-diff2.md @@ -141,21 +141,21 @@ fn print_edit(edit : Edit) -> String { let old_line = pad_right("", line_width) let new_line = pad_right(edit.new.number.to_string(), line_width) let text = edit.new.text - "\(tag) \(old_line) \(new_line) \(text)" + "\{tag} \{old_line} \{new_line} \{text}" } Delete(_) as edit => { let tag = "-" let old_line = pad_right(edit.old.number.to_string(), line_width) let new_line = pad_right("", line_width) let text = edit.old.text - "\(tag) \(old_line) \(new_line) \(text)" + "\{tag} \{old_line} \{new_line} \{text}" } Equal(_) as edit => { let tag = " " let old_line = pad_right(edit.old.number.to_string(), line_width) let new_line = pad_right(edit.new.number.to_string(), line_width) let text = edit.old.text - "\(tag) \(old_line) \(new_line) \(text)" + "\{tag} \{old_line} \{new_line} \{text}" } } } diff --git a/moonbit-docs/docs/examples/myers-diff3.md b/moonbit-docs/docs/examples/myers-diff3.md index d005b9df..c18e039e 100644 --- a/moonbit-docs/docs/examples/myers-diff3.md +++ b/moonbit-docs/docs/examples/myers-diff3.md @@ -110,9 +110,9 @@ fn find_path(box : Box, a : Array[Line], b : Array[Line]) -> Iter[(Int, Int)]? { let end = snake.end; let headbox = Box { left: box.left, top: box.top, right: start.0, bottom: start.1 }; let tailbox = Box { left: end.0, top: end.1, right: box.right, bottom: box.bottom }; - // println("snake = \(snake)") - // println("headbox = \(headbox)") - // println("tailbox = \(tailbox)") + // println("snake = \{snake}") + // println("headbox = \{headbox}") + // println("tailbox = \{tailbox}") let head = find_path(headbox, a, b).or(Iter::singleton(start)); let tail = find_path(tailbox, a, b).or(Iter::singleton(end)); Some(head.concat(tail)) diff --git a/moonbit-docs/docs/examples/sudoku/index.md b/moonbit-docs/docs/examples/sudoku/index.md index 9a0f4ad3..9ae06f0a 100644 --- a/moonbit-docs/docs/examples/sudoku/index.md +++ b/moonbit-docs/docs/examples/sudoku/index.md @@ -89,7 +89,7 @@ fn square_to_int(s : String) -> Int { let col = s[1].to_int() - 49 // '1' <=> 0 return row * 9 + col } else { - abort("square_to_int(): \(s) is not a square") + abort("square_to_int(): \{s} is not a square") } } diff --git a/moonbit-docs/docs/ffi-and-wasm-host.md b/moonbit-docs/docs/ffi-and-wasm-host.md index 8fc63f75..e5e0ecb9 100644 --- a/moonbit-docs/docs/ffi-and-wasm-host.md +++ b/moonbit-docs/docs/ffi-and-wasm-host.md @@ -145,7 +145,7 @@ pub fn draw(self : Canvas_ctx) -> Unit { // We also demonstrate the `println` functionality here pub fn display_pi() -> Unit { - println("PI: \(pi)") + println("PI: \{pi}") } ``` diff --git a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-1/index.md b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-1/index.md index f8c746be..96e732ff 100644 --- a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-1/index.md +++ b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-1/index.md @@ -450,7 +450,7 @@ PushGlobal指令从全局表中找到指定超组合子的地址,然后将地 fn pushglobal(self : GState, name : String) { let sc = self.globals[name] match sc { - None => abort("pushglobal(): cant find supercombinator \(name)") + None => abort("pushglobal(): cant find supercombinator \{name}") Some(addr) => { self.putStack(addr) } @@ -467,7 +467,7 @@ fn pusharg(self : GState, offset : Int) { let appaddr = nth(self.stack, offset + 1) let arg = match self.heap[appaddr] { NApp(_, arg) => arg - otherwise => abort("pusharg: stack offset \(offset) address \(appaddr) node \(otherwise), not a applicative node") + otherwise => abort("pusharg: stack offset \{offset} address \{appaddr} node \{otherwise}, not a applicative node") } self.putStack(arg) } @@ -522,7 +522,7 @@ fn unwind(self : GState) { self.putStack(a) self.putCode(Cons(Unwind, Nil)) } - otherwise => abort("unwind() : wrong kind of node \(otherwise), address \(addr)") + otherwise => abort("unwind() : wrong kind of node \{otherwise}, address \{addr}") } } ``` @@ -660,9 +660,9 @@ fn reify(self : GState) { match stack { Cons(addr, Nil) => { let res = self.heap[addr] - println("\(res)") + println("\{res}") } - _ => abort("wrong stack \(stack)") + _ => abort("wrong stack \{stack}") } } } diff --git a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-2.md b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-2.md index 74fb887f..6bd8dd7b 100644 --- a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-2.md +++ b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-2.md @@ -254,7 +254,7 @@ fn liftArith2(self : GState, op : (Int, Int) -> Int) -> Unit { let addr = self.heap.alloc(newnode) self.putStack(addr) } - (node1, node2) => abort("liftArith2: \(a1) = \(node1) \(a2) = \(node2)") + (node1, node2) => abort("liftArith2: \{a1} = \{node1} \{a2} = \{node2}") } } @@ -268,7 +268,7 @@ fn liftCmp2(self : GState, op : (Int, Int) -> Bool) -> Unit { let addr = self.heap.alloc(newnode) self.putStack(addr) } - (node1, node2) => abort("liftCmp2: \(a1) = \(node1) \(a2) = \(node2)") + (node1, node2) => abort("liftCmp2: \{a1} = \{node1} \{a2} = \{node2}") } } @@ -282,7 +282,7 @@ fn negate(self : GState) -> Unit { } otherwise => { // 不是NNum 直接报错 - abort("negate: wrong kind of node \(otherwise), address \(addr) ") + abort("negate: wrong kind of node \{otherwise}, address \{addr} ") } } } @@ -303,7 +303,7 @@ fn condition(self : GState, i1 : List[Instruction], i2 : List[Instruction]) -> U // true, 跳转i1 self.code = append(i1, self.code) } - otherwise => abort("cond : \(addr) = \(otherwise)") + otherwise => abort("cond : \{addr} = \{otherwise}") } } diff --git a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-3.md b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-3.md index 9b6474a2..d2309b0e 100644 --- a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-3.md +++ b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/gmachine-3.md @@ -233,7 +233,7 @@ fn casejump(self : GState, table : List[(Int, List[Instruction])]) -> Unit { } } } - otherwise => abort("casejump(): addr = \(addr) node = \(otherwise)") + otherwise => abort("casejump(): addr = \{addr} node = \{otherwise}") } } ``` diff --git a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/lambda.md b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/lambda.md index f09ee54d..ad87683b 100644 --- a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/lambda.md +++ b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/lambda.md @@ -71,7 +71,7 @@ fn subst(self : Term, var : String, term : Term) -> Term { Abs(variable, body) => { if freeVars.contains(variable) { //自由变量集合中有当前这个内层lambda的参数名,即会发生变量捕获 - abort("subst(): error while encountering \(variable)") + abort("subst(): error while encountering \{variable}") } else { ...... } @@ -113,8 +113,8 @@ enum TermDBI { fn to_string(self : TermDBI) -> String { match self { VarDBI(name, _) => name - AbsDBI(name, body) => "(\\\(name).\(body))" - AppDBI(t1, t2) => "\(t1) \(t2)" + AbsDBI(name, body) => "(\\\{name}.\{body})" + AppDBI(t1, t2) => "\{t1} \{t2}" } } ``` @@ -142,7 +142,7 @@ struct Index { // 查找环境中第一个varname对应的整数 fn find(m : List[Index], varname : String) -> Result[Int, String] { match m { - Nil => Err(varname) // abort("variable \'\(varname)\' not found") + Nil => Err(varname) // abort("variable \'\{varname}\' not found") Cons(i, rest) => { if i.name == varname { Ok(i.depth) @@ -201,7 +201,7 @@ fn eval(self : TermDBI) -> TermDBI { } } AbsDBI(_) => self - otherwise => abort("eval(): \(otherwise) ") + otherwise => abort("eval(): \{otherwise} ") // eval应该不会遇到自由变量才对 } } diff --git a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/myers-diff2.md b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/myers-diff2.md index b5cc408e..3ac83ae2 100644 --- a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/myers-diff2.md +++ b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/myers-diff2.md @@ -141,21 +141,21 @@ fn print_edit(edit : Edit) -> String { let old_line = pad_right("", line_width) let new_line = pad_right(edit.new.number.to_string(), line_width) let text = edit.new.text - "\(tag) \(old_line) \(new_line) \(text)" + "\{tag} \{old_line} \{new_line} \{text}" } Delete(_) as edit => { let tag = "-" let old_line = pad_right(edit.old.number.to_string(), line_width) let new_line = pad_right("", line_width) let text = edit.old.text - "\(tag) \(old_line) \(new_line) \(text)" + "\{tag} \{old_line} \{new_line} \{text}" } Equal(_) as edit => { let tag = " " let old_line = pad_right(edit.old.number.to_string(), line_width) let new_line = pad_right(edit.new.number.to_string(), line_width) let text = edit.old.text - "\(tag) \(old_line) \(new_line) \(text)" + "\{tag} \{old_line} \{new_line} \{text}" } } } diff --git a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/myers-diff3.md b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/myers-diff3.md index 69c226bc..b6f1c0cb 100644 --- a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/myers-diff3.md +++ b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/myers-diff3.md @@ -110,9 +110,9 @@ fn find_path(box : Box, a : Array[Line], b : Array[Line]) -> Iter[(Int, Int)]? { let end = snake.end let headbox = Box::{ left : box.left, top : box.top, right : start.0, bottom : start.1 } let tailbox = Box::{ left : end.0, top : end.1, right : box.right, bottom : box.bottom } - // println("snake = \(snake)") - // println("headbox = \(headbox)") - // println("tailbox = \(tailbox)") + // println("snake = \{snake}") + // println("headbox = \{headbox}") + // println("tailbox = \{tailbox}") let head = find_path(headbox, a, b).or(Iter::singleton(start)) let tail = find_path(tailbox, a, b).or(Iter::singleton(end)) Some(head.concat(tail)) diff --git a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/sudoku/index.md b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/sudoku/index.md index 98c00bc9..4cc73ac2 100644 --- a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/sudoku/index.md +++ b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/examples/sudoku/index.md @@ -91,7 +91,7 @@ fn square_to_int(s : String) -> Int { let col = s[1].to_int() - 49 // '1' <=> 0 return row * 9 + col } else { - abort("square_to_int(): \(s) is not a square") + abort("square_to_int(): \{s} is not a square") } } diff --git a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/ffi-and-wasm-host.md b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/ffi-and-wasm-host.md index 99f20fc8..dc36d964 100644 --- a/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/ffi-and-wasm-host.md +++ b/moonbit-docs/i18n/zh/docusaurus-plugin-content-docs/current/ffi-and-wasm-host.md @@ -145,7 +145,7 @@ pub fn draw(self : Canvas_ctx) -> Unit { // 我们在这里也演示`println`的功能 pub fn display_pi() -> Unit { - println("PI: \(pi)") + println("PI: \{pi}") } ```