allow many paragraph output

This commit is contained in:
Mark Canlas 2022-12-04 17:17:55 -05:00
parent a7ab58f660
commit c9ac5ee14b
3 changed files with 10 additions and 8 deletions

View File

@ -5,6 +5,4 @@
; Change direction: W A S D
labeled:

View File

@ -29,7 +29,7 @@ object PrintPrograms extends ZIOAppDefault:
),
"annotated-snake.asm" -> (Line.mkString _)
.compose(Paragraph.mkLines)
.compose((xs: List[AsmBlock]) => xs.map(AsmBlock.toParagraph))
.compose((xs: List[AsmBlock]) => xs.flatMap(AsmBlock.toParagraphs))
.apply(
List(
CommentBlock.fromMultiline(asciiArt),

View File

@ -11,18 +11,22 @@ case class NamedCodeBlock(name: String, intents: List[AsmBlock.Intent]) extends
case class AnonymousCodeBlock(intents: List[AsmBlock.Intent]) extends AsmBlock
object AsmBlock:
def toParagraph(xs: AsmBlock): Paragraph =
def toParagraphs(xs: AsmBlock): List[Paragraph] =
xs match
case CommentBlock(ys) =>
Paragraph(ys.map("; " + _))
List(
Paragraph(ys.map("; " + _))
)
case NamedCodeBlock(label, _) =>
Paragraph(
List(label + ":")
List(
Paragraph(
List(label + ":")
)
)
case AnonymousCodeBlock(_) =>
Paragraph("")
Nil
case class Intent(label: Option[String], instructions: List[Intent.Instruction])