aboutsummaryrefslogtreecommitdiff
path: root/module/c/cpp.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/c/cpp.scm')
-rw-r--r--module/c/cpp.scm13
1 files changed, 8 insertions, 5 deletions
diff --git a/module/c/cpp.scm b/module/c/cpp.scm
index 9a8245ad..86130167 100644
--- a/module/c/cpp.scm
+++ b/module/c/cpp.scm
@@ -16,16 +16,19 @@
;; input "#define F(x, y) x + y"
-;; 1 full define | F(x, y)
+;; 1 full define | F(x,y)
;; 2 macro name | F
-;; 3 macro args | (x, y)
-;; 4 macro body | x + y
-(define define-re (make-regexp "^#define ((\\w+)([(][^)]*[)])?) (.*)"))
+;; 3 macro args | (x,y)
+;; 5 macro body | x + y or #f
+(define define-re (make-regexp "^#define ((\\w+)([(][^)]*[)])?)( (.*))?"))
(define (tokenize-define-line header-line)
(aif (regexp-exec define-re header-line)
(cons (match:substring it 1)
- (match:substring it 4))
+ (let ((body (match:substring it 5)))
+ (if (or (eqv? body #f)
+ (string-null? body))
+ "1" body)))
(scm-error 'c-parse-error
"tokenize-define-line"
"Line dosen't match: ~s"