Skip to content
This repository has been archived by the owner on Jun 9, 2018. It is now read-only.

Commit

Permalink
refactor with a last separator
Browse files Browse the repository at this point in the history
  • Loading branch information
fperrad committed Mar 29, 2009
1 parent 82e7ebf commit 09c0afc
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Compiler.pir
Expand Up @@ -110,6 +110,8 @@ Return generated HTML for all of its children.
.param int has_ssep :opt_flag
.param string esep :optional
.param int has_esep :opt_flag
.param string lsep :optional
.param int has_lsep :opt_flag
.local pmc code, iter
code = new 'CodeString'
iter = node.'iterator'()
Expand All @@ -124,11 +126,16 @@ Return generated HTML for all of its children.
code .= ssep
L1:
code .= $P0
unless iter goto iter_end
unless has_esep goto L2
code .= esep
L2:
goto iter_loop
iter_end:
unless $I0 goto L3
unless has_lsep goto L3
code .= lsep
L3:
.return (code)
.end

Expand All @@ -149,7 +156,7 @@ Return generated HTML for all of its children.

.sub 'html' :method :multi(_, ['Markdown'; 'Document'])
.param pmc node
.tailcall self.'html_children'(node, '', "\n\n")
.tailcall self.'html_children'(node, '', "\n\n", "\n\n")
.end


Expand Down Expand Up @@ -229,10 +236,7 @@ Return generated HTML for all of its children.
.param pmc node
$S0 = "<blockquote>\n"
$S0 .= " "
$S1 = self.'html_children'(node, '', "\n\n")
$I0 = length $S1
dec $I0
$S1 = substr $S1, 0, $I0
$S1 = self.'html_children'(node, '', "\n\n", "\n")
$S0 .= $S1
$S0 .= "</blockquote>"
.local pmc code
Expand Down Expand Up @@ -285,10 +289,7 @@ Return generated HTML for all of its children.
$S1 = self.'html_children'(node)
goto L2
L1:
$S1 = self.'html_children'(node, "<p>", "</p>\n\n")
$I0 = length $S1
$I0 -= 2
$S1 = substr $S1, 0, $I0
$S1 = self.'html_children'(node, "<p>", "</p>\n\n", "</p>")
L2:
$S0 .= $S1
$S0 .= "</li>\n"
Expand Down

0 comments on commit 09c0afc

Please sign in to comment.