diff options
author | Thomas Albers Raviola <thomas@thomaslabs.org> | 2025-01-05 16:55:51 +0100 |
---|---|---|
committer | Thomas Albers Raviola <thomas@thomaslabs.org> | 2025-01-05 17:11:20 +0100 |
commit | 5b518ad7205b3432d95ff2b3757e49914233d913 (patch) | |
tree | c4abb63c32cc1821a1f072a9e6487d067a873bc3 /src/interpreter.lisp | |
parent | bc69faaa5bbd8a2d8afb9ab81882b1ba21c4bb8e (diff) |
Clean up eval-tree
Diffstat (limited to 'src/interpreter.lisp')
-rw-r--r-- | src/interpreter.lisp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/interpreter.lisp b/src/interpreter.lisp index e69de29..6c47d4b 100644 --- a/src/interpreter.lisp +++ b/src/interpreter.lisp @@ -0,0 +1,43 @@ +(use-package :chains) + +(alexandria:define-constant +command-line-options+ + '((:help #\h) + (:help "help") + (:use #\u :required) + (:use "use" :required) + (:use #\i :required) + (:use "include" :required)) + :test #'equal + :documentation "") + +(defun help () + (format t "~&Usage: chains [OPTION]... FILE... + + -i, --include + -u, --use + -h, --help +")) + +(defun parse-arguments (command-line-arguments) + (multiple-value-bind (options others unknowns) + (just-getopt-parser:getopt command-line-arguments +command-line-options+) + (cond ((assoc :help options) + (help) + (sb-posix:exit 0)) + (unknowns + (help) + (sb-posix:exit 1)) + (t + (loop :for (option . value) :in options :do + (case option + )))) + others)) + +(defun chains () + (let ((files (parse-arguments (uiop:command-line-arguments)))) + (dolist (file files) + (with-open-file (stream file :direction :input) + (mapc (alexandria:compose #'princ #'chains::content) + (alexandria:flatten (chains:eval-tree chains:*default-environment* + (chains:build-tree + (chains:read-tokens stream))))))))) |