Skip to content

Commit 2bf552e

Browse files
committed
Make printing EO AST easier
1 parent 5628b4f commit 2bf552e

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

  • backends/eolang/src/main/scala/org/polystat/odin/backend/eolang

backends/eolang/src/main/scala/org/polystat/odin/backend/eolang/ToEO.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ object ToEO {
2626

2727
implicit class ToEOOps[T, R](private val node: T) extends AnyVal {
2828
def toEO(implicit toEO: ToEO[T, R]): R = ToEO[T, R].toEO(node)
29+
30+
def toEOPretty(implicit toEO: ToEO[T, InlineOrLines]): String =
31+
ToEO[T, InlineOrLines]
32+
.toEO(node)
33+
.fold[String](
34+
identity,
35+
_.mkString("\n")
36+
)
37+
2938
}
3039

3140
}
@@ -39,10 +48,10 @@ object ToEO {
3948

4049
// Program
4150
// ///////////////////////////////////////////////////////////////////
42-
implicit val progToEO: ToEO[EOProg[EOExprOnly], Lines] =
43-
new ToEO[EOProg[EOExprOnly], Lines] {
51+
implicit val progToEO: ToEO[EOProg[EOExprOnly], InlineOrLines] =
52+
new ToEO[EOProg[EOExprOnly], InlineOrLines] {
4453

45-
override def toEO(node: EOProg[EOExprOnly]): Lines = {
54+
override def toEO(node: EOProg[EOExprOnly]): InlineOrLines = {
4655
val metas = node.metas.toEO.toIterable
4756
val program = node.bnds.flatMap(_.toEO.toIterable)
4857

0 commit comments

Comments
 (0)