aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-20 03:59:10 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-20 04:19:03 +0200
commit8a93b3ce695003d07c8d8e4c71153c0130372c4d (patch)
tree3e4a506c2a7af64374711d97acbfe3c81890d6ca
parentSplit parse-cpp into multiple modules. (diff)
downloadcalp-8a93b3ce695003d07c8d8e4c71153c0130372c4d.tar.gz
calp-8a93b3ce695003d07c8d8e4c71153c0130372c4d.tar.xz
Cleanup for cpp.
-rw-r--r--module/c/cpp.scm7
-rw-r--r--module/vulgar/termios.scm12
-rw-r--r--tests/cpp.scm3
3 files changed, 10 insertions, 12 deletions
diff --git a/module/c/cpp.scm b/module/c/cpp.scm
index 69e21d27..2fe842c8 100644
--- a/module/c/cpp.scm
+++ b/module/c/cpp.scm
@@ -114,7 +114,10 @@
(string-append "cpp -dM " header-file))
read-lines)))
-(define-macro (include# header-file)
+(define-macro (include# header-file . args)
+
+ (define define-form (if (null? args) 'define (car args)))
+
(define lines (remove (compose private-c-symbol? car)
(tokenize-header-file header-file)))
@@ -131,7 +134,7 @@
(define graph (add-node graph* (cons '_POSIX_VDISABLE #f) '()))
`(begin
- ,@(map (lambda (pair) `(define ,(car pair) ,(cdr pair)))
+ ,@(map (lambda (pair) `(,define-form ,(car pair) ,(cdr pair)))
(resolve-dependency-graph graph))))
diff --git a/module/vulgar/termios.scm b/module/vulgar/termios.scm
index 3fe82f92..62212122 100644
--- a/module/vulgar/termios.scm
+++ b/module/vulgar/termios.scm
@@ -7,6 +7,7 @@
:use-module (ice-9 format)
:use-module (ice-9 rdelim)
:use-module (srfi srfi-9) ; records
+ :use-module (c cpp)
:use-module (util)
:export (make-termios
copy-termios
@@ -14,16 +15,7 @@
-;;; Constants, TODO, auto parse these from
-;; /usr/include/bits/termios.h
-
-(define-public ECHO 0000010)
-(define-public ICANON 0000002)
-
-;; @var{when} values
-(define-public TCSANOW 0)
-(define-public TCSADRAIN 1)
-(define-public TCSAFLUSH 2)
+(include# "/usr/include/termios.h" define-public)
diff --git a/tests/cpp.scm b/tests/cpp.scm
index 1d4e62f3..d83ba554 100644
--- a/tests/cpp.scm
+++ b/tests/cpp.scm
@@ -1,3 +1,6 @@
+(((c lex) lex)
+ ((c parse) parse-lexeme-tree))
+
(define run (compose parse-lexeme-tree lex))
(test-equal