mirror of
https://github.com/mcanlas/6502-opcodes.git
synced 2025-01-14 03:31:08 +00:00
with comment
This commit is contained in:
parent
c9ac5ee14b
commit
54ffb91104
@ -6,3 +6,4 @@
|
||||
; Change direction: W A S D
|
||||
|
||||
labeled:
|
||||
; This is a subroutine description
|
||||
|
@ -54,6 +54,7 @@ object PrintPrograms extends ZIOAppDefault:
|
||||
),
|
||||
NamedCodeBlock(
|
||||
"labeled",
|
||||
"This is a subroutine description".some,
|
||||
List(
|
||||
AsmBlock.Intent(
|
||||
None,
|
||||
|
@ -6,24 +6,34 @@ sealed trait AsmBlock
|
||||
|
||||
case class CommentBlock(xs: List[String]) extends AsmBlock
|
||||
|
||||
case class NamedCodeBlock(name: String, intents: List[AsmBlock.Intent]) extends AsmBlock
|
||||
case class NamedCodeBlock(name: String, comment: Option[String], intents: List[AsmBlock.Intent]) extends AsmBlock
|
||||
|
||||
case class AnonymousCodeBlock(intents: List[AsmBlock.Intent]) extends AsmBlock
|
||||
|
||||
object AsmBlock:
|
||||
def toComment(s: String): String =
|
||||
"; " + s
|
||||
|
||||
def withIndent(s: String): String =
|
||||
" " + s
|
||||
|
||||
def toParagraphs(xs: AsmBlock): List[Paragraph] =
|
||||
xs match
|
||||
case CommentBlock(ys) =>
|
||||
List(
|
||||
Paragraph(ys.map("; " + _))
|
||||
Paragraph(ys.map(toComment))
|
||||
)
|
||||
|
||||
case NamedCodeBlock(label, _) =>
|
||||
List(
|
||||
case NamedCodeBlock(label, oComment, _) =>
|
||||
val headerParagraph =
|
||||
Paragraph(
|
||||
List(label + ":")
|
||||
List(label + ":") ++ oComment.map(toComment).map(withIndent).toList
|
||||
)
|
||||
)
|
||||
|
||||
val intentParagraphs =
|
||||
Nil
|
||||
|
||||
headerParagraph :: intentParagraphs
|
||||
|
||||
case AnonymousCodeBlock(_) =>
|
||||
Nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user