Permalink
Browse files

pretty: improve block/proc-arg formatting

  • Loading branch information...
1 parent a9d9061 commit da2eb3ee2aedfc9cb60f83894bbec8562c49c311 @vito committed May 27, 2012
Showing with 22 additions and 19 deletions.
  1. +22 −19 kernel/pretty.ay
View
@@ -180,6 +180,24 @@ Atomy AST open:
grouped(n)
+ braces-block(contents, left = /empty) =
+ align(left <+> (lbrace <+> body(contents)) nest(2) <+> rbrace) <||>
+ if(left empty?)
+ then: align((lbrace <+> vbody(contents)) nest(2) <$> rbrace)
+ else: align(left <+> (lbrace <$> vbody(contents)) nest(2) <$> rbrace)
+
+ proc-arg(left, contents) =
+ if(from(.top)?)
+ then:
+ block =
+ (colon <+> body(contents)) <||>
+ (colon <$> vbody(contents))
+
+ align((left <> block) nest(2))
+ else:
+ braces-block(contents, left)
+
+
/doc(b: Infix) :=
from(.infix):
( if(b private)
@@ -189,31 +207,16 @@ Atomy AST open:
unamb(b left) <+> text(b operator) <\> unamb(b right)
) hang(2)
- /doc(b: Block) := do:
- args =
+ /doc(b: Block) :=
+ braces-block(
+ b contents
if(b arguments empty?)
then: empty
- else: list(render-sequence(b arguments))
-
- contents = body(b contents)
-
- align(args <+> (lbrace </> contents) nest(2) <\> rbrace)
+ else: list(render-sequence(b arguments)))
/doc(c: Call) :=
from(.call) { unamb(c name) } <> tupled(render-sequence(c arguments))
- proc-arg(left, contents) =
- if(from(.top)?)
- then:
- block =
- (colon <+> body(contents)) <||>
- (colon <$> vbody(contents))
-
- align((left <> block) nest(2))
- else:
- align((left <+> lbrace <\> body(contents)) nest(2) <\> rbrace)
-
-
/doc(`(~x [~*ys] { ~*zs })) :=
proc-arg(
from(.compose) { unamb(x) } <+>

0 comments on commit da2eb3e

Please sign in to comment.