From eb5f5dd3f3f408ccb9f62303f031efc8454fd5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 13 Jul 2022 11:47:22 +0200 Subject: Resolve #ifdef, #ifndef, #else, #endif. --- module/c/preprocessor2.scm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'module/c') diff --git a/module/c/preprocessor2.scm b/module/c/preprocessor2.scm index 2677c42e..28d11901 100644 --- a/module/c/preprocessor2.scm +++ b/module/c/preprocessor2.scm @@ -633,12 +633,18 @@ ((if) resolve-for-if) ((ifdef) (lambda (env body) - (if (in-environment? env (identifier-token? (car body))) - enter-active-if enter-inactive-if))) + ((if (in-environment? env (identifier-token? (car body))) + enter-active-if enter-inactive-if) + env))) ((ifndef) (lambda (env body) - (if (in-environment? env (identifier-token? (car body))) - enter-inactive-if enter-active-if))) + ((if (in-environment? env (identifier-token? (car body))) + 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))) + ;; ((elif) (lambda )) ((define) resolve-define) ((undef) (lambda (env body) (remove-identifier env (identifier-token? (car body))))) ((line) handle-line-directive) -- cgit v1.2.3