Skip to content

Commit

Permalink
Fixed bug where named function declarations would not be allowed in !…
Browse files Browse the repository at this point in the history
…begin blocks;

renamed js-debug and JD-DEBUG to debug-js and DEBUG-JS;
added xml-debug and XML-DEBUG forms.
  • Loading branch information
Dave Gurnell committed Jun 20, 2009
1 parent 3d2cd34 commit 68d01d2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 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 "nothing yet...")))
(ul (li "named function declarations are now allowed within !begin blocks;"))))

(define primary-file "mirrors.ss")

Expand Down
30 changes: 18 additions & 12 deletions javascript/render.ss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

(require "../base.ss")

(require (javascript-in print)
(require (javascript-in config print)
(pprint-in)
(unlib-in debug list profile)
"quote.ss"
Expand All @@ -19,20 +19,26 @@

; javascript -> string
(define (javascript->string js)
(parameterize ([formatters/Expression (list* format-FunctionExpression
format-RawExpression
(formatters/Expression))]
[formatters/Statement (list* format-BeginStatement
(formatters/Statement))])
(pretty-format (group (format-term js)) #f)))
#;(parameterize ([allow-nested-function-declarations? #t]
[formatters/Expression (list* format-FunctionExpression
format-RawExpression
(formatters/Expression))]
[formatters/Statement (list* format-BeginStatement
(formatters/Statement))])
(pretty-format (group (format-term js)) #f))
(if (render-pretty-javascript?)
(javascript->pretty-string js)
(fast-javascript->string js)))


; javascript -> string
(define (javascript->pretty-string js)
(parameterize ([formatters/Expression (list* format-FunctionExpression
format-RawExpression
(formatters/Expression))]
[formatters/Statement (list* format-BeginStatement
(formatters/Statement))])
(parameterize ([allow-nested-function-declarations? #t]
[formatters/Expression (list* format-FunctionExpression
format-RawExpression
(formatters/Expression))]
[formatters/Statement (list* format-BeginStatement
(formatters/Statement))])
(pretty-format (format-term js))))

; Custom printers --------------------------------
Expand Down
8 changes: 4 additions & 4 deletions javascript/syntax.ss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
(js)))

; (_ string xml ...)
(define-syntax-rule (js-debug msg expr ...)
(define-syntax-rule (debug-js msg expr ...)
(let ([ans (js expr ...)])
(printf "----------~a:~n~a~n----------~n" msg (javascript->pretty-string ans))
ans))
Expand All @@ -41,12 +41,12 @@
(JS)))

; (_ string xml ...)
(define-syntax-rule (JS-DEBUG msg expr ...)
(define-syntax-rule (DEBUG-JS msg expr ...)
(let ([ans (JS expr ...)])
(printf "----------~a:~n~a~n----------~n" msg (javascript->pretty-string ans))
ans))

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

(provide js opt-js js-debug
JS OPT-JS JS-DEBUG)
(provide js opt-js debug-js
JS OPT-JS DEBUG-JS)
16 changes: 14 additions & 2 deletions xml/syntax.ss
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
(xml-attrs [id ,val])
(xml-attrs)))]))

; (_ string xml ...)
(define-syntax-rule (debug-xml msg expr ...)
(let ([ans (xml expr ...)])
(printf "----------~a:~n~a~n----------~n" msg (xml->string ans))
ans))

; Uppercase variants -----------------------------

(define-syntax (XML stx)
Expand Down Expand Up @@ -106,7 +112,13 @@
(XML-ATTRS [id ,val])
(XML-ATTRS)))]))

; (_ string xml ...)
(define-syntax-rule (DEBUG-XML msg expr ...)
(let ([ans (XML expr ...)])
(printf "----------~a:~n~a~n----------~n" msg (xml->string ans))
ans))

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

(provide xml xml-attrs xml* xml-attrs* opt-xml opt-xml-attr
XML XML-ATTRS XML* XML-ATTRS* OPT-XML OPT-XML-ATTR)
(provide xml xml-attrs xml* xml-attrs* opt-xml opt-xml-attr debug-xml
XML XML-ATTRS XML* XML-ATTRS* OPT-XML OPT-XML-ATTR DEBUG-XML)

0 comments on commit 68d01d2

Please sign in to comment.