Skip to content

Commit

Permalink
do not indent Begin body expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
vipentti committed Dec 9, 2023
1 parent b1ef2fb commit a8fad61
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
13 changes: 12 additions & 1 deletion src/Visp.Compiler/Syntax/SynWriter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@ module Write =

()

let private writeBodyNoIndent<'a>
(w: SynWriter)
(wrt: SynWriter -> WriteState -> 'a -> unit)
(items: seq<'a>)
=
newline w
writeSeq w WriteState.Body newline wrt items

let private writeBody<'a>
(w: SynWriter)
(wrt: SynWriter -> WriteState -> 'a -> unit)
Expand Down Expand Up @@ -628,7 +636,10 @@ module Write =
if kind = BeginKind.Do then
char w '('

writeBody w writeExpr expr
if kind = BeginKind.Do then
writeBody w writeExpr expr
else
writeBodyNoIndent w writeExpr expr

if kind = BeginKind.Do then
char w ')'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@ let visp_result_todo =
then
// line 22 @"cond-macro-1.visp"

// line 22 @"cond-macro-1.visp"
printfn ("body here1")
// line 22 @"cond-macro-1.visp"
printfn ("body here2")
()
// line 22 @"cond-macro-1.visp"
printfn ("body here1")
// line 22 @"cond-macro-1.visp"
printfn ("body here2")
()
else
// line 22 @"cond-macro-1.visp"
if CoreMethods.isTruthy(
CoreMethods.``lt``(1, 0))
then
// line 22 @"cond-macro-1.visp"

// line 22 @"cond-macro-1.visp"
printfn ("here1")
// line 22 @"cond-macro-1.visp"
printfn ("here2")
// line 22 @"cond-macro-1.visp"
printfn ("here1")
// line 22 @"cond-macro-1.visp"
printfn ("here2")
else
// line 22 @"cond-macro-1.visp"
if CoreMethods.isTruthy(
true)
then
// line 22 @"cond-macro-1.visp"

// line 22 @"cond-macro-1.visp"
printfn ("default1")
// line 22 @"cond-macro-1.visp"
printfn ("default2")
// line 22 @"cond-macro-1.visp"
printfn ("default1")
// line 22 @"cond-macro-1.visp"
printfn ("default2")
else
// line 22 @"cond-macro-1.visp"
failwith ("unreachable")
Expand Down

0 comments on commit a8fad61

Please sign in to comment.