From 1393ce3878e5d14214631fb83d58c819a7849b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 7 Jul 2022 18:40:27 +0200 Subject: work. --- module/c/preprocessor.scm | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'module/c/preprocessor.scm') diff --git a/module/c/preprocessor.scm b/module/c/preprocessor.scm index 49ecfa27..71712b17 100644 --- a/module/c/preprocessor.scm +++ b/module/c/preprocessor.scm @@ -139,27 +139,6 @@ (every predicate lst)) -(define-type (cpp-environment) - (cpp-if-status type: (list-of? (lambda (x) (memv x '(outside active-if inactive-if)))) - ;; type: (list-of? (memv '(outside active-if inactive-if))) - default: '(outside)) - (cpp-variabes type: hash-table? default: (make-hash-table))) - -(define (make-environment) (cpp-environment)) - -(define (in-envirnoment? environment key) - (hash-get-handle (cpp-variables environment) key)) - -(define (remove-identifier! environment key) - (hash-remove! (cpp-variables environment) key) - environment) - -(define (add-identifier! environment key value) - (assert (string? key)) - (assert (macro? value)) - (hash-set! (cpp-variables environment) key value) - environment) - ;; Parantheses when defining macro (define (parse-parameter-string string) (map string-trim-both @@ -174,15 +153,12 @@ (formals type: (list-of? string?)) (body type: string?)) -(define (macro? x) - (or (object-macro? x) - (function-macro? x))) ;; The interesting part ;; environment, (list string) -> (values (list string) (list strings)) ;; multiple lines since since a function-like macro can extend over multiple lines -(define (expand-macros environment strings) - ) +;; (define (expand-macros environment strings) +;; ) (define (crash-if-not-if body guilty) @@ -235,7 +211,7 @@ ((elif) (case (car (cpp-if-status environment)) ((outside) (crash-if-not-if (directive-body m) "elif")) - (else ;; TODO + (else 'TODO ;; TODO ) )) @@ -272,7 +248,7 @@ xcons 'inactive-if) (cdr lines) done)) - (else ;; TODO + (else 'TODO ;; TODO ))) @@ -286,7 +262,7 @@ ((#\") (handle-file environment filename)))))) (else (scm-error 'cpp-error "parse-directives" "Invalid include" - '() #f)))) + '() #f))))) ((define) ;; TODO what are valid names? (cond ((string-match "^(\\w+)([(][^)]*[)])?\\s+(.*)" (directive-body directive?)) -- cgit v1.2.3