movement
parent
44bbd16a32
commit
4573519a50
@ -1,2 +0,0 @@
|
||||
#lang info
|
||||
(define collection "stacker")
|
@ -1,6 +0,0 @@
|
||||
#lang reader "stacker-lang.rkt"
|
||||
push 4
|
||||
push 8
|
||||
+
|
||||
push 3
|
||||
*
|
@ -1,12 +1,14 @@
|
||||
#lang br
|
||||
(define (read-syntax src-path src-port)
|
||||
|
||||
(module reader br
|
||||
(define (read-syntax src-path src-port)
|
||||
(define src-strs (port->lines src-port))
|
||||
(define (make-datum str) (format-datum '(dispatch ~a) str))
|
||||
(define src-exprs (map make-datum src-strs))
|
||||
(inject-syntax ([#'(list src-expr ...) src-exprs])
|
||||
#'(module stacker-mod "stacker-lang.rkt"
|
||||
src-expr ...)))
|
||||
(provide read-syntax)
|
||||
(provide read-syntax))
|
||||
|
||||
(define #'(stacker-module-begin reader-line ...)
|
||||
#'(#%module-begin
|
@ -0,0 +1,6 @@
|
||||
#lang reader (submod "stacker-lang.rkt" reader)
|
||||
push 4
|
||||
push 8
|
||||
+
|
||||
push 3
|
||||
*
|
@ -1,40 +0,0 @@
|
||||
#lang at-exp br
|
||||
(require scribble/manual scribble/core txexpr)
|
||||
(provide scribble->xexpr)
|
||||
|
||||
(define (style->attrs s style-accessor)
|
||||
(let* ([style-datum (style-accessor s)])
|
||||
(if (style? style-datum) ; either style struct, or simple symbol name
|
||||
`((style ,(~a (style-name style-datum)))
|
||||
(properties ,(string-join (map ~a (style-properties style-datum)) " ")))
|
||||
`((style ,(~a style-datum))))))
|
||||
|
||||
|
||||
;; Unfortunately there seems to be no generic way of fetching the style & elements from a Scribble structure
|
||||
;; the specific struct accessors must be used.
|
||||
(define #'structure->txexpr
|
||||
(λ(stx)
|
||||
(syntax-match stx
|
||||
[#'(_ structure-name elem-name id)
|
||||
(syntax-let ([#'structure-name-elem-name (format-id stx "~a-~a" #'structure-name #'elem-name)]
|
||||
[#'structure-name-style (format-id stx "~a-style" #'structure-name)])
|
||||
#'(let* ([elem-raw (structure-name-elem-name id)]
|
||||
[elems (map scribble->xexpr (if (list? elem-raw)
|
||||
(flatten elem-raw)
|
||||
(list elem-raw)))])
|
||||
(list* 'structure-name (style->attrs id structure-name-style) elems)))])))
|
||||
|
||||
(define (scribble->xexpr s)
|
||||
(cond
|
||||
[(nested-flow? s) (structure->txexpr nested-flow blocks s)]
|
||||
[(paragraph? s) (structure->txexpr paragraph content s)]
|
||||
[(element? s) (structure->txexpr element content s)]
|
||||
[else s]))
|
||||
|
||||
(module+ test
|
||||
(require rackunit)
|
||||
(define-simple-check (check-sx? s)
|
||||
(check-true (txexpr? (scribble->xexpr s))))
|
||||
(check-sx? @racketblock[(list +)])
|
||||
(check-sx? @racket[(list +)])
|
||||
(check-sx? @code{(list +)}))
|
@ -0,0 +1,5 @@
|
||||
#lang racket/base
|
||||
(provide message)
|
||||
(define message "You installed beautiful-racket correctly.")
|
||||
(module+ main
|
||||
(displayln message))
|
Loading…
Reference in New Issue