stub out #lang quad

main
Matthew Butterick 5 years ago
parent 743f8cad83
commit 35fa2174aa

@ -0,0 +1,37 @@
#lang racket
(require racket/class)
(provide get-info)
(define (custom-indent-rules x)
(match x
;; tbd: custom indent rules, examples below
#;[("with-pattern"
"with-shared-id"
"pattern-case"
"pattern-case-filter") 'lambda]
#;[("define-macro"
"define-macro-cases"
"define-cases"
"while"
"until") 'define]
[_ #false]))
(define (indenter t pos)
(send t compute-racket-amount-to-indent pos custom-indent-rules))
(define (get-info key default-value proc)
(define (fallback) (if proc (proc key default-value) default-value))
(define (try-dynamic-require lib export)
(with-handlers ([exn:missing-module?
(λ (x) (case key
[(drracket:indentation) indenter]
[else (fallback)]))])
(dynamic-require lib export)))
(case key
[(color-lexer)
(try-dynamic-require 'syntax-color/scribble-lexer 'scribble-lexer)]
[(drracket:indentation)
(try-dynamic-require 'scribble/private/indentation 'determine-spaces)]
[(drracket:keystrokes)
(try-dynamic-require 'scribble/private/indentation 'keystrokes)]
[else (fallback)]))

@ -0,0 +1,8 @@
#lang racket/base
(require (for-syntax racket/base))
(provide (rename-out [quad-mb #%module-begin])
#%top-interaction)
(define-syntax (quad-mb stx)
(syntax-case stx ()
[(_ . ARGS) #'(#%module-begin . ARGS)]))

@ -1,5 +1,10 @@
#lang racket/base
;; reader hook for #lang quad
(module reader racket/base
(require "reader.rkt")
(provide (all-from-out "reader.rkt")))
(require "atomize.rkt"
"quad.rkt"
"qexpr.rkt"

@ -10,6 +10,7 @@
"param.rkt"
"rebase.rkt")
(provide (all-defined-out))
(module+ test (require rackunit))
(define (size q)

@ -0,0 +1,27 @@
#lang racket/base
(provide (rename-out
[quad-lang-read read]
[quad-lang-read-syntax read-syntax]
[qr-mod:get-info get-info]))
(module quad-reader syntax/module-reader
#:language 'quad/lang
#:info qgi:get-info
#:read my-read
#:read-syntax my-read-syntax
(require (prefix-in qgi: quad/get-info) (prefix-in at: scribble/reader))
(define (my-read ip) (syntax->datum (my-read-syntax ip)))
(define (my-read-syntax src ip)
(parameterize ([current-readtable (at:make-at-readtable #:command-char #\◊)])
(read-syntax src ip))))
(require debug/reader (prefix-in qr-mod: 'quad-reader))
#|
Use wrap-reader on the whole-module read function that would be exported
by the reader module, not the single-expression read function like
at:read-syntax that you deal with within syntax/module-reader or normal use.
|#
(define quad-lang-read (wrap-reader qr-mod:read))
(define quad-lang-read-syntax (wrap-reader qr-mod:read-syntax))
Loading…
Cancel
Save