diff --git a/lib/test-list.sex b/lib/test-list.sex index f21c7a5..1ef2f68 100644 --- a/lib/test-list.sex +++ b/lib/test-list.sex @@ -17,6 +17,9 @@ (fn bool bar () false) +(extern fn void puk ((int a) (float b))) +(extern var int i) + (pub fn int main () (var (* list-int) l (make-list-int)) (printf "Size of the list: %zu\n" (length-list-int l)) diff --git a/sex-mode.el b/sex-mode.el index ff136ef..e3bfeaa 100644 --- a/sex-mode.el +++ b/sex-mode.el @@ -28,7 +28,8 @@ All commands in `lisp-mode-shared-map' are inherited by this map.") (list ;; Declarations (list (concat "(" - (regexp-opt '("include" + (regexp-opt '("extern" + "include" "fn" "pub" "struct" diff --git a/sexc.scm b/sexc.scm index 9638ff2..06c9122 100644 --- a/sexc.scm +++ b/sexc.scm @@ -27,6 +27,7 @@ (define (atom-to-fmt-c atom) (case atom ((fn) '%fun) + ((prototype) '%prototype) ((var) '%var) ((begin) '%begin) ((pointer) '%pointer) @@ -89,9 +90,22 @@ (append (walk-generic form (list)) (cons `(typedef struct ,name ,name) acc)))) +(define (walk-extern form acc) + (case (cadr form) + ((fn) + (append + (walk-generic (list 'extern (cons 'prototype (cddr form))) (list)) + acc)) + ((var) + (append + (walk-generic (list 'extern (cdr form)) (list)) + acc)) + (else (error "Extern what?")))) + (define (walk-sex-tree form acc) (case (car form) ((fn) (walk-function form #t acc)) + ((extern) (walk-extern form acc)) ((pub) (walk-function form #f acc)) ((struct union) (walk-struct form acc)) ((unquote) (fold (fn (walk-sex-tree x y))