1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-18 01:30:27 +02:00

First code for elisp compilation, handling a very limited set of operations (but not really usable yet).

* module/language/elisp/README: New file containing some notes.
* module/language/elisp/compile-tree-il.scm: New file with compilation code.
* module/language/elisp/spec.scm: Updated language definition.
This commit is contained in:
Daniel Kraft 2009-06-09 21:37:13 +02:00
parent ac4d09b164
commit 51248e6e25
3 changed files with 152 additions and 35 deletions

View file

@ -19,45 +19,15 @@
;;; Code:
(define-module (lang elisp spec)
#:use-module (system lang language)
(define-module (language elisp spec)
#:use-module (language elisp compile-tree-il)
#:use-module (system base language)
#:export (elisp))
;;;
;;; Translator
;;;
(define (translate x)
(if (pair? x)
(translate-pair x)
x))
(define (translate-pair x)
(let ((name (car x)) (args (cdr x)))
(case name
((quote) `(@quote ,@args))
((defvar) `(@define ,@(map translate args)))
((setq) `(@set! ,@(map translate args)))
((if) `(@if ,(translate (car args))
(@begin ,@(map translate (cdr args)))))
((and) `(@and ,@(map translate args)))
((or) `(@or ,@(map translate args)))
((progn) `(@begin ,@(map translate args)))
((defun) `(@define ,(car args)
(@lambda ,(cadr args) ,@(map translate (cddr args)))))
((lambda) `(@lambda ,(car args) ,@(map translate (cdr args))))
(else x))))
;;;
;;; Language definition
;;;
(define-language elisp
#:title "Emacs Lisp"
#:version "0.0"
#:reader read
#:expander id
#:translator translate
#:printer write
#:compilers `((tree-il . ,compile-tree-il))
)