mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 23:37:38 +02:00
Added (lib:includes ast)
This commit is contained in:
parent
e29511cc99
commit
dd955d9b2f
1 changed files with 22 additions and 47 deletions
69
trans.scm
69
trans.scm
|
@ -7,50 +7,8 @@
|
|||
;; various utility functions used by the compiler.
|
||||
;;
|
||||
|
||||
(define *version* "0.0.1 (Pre-release)")
|
||||
(load (string-append (cyc:get-lib-dir) "scheme/cyclone.scm"))
|
||||
|
||||
(define *version-banner*
|
||||
(string-append "
|
||||
:@
|
||||
@@@
|
||||
@@@@:
|
||||
`@@@@@+
|
||||
.@@@+@@@ Cyclone
|
||||
@@ @@ An experimental Scheme compiler
|
||||
,@ https://github.com/justinethier/cyclone
|
||||
'@
|
||||
.@
|
||||
@@ #@ (c) 2014 Justin Ethier
|
||||
`@@@#@@@. Version " *version* "
|
||||
#@@@@@
|
||||
+@@@+
|
||||
@@#
|
||||
`@.
|
||||
|
||||
"))
|
||||
|
||||
(define *c-file-header-comment*
|
||||
(string-append "/**
|
||||
** This file was automatically generated by the Cyclone scheme compiler
|
||||
**
|
||||
** (c) 2014 Justin Ethier
|
||||
** Version " *version* "
|
||||
**
|
||||
**/
|
||||
"))
|
||||
|
||||
;; Features implemented by this Scheme
|
||||
(define *features* '(cyclone))
|
||||
|
||||
;; Built-in functions
|
||||
;; TODO: relocate these somewhere else, like a lib.scm!!!
|
||||
;; TODO: Longer-term, we will want to insert all these but then have an
|
||||
;; algorithm in place to remove the definitions that are not used.
|
||||
;; Basically, after the expansion phase but before alpha conversion,
|
||||
;; there should be enough information to figure out what is unused, and
|
||||
;; discard it. Obviously this may be a no-go in certain situations, such
|
||||
;; as if a (read (eval)) REPL is present. Although maybe not, since that
|
||||
;; would use the interpreter.
|
||||
(define *built-ins* `(
|
||||
(define *Cyc-version-banner* ,*version-banner*)
|
||||
;; TODO: The whitespace characters are space, tab, line feed, form feed (not in parser yet), and carriage return.
|
||||
|
@ -1777,6 +1735,10 @@
|
|||
;; Helper function that returns an empty list as a default value
|
||||
(define (lib:result result)
|
||||
(if result result '()))
|
||||
|
||||
;; TODO: most of these below assume 0 or 1 instances of the directive.
|
||||
;; may need to replace some of these later with filter operations to
|
||||
;; support more than 1 instance.
|
||||
(define (lib:exports ast)
|
||||
(lib:result
|
||||
(and-let* ((code (assoc 'export (cddr ast))))
|
||||
|
@ -1789,7 +1751,16 @@
|
|||
(lib:result
|
||||
(and-let* ((code (assoc 'begin (cddr ast))))
|
||||
(cdr code))))
|
||||
;; TODO: include, include-ci, cond-expand
|
||||
(define (lib:includes ast)
|
||||
(map
|
||||
(lambda (inc-lst)
|
||||
(cadr inc-lst))
|
||||
(filter
|
||||
(lambda (code)
|
||||
(tagged-list? 'include code))
|
||||
(cddr ast))))
|
||||
|
||||
;; TODO: include-ci, cond-expand
|
||||
|
||||
;; Resolve library filename given an import.
|
||||
;; Assumes ".sld" file extension if one is not specified.
|
||||
|
@ -1798,7 +1769,7 @@
|
|||
(if (null? ext)
|
||||
".sld"
|
||||
(car ext)))
|
||||
(filename
|
||||
(filename*
|
||||
(string-append
|
||||
(apply
|
||||
string-append
|
||||
|
@ -1806,8 +1777,12 @@
|
|||
(lambda (i)
|
||||
(string-append "/" (symbol->string i)))
|
||||
import))
|
||||
file-ext)))
|
||||
(substring filename 1 (string-length filename))))
|
||||
file-ext))
|
||||
(filename
|
||||
(substring filename* 1 (string-length filename*))))
|
||||
(if (tagged-list? 'scheme import)
|
||||
(string-append (cyc:get-lib-dir filename)) ;; Built-in library
|
||||
filename)))
|
||||
|
||||
; !!!!!!!!!!!!!!!!!!!!!!!!
|
||||
;TODO: all this basedir stuff below is silly. all we need is a way of saying OK, this
|
||||
|
|
Loading…
Add table
Reference in a new issue