From 8fc3997b73e98416f64b78f2814711b6d1439755 Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Fri, 29 Jul 2022 17:03:03 -0700 Subject: Fig bugs in the flag library. Now bool flags are handled properly. We have a compiler!! --- csc/main.csc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'csc/main.csc') diff --git a/csc/main.csc b/csc/main.csc index 1e2cde1..9dae75f 100644 --- a/csc/main.csc +++ b/csc/main.csc @@ -1,4 +1,6 @@ (import (scheme base) + (only (scheme file) + open-binary-output-file) (only (scheme read) read) (only (csc compiler) @@ -23,6 +25,7 @@ (define-flag *include* "include" (lambda (s) (cons s *include*)) '()) (define-flag *output* "output" string-copy "") (define-flag *help* "help" bool-flag #f) +(define-flag *h* "h" bool-flag #f) (define *help-msg* @@ -32,6 +35,8 @@ This flag can be passed more than once. --output FILE Write output to the given file. The default is to immediately execute. + + --help,-h Print the usage message. ") @@ -54,7 +59,7 @@ (printf "Error: could not parse flag {}: {}\n{}" (parse-error-flag e) (parse-error-msg e) *help-msg*) (exit 2))) (parse-flags)) - (when *help* + (when (or *help* *h*) (printf "{}" *help-msg*) (exit 0)) (when (string=? "" *output*) @@ -66,3 +71,6 @@ (exit 2)))) (set! *library-search-dirs* *include*) (write-file *output* (compile (read-file input-file)))) + + +(main) -- cgit v1.3.1