diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-13 12:46:45 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-13 12:46:45 +0200 |
commit | c1defcf83c0eedd2fc5cf70c43239336d5abf238 (patch) | |
tree | ae6678bec98c057f855a44ed16fc3b3e650f3ff9 /module/c/preprocessor2.scm | |
parent | Resolve #ifdef, #ifndef, #else, #endif. (diff) | |
download | calp-c1defcf83c0eedd2fc5cf70c43239336d5abf238.tar.gz calp-c1defcf83c0eedd2fc5cf70c43239336d5abf238.tar.xz |
Clearen conditional status predicates.
Diffstat (limited to 'module/c/preprocessor2.scm')
-rw-r--r-- | module/c/preprocessor2.scm | 14 |
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 |