1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: add support for goto

This commit is contained in:
Alexey 2020-03-02 19:41:32 +03:00 committed by GitHub
parent c6107276df
commit 78c885d657
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 0 deletions

View File

@ -195,6 +195,12 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
f.stmts(it.stmts) f.stmts(it.stmts)
f.writeln('}') f.writeln('}')
} }
ast.GotoLabel {
f.writeln('$it.name:')
}
ast.GotoStmt {
f.writeln('goto $it.name')
}
ast.LineComment { ast.LineComment {
f.writeln('// $it.text') f.writeln('// $it.text')
} }

View File

@ -3,9 +3,11 @@ fn hello() {
a = 10 a = 10
a++ a++
-23 -23
goto lbl
b := 42 b := 42
println('hello') println('hello')
abc() abc()
lbl:
if true { if true {
a = 10 a = 10
a++ a++

View File

@ -4,9 +4,11 @@ fn hello()
a = 10 a = 10
a++ a++
-23 -23
goto lbl
b:= 42 b:= 42
println( 'hello' ) println( 'hello' )
abc() abc()
lbl:
if true { if true {
a = 10 a = 10
a++ a++