mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 17:50:29 +02:00
add parsers and unparser for ghil; ,language ghil works now
* module/system/repl/common.scm (repl-print): Slightly refine the meaning of "language-printer": a language printer prints an expression of a language, not the result of evaluation. `write' prints values. * module/language/ghil/spec.scm (ghil): Define a language printer, and a translator for turning s-expressions (not scheme, mind you) into GHIL. * module/language/scheme/translate.scm (quote, quasiquote): Add some #:keyword action, so that we can (quote #:keywords). * module/system/base/language.scm (<language>): * module/system/base/compile.scm (read-file-in): Don't require that a language have a read-file; instead error when read-file is called. (compile-passes, compile-in): Refactor to call a helper method to turn the language + set of options into a set of compiler passes. * module/system/base/syntax.scm (define-type): Allow the type to be a list, with the car being the name and the cdr being keyword options. Interpret #:printer as a printer, and pass it down to... (define-record): Here. * module/system/il/ghil.scm (print-ghil, <ghil>): New printer for GHIL, yay! (parse-ghil, unparse-ghil): New lovely functions. Will document them in the manual.
This commit is contained in:
parent
f698d111b4
commit
f38624b349
7 changed files with 225 additions and 184 deletions
|
@ -21,12 +21,21 @@
|
|||
|
||||
(define-module (language ghil spec)
|
||||
#:use-module (system base language)
|
||||
#:use-module (system il ghil)
|
||||
#:export (ghil))
|
||||
|
||||
(define (write-ghil exp . port)
|
||||
(apply write (unparse-ghil exp) port))
|
||||
|
||||
(define (translate x e)
|
||||
(call-with-ghil-environment e '()
|
||||
(lambda (env vars)
|
||||
(make-ghil-lambda env #f vars #f '() (parse-ghil env x)))))
|
||||
|
||||
(define-language ghil
|
||||
#:title "Guile High Intermediate Language (GHIL)"
|
||||
#:version "0.3"
|
||||
#:reader read
|
||||
#:printer write
|
||||
;; #:environment (make-vmodule)
|
||||
#:printer write-ghil
|
||||
#:translator translate
|
||||
)
|
||||
|
|
|
@ -136,11 +136,11 @@
|
|||
|
||||
(define-scheme-translator quote
|
||||
;; (quote OBJ)
|
||||
((,obj) (make-ghil-quote e l obj)))
|
||||
((,obj) (make-ghil-quote e l #:obj obj)))
|
||||
|
||||
(define-scheme-translator quasiquote
|
||||
;; (quasiquote OBJ)
|
||||
((,obj) (make-ghil-quasiquote e l (trans-quasiquote e l obj 0))))
|
||||
((,obj) (make-ghil-quasiquote e l #:exp (trans-quasiquote e l obj 0))))
|
||||
|
||||
(define-scheme-translator define
|
||||
;; (define NAME VAL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue