mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-01-14 03:31:08 +00:00
demonstrate code block
This commit is contained in:
parent
67c77196f1
commit
844d34dd5d
@ -4,3 +4,6 @@
|
||||
; |___/_||_\__,_|_\_\___\___/___/\__/___|
|
||||
|
||||
; Change direction: W A S D
|
||||
|
||||
|
||||
labeled:
|
||||
|
@ -27,11 +27,13 @@ object PrintPrograms extends ZIOAppDefault:
|
||||
),
|
||||
"annotated-snake.asm" -> (Line.mkString _)
|
||||
.compose(Paragraph.mkLines)
|
||||
.compose((xs: List[CommentBlock]) => xs.map(CommentBlock.toParagraph))
|
||||
.compose((xs: List[AsmBlock]) => xs.map(AsmBlock.toParagraph))
|
||||
.apply(
|
||||
List(
|
||||
CommentBlock.fromMultiline(asciiArt),
|
||||
CommentBlock(List("Change direction: W A S D"))
|
||||
CommentBlock(List("Change direction: W A S D")),
|
||||
CodeBlock(None, Nil),
|
||||
CodeBlock(Some("labeled"), Nil)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -6,11 +6,27 @@ sealed trait AsmBlock
|
||||
|
||||
case class CommentBlock(xs: List[String]) extends AsmBlock
|
||||
|
||||
object CommentBlock:
|
||||
case class CodeBlock(name: Option[String], chunks: List[CodeBlock.Chunk]) extends AsmBlock
|
||||
|
||||
object CodeBlock:
|
||||
case class Chunk(label: Option[String], instructions: List[Chunk.Instruction])
|
||||
|
||||
object Chunk:
|
||||
case class Instruction(code: String, comment: Option[String])
|
||||
|
||||
object AsmBlock:
|
||||
def toParagraph(xs: AsmBlock): Paragraph =
|
||||
xs match
|
||||
case CommentBlock(ys) =>
|
||||
Paragraph(ys.map("; " + _))
|
||||
|
||||
case CodeBlock(oLabel, _) =>
|
||||
Paragraph(
|
||||
oLabel
|
||||
.map(_ + ":")
|
||||
.toList
|
||||
)
|
||||
|
||||
object CommentBlock:
|
||||
def fromMultiline(s: String): CommentBlock =
|
||||
CommentBlock(s.split("\\n").toList)
|
||||
|
Loading…
x
Reference in New Issue
Block a user