aboutsummaryrefslogtreecommitdiff
path: root/src/interpreter.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/interpreter.lisp')
-rw-r--r--src/interpreter.lisp43
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)))))))))