forked from alex-eg/sex
add chicken-import support to sex
also fix unquoting to single atom processing wrongly in walk-sex-tree
This commit is contained in:
@@ -3,7 +3,12 @@
|
||||
(include stdbool.h)
|
||||
(include stdio.h)
|
||||
|
||||
(load "list.seh")
|
||||
(chicken-import srfi-1 brev-separate) ; list routines, e.g. fold
|
||||
|
||||
(chicken-load "list.seh")
|
||||
|
||||
(define (imports-test a b c)
|
||||
(fold + 0 (list 1 2 3 a b c)))
|
||||
|
||||
(struct foo
|
||||
((float a)
|
||||
@@ -16,9 +21,8 @@
|
||||
,(length-list-T '(int) #f)
|
||||
,(is-empty-list-T '(int) #f)
|
||||
|
||||
|
||||
(extern fn void puk ((int a) (float b)))
|
||||
(fn bool bar () false)
|
||||
(fn int bar () ,(imports-test 10 20 30))
|
||||
(pub fn void baz () true)
|
||||
|
||||
(extern var int i)
|
||||
|
||||
@@ -28,7 +28,8 @@ All commands in `lisp-mode-shared-map' are inherited by this map.")
|
||||
(list
|
||||
;; Declarations
|
||||
(list (concat "("
|
||||
(regexp-opt '("extern"
|
||||
(regexp-opt '("chicken-import"
|
||||
"extern"
|
||||
"include"
|
||||
"fn"
|
||||
"pub"
|
||||
|
||||
23
sexc.scm
23
sexc.scm
@@ -111,22 +111,27 @@
|
||||
(else (error "Pub what?"))))
|
||||
|
||||
(define (walk-sex-tree form acc)
|
||||
(case (car form)
|
||||
((fn) (walk-function form #t acc))
|
||||
((extern) (walk-extern form acc))
|
||||
((pub) (walk-public form acc))
|
||||
((struct union) (walk-struct form acc))
|
||||
((unquote) (fold (fn (walk-sex-tree x y))
|
||||
acc
|
||||
(eval (cadr form))))
|
||||
(if (list? form)
|
||||
(case (car form)
|
||||
((fn) (walk-function form #t acc))
|
||||
((extern) (walk-extern form acc))
|
||||
((pub) (walk-public form acc))
|
||||
((struct union) (walk-struct form acc))
|
||||
((unquote) (fold (fn (walk-sex-tree x y))
|
||||
acc
|
||||
(eval (cadr form))))
|
||||
|
||||
(else (append (walk-generic form (list)) acc))))
|
||||
(else (append (walk-generic form (list)) acc)))
|
||||
;; only for unquote support
|
||||
(list (list (atom-to-fmt-c form)))))
|
||||
|
||||
(define (process-form form acc)
|
||||
(case (car form)
|
||||
((define) (eval form) acc)
|
||||
((template) (eval form) acc)
|
||||
((load) (eval form) acc)
|
||||
((chicken-import)
|
||||
(eval (cons 'import (cdr form))) acc)
|
||||
(else
|
||||
(walk-sex-tree form acc))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user