added render-lw

svn: r11255
This commit is contained in:
Robby Findler 2008-08-14 21:22:26 +00:00
parent 32729b8ae8
commit 070b321558
6 changed files with 77 additions and 37 deletions

View File

@ -83,4 +83,6 @@
[set-arrow-pict! (-> symbol? (-> pict?) void?)] [set-arrow-pict! (-> symbol? (-> pict?) void?)]
[lw->pict [lw->pict
(-> (or/c (listof symbol?) compiled-lang?) lw? pict?)]
[render-lw
(-> (or/c (listof symbol?) compiled-lang?) lw? pict?)]) (-> (or/c (listof symbol?) compiled-lang?) lw? pict?)])

View File

@ -1,7 +1,6 @@
(module bitmap-test mzscheme (module bitmap-test mzscheme
(require "bitmap-test-util.ss" (require "bitmap-test-util.ss"
"../pict.ss" "../main.ss")
"../reduction-semantics.ss")
;; tests: ;; tests:
;; - language, ;; - language,
@ -40,5 +39,12 @@
(test (render-metafunction S) (test (render-metafunction S)
"metafunction.png") "metafunction.png")
;; in this test, teh `x' is italic and the 'z' is sf, since 'x' is in the grammar, and 'z' is not.
(test (render-lw
lang
(to-lw ((λ (x) (x x))
(λ (z) (z z)))))
"lw.png")
(printf "bitmap-test.ss: ") (printf "bitmap-test.ss: ")
(done)) (done))

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,16 +1,19 @@
#lang scheme/base
(module core-layout mzscheme
(require "loc-wrapper.ss" (require "loc-wrapper.ss"
"matcher.ss" "matcher.ss"
"reduction-semantics.ss" "reduction-semantics.ss"
(lib "list.ss")
(lib "utils.ss" "texpict") texpict/utils
(lib "mrpict.ss" "texpict") texpict/mrpict
(lib "etc.ss")
(lib "mred.ss" "mred") scheme/gui/base
(lib "struct.ss")) scheme/class)
(require (for-syntax scheme/base))
(provide find-enclosing-loc-wrapper (provide find-enclosing-loc-wrapper
render-lw
lw->pict lw->pict
basic-text basic-text
metafunction-text metafunction-text
@ -36,10 +39,10 @@
;; for test suite ;; for test suite
build-lines build-lines
(struct token (column span)) (struct-out token)
(struct string-token (string style)) (struct-out string-token)
(struct pict-token (pict)) (struct-out pict-token)
(struct spacer-token ()) (struct-out spacer-token)
current-text) current-text)
@ -117,24 +120,28 @@
;; token = string-token | spacer-token | pict-token | align-token ;; token = string-token | spacer-token | pict-token | align-token
(define-struct token (column span) (make-inspector)) (define-struct token (column span) #:inspector (make-inspector))
;; string : string ;; string : string
;; style : valid third argument to mrpict.ss's `text' function ;; style : valid third argument to mrpict.ss's `text' function
(define-struct (string-token token) (string style) (make-inspector)) (define-struct (string-token token) (string style) #:inspector (make-inspector))
;; width : number ;; width : number
;; pict : pict ;; pict : pict
(define-struct (pict-token token) (pict) (make-inspector)) (define-struct (pict-token token) (pict) #:inspector (make-inspector))
;; spacer : number ;; spacer : number
(define-struct (spacer-token token) () (make-inspector)) (define-struct (spacer-token token) () #:inspector (make-inspector))
;; pict : pict ;; pict : pict
;; this token always appears at the beginning of a line and its width ;; this token always appears at the beginning of a line and its width
;; is the x-coordinate of the pict inside itself (which must appear on ;; is the x-coordinate of the pict inside itself (which must appear on
;; an earlier line) ;; an earlier line)
(define-struct align-token (pict) (make-inspector)) (define-struct align-token (pict) #:inspector (make-inspector))
(define (render-lw nts lw)
(parameterize ([dc-for-text-size (make-object bitmap-dc% (make-object bitmap% 1 1))])
(lw->pict nts lw)))
(define (lw->pict nts lw) (define (lw->pict nts lw)
(lines->pict (lines->pict
@ -156,9 +163,9 @@
((current-unquote-rewriter) w-out-term-let) ((current-unquote-rewriter) w-out-term-let)
w-out-term-let)]) w-out-term-let)])
(if (equal? rewritten an-lw) (if (equal? rewritten an-lw)
(copy-struct lw (struct-copy lw
an-lw an-lw
[lw-e (ar/e (lw-e an-lw) [e (ar/e (lw-e an-lw)
(lw-line an-lw) (lw-line an-lw)
(lw-line-span an-lw) (lw-line-span an-lw)
(lw-column an-lw) (lw-column an-lw)
@ -172,9 +179,9 @@
(pair? (cdr content)) (pair? (cdr content))
(lw? (cadr content)) (lw? (cadr content))
(equal? 'term-let (lw-e (cadr content)))) (equal? 'term-let (lw-e (cadr content))))
(copy-struct lw (struct-copy lw
an-lw an-lw
[lw-e (lw-e (second-to-last content))]) [e (lw-e (second-to-last content))])
an-lw)) an-lw))
an-lw)) an-lw))
@ -756,5 +763,3 @@
(find/e in-lws) (find/e in-lws)
lws) lws)
)

View File

@ -1152,12 +1152,15 @@ This section documents two classes of operations, one for
direct use of creating postscript figures for use in papers direct use of creating postscript figures for use in papers
and for use in DrScheme to easily adjust the typesetting: and for use in DrScheme to easily adjust the typesetting:
@scheme[render-language], @scheme[render-language],
@scheme[render-reduction-relation], and @scheme[render-reduction-relation],
@scheme[render-metafunction], and one @scheme[render-metafunction], and
@scheme[render-lw],
and one
for use in combination with other libraries that operate on picts for use in combination with other libraries that operate on picts
@scheme[language->pict], @scheme[language->pict],
@scheme[reduction-relation->pict], and @scheme[reduction-relation->pict],
@scheme[metafunction->pict]. @scheme[metafunction->pict], and
@scheme[lw->pict].
The primary difference between these functions is that the former list The primary difference between these functions is that the former list
sets @scheme[dc-for-text-size] and the latter does not. sets @scheme[dc-for-text-size] and the latter does not.
@ -1622,6 +1625,30 @@ the empty string and the @scheme[x] in the typeset output.
} }
@defproc[(render-lw (language/nts (or/c (listof symbol?) compiled-lang?))
(lw lw?)) pict?]{
Produces a pict that corresponds to the @scheme[lw] object
argument, using @scheme[language/nts] to determine which
of the identifiers in the @scheme[lw] argument are
non-terminals.
This function sets @scheme[dc-for-text-size]. See also
@scheme[lw->pict].
}
@defproc[(lw->pict (language/ntw (or/c (listof symbol?) compiled-lang?))
(lw lw?)) pict?]{
Produces a pict that corresponds to the @scheme[lw] object
argument, using @scheme[language/nts] to determine which
of the identifiers in the @scheme[lw] argument are
non-terminals.
This does not set the @scheme[dc-for-text-size] parameter. See also
@scheme[render-lw].
}
@deftogether[[ @deftogether[[
@defproc[(just-before [stuff (or/c pict? string? symbol?)] @defproc[(just-before [stuff (or/c pict? string? symbol?)]
[lw lw?]) [lw lw?])