From 78c885d6573df6f5bb2ca83704136f4520d8fef9 Mon Sep 17 00:00:00 2001 From: Alexey Date: Mon, 2 Mar 2020 19:41:32 +0300 Subject: [PATCH] fmt: add support for goto --- vlib/v/fmt/fmt.v | 6 ++++++ vlib/v/fmt/tests/simple_expected.vv | 2 ++ vlib/v/fmt/tests/simple_input.vv | 2 ++ 3 files changed, 10 insertions(+) diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 9ac38a7f0d..4a5f68fefb 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -195,6 +195,12 @@ fn (f mut Fmt) stmt(node ast.Stmt) { f.stmts(it.stmts) f.writeln('}') } + ast.GotoLabel { + f.writeln('$it.name:') + } + ast.GotoStmt { + f.writeln('goto $it.name') + } ast.LineComment { f.writeln('// $it.text') } diff --git a/vlib/v/fmt/tests/simple_expected.vv b/vlib/v/fmt/tests/simple_expected.vv index 95f2d6a5cd..260d92bcc0 100644 --- a/vlib/v/fmt/tests/simple_expected.vv +++ b/vlib/v/fmt/tests/simple_expected.vv @@ -3,9 +3,11 @@ fn hello() { a = 10 a++ -23 + goto lbl b := 42 println('hello') abc() + lbl: if true { a = 10 a++ diff --git a/vlib/v/fmt/tests/simple_input.vv b/vlib/v/fmt/tests/simple_input.vv index a2c1308f6a..ccd2a59cdb 100644 --- a/vlib/v/fmt/tests/simple_input.vv +++ b/vlib/v/fmt/tests/simple_input.vv @@ -4,9 +4,11 @@ fn hello() a = 10 a++ -23 + goto lbl b:= 42 println( 'hello' ) abc() + lbl: if true { a = 10 a++