Skip to content

Commit

Permalink
Removed extraneous newline characters from empty pretty printed !begi…
Browse files Browse the repository at this point in the history
…n statements.
  • Loading branch information
Dave Gurnell committed Mar 16, 2009
1 parent 956a586 commit 74a63d4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion info.ss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

(define release-notes
'((p "Changes and additions:")
(ul (li "added new XML procedures: " (tt "xml-quotable?") ", " (tt "xml+quotable?") ", " (tt "xml-quote") " and " (tt "xml-empty?") "."))))
(ul (li "removed extraneous newlines generated when pretty printing empty begin statements."))))

(define primary-file
"mirrors.ss")
Expand Down
20 changes: 11 additions & 9 deletions javascript/render.ss
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,20 @@

; Custom printers --------------------------------

; BeginStatement -> void
; BeginStatement -> doc
(define (format-BeginStatement stmt)
(match stmt
[(struct BeginStatement (_ statements))
(if (null? statements)
(h-append)
(h-append (format-substatement (car statements))
(format-map (lambda (statement)
(h-append line
(format-substatement statement)))
(cdr statements)
formatters/StatementList)))]))
(format-BeginStatement-substatements statements)]))

; (listof statement) -> doc
(define (format-BeginStatement-substatements statements)
(cond [(null? statements) (h-append)]
[(empty-begin? (car statements)) (format-BeginStatement-substatements (cdr statements))]
[(null? (cdr statements)) (format-substatement (car statements))]
[else (h-append (format-substatement (car statements))
line
(format-BeginStatement-substatements (cdr statements)))]))

; Provide statements -----------------------------

Expand Down
12 changes: 9 additions & 3 deletions javascript/struct.ss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

; Procedures -------------------------------------

; statement -> void
(define (empty-begin? stmt)
(and (BeginStatement? stmt)
(andmap empty-begin? (BeginStatement-statements stmt))))

; any -> boolean
(define (javascript? item)
(or (SourceElement? item)
Expand All @@ -36,7 +41,8 @@
(provide/contract
[struct (BeginStatement Statement) ([location (or/c region? false/c)]
[statements (listof SourceElement?)])]
[javascript? procedure?]
[empty-begin? procedure?]
[javascript? procedure?]
[javascript-declaration? procedure?]
[javascript-statement? procedure?]
[javascript-expression? procedure?])
[javascript-statement? procedure?]
[javascript-expression? procedure?])

0 comments on commit 74a63d4

Please sign in to comment.