mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Allow including C headers in a program
This commit is contained in:
parent
c9fa2410cf
commit
1fddf8272a
2 changed files with 23 additions and 4 deletions
14
cyclone.scm
14
cyclone.scm
|
@ -91,11 +91,25 @@
|
|||
include))
|
||||
input-program)))
|
||||
includes))))
|
||||
(else
|
||||
;; Handle import, if present
|
||||
(cond
|
||||
((tagged-list? 'import (car input-program))
|
||||
(set! imports (cdar input-program))
|
||||
(set! input-program (cdr input-program))
|
||||
;(error (list 'imports (cdar input-program)))
|
||||
))
|
||||
;; Handle any C headers
|
||||
(let ((headers (lib:include-c-headers `(dummy dummy ,@input-program))))
|
||||
(cond
|
||||
((not (null? headers))
|
||||
(set! c-headers headers)
|
||||
(set! input-program
|
||||
(filter
|
||||
(lambda (expr)
|
||||
(not (tagged-list? 'include-c-header expr)))
|
||||
input-program)))))
|
||||
))
|
||||
|
||||
;; Process library imports
|
||||
;; TODO: this may not be good enough, may need to tag library
|
||||
|
|
|
@ -17,8 +17,13 @@
|
|||
; (only (example life) life)
|
||||
; (rename (prefix (example grid) grid-)
|
||||
; (grid-make make-grid)))
|
||||
|
||||
;; Simple example of including headers in a program.
|
||||
;; Just place them here in the top-level, after
|
||||
;; the (import) expression, if any.
|
||||
(include-c-header "stdlib.h")
|
||||
(include-c-header "<stdio.h>")
|
||||
;; END C headers
|
||||
|
||||
;; Initialize a grid with a glider.
|
||||
;(define grid (make-grid 24 24))
|
||||
|
|
Loading…
Add table
Reference in a new issue