aboutsummaryrefslogtreecommitdiff
path: root/module/c/preprocessor2.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/c/preprocessor2.scm')
-rw-r--r--module/c/preprocessor2.scm14
1 files changed, 10 insertions, 4 deletions
diff --git a/module/c/preprocessor2.scm b/module/c/preprocessor2.scm
index 28d11901..6757521f 100644
--- a/module/c/preprocessor2.scm
+++ b/module/c/preprocessor2.scm
@@ -607,7 +607,7 @@
;; null directive
(loop environment remaining-tokens))
- ((in-comment-block? environment)
+ ((in-conditional/inactive? environment)
(case (string->symbol (identifier-token? (car line-tokens)))
((else) (loop (flip-flop-if environment) remaining-tokens))
((endif) (loop (leave-if environment) remaining-tokens))
@@ -642,8 +642,14 @@
enter-inactive-if enter-active-if)
env)))
;; NOTE possibly validate that body is empty for endif and else
- ((endif) (lambda (env _) (leave-if env)))
- ((else) (lambda (env _) (flip-flop-if env)))
+ ((endif) (lambda (env _)
+ (unless (in-conditional? env)
+ (err "#endif outside conditional"))
+ (leave-if env)))
+ ((else) (lambda (env _)
+ (unless (in-conditional? env)
+ (err "#else outside conditional"))
+ (flip-flop-if env)))
;; ((elif) (lambda ))
((define) resolve-define)
((undef) (lambda (env body) (remove-identifier env (identifier-token? (car body)))))
@@ -658,7 +664,7 @@
;; Line is not a pre-processing directive
(else (let ((preceding-tokens remaining-tokens (tokens-until-cpp-directive (cdr tokens))))
- (let* ((env* resolved-tokens (if (in-comment-block? environment)
+ (let* ((env* resolved-tokens (if (in-conditional/inactive? environment)
(values environment '())
(resolve-token-stream environment preceding-tokens))))
(on-snd (append resolved-tokens