summaryrefslogtreecommitdiff
path: root/src/main.lisp
diff options
context:
space:
mode:
authorSiddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com>2025-04-08 10:17:09 -0400
committerGitHub <noreply@github.com>2025-04-08 10:17:09 -0400
commitcc1e5892a25949b996d69a0b07f151a276ef2570 (patch)
tree643d37db692c19d1ef64223eadcac7a28dbbd7db /src/main.lisp
parent19d13c8339ee990fba358417a54aa6f1c94c7bca (diff)
parentb85c10ba1c53f1b442fea6bde4c2a2f73cfe5d6b (diff)
Merge pull request #1 from bdunahu/bdunahu
Add logic to open file, full lexer and tests.
Diffstat (limited to 'src/main.lisp')
-rw-r--r--src/main.lisp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/main.lisp b/src/main.lisp
index c85e392..f6e5754 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -35,14 +35,22 @@ _/_/ _/_/ "
(defun driver (cmd)
"Reads in a file and directs lexing, parsing, and binary emission."
(print-splash)
- (let ((args (clingon:command-arguments cmd))
- (parse? (not (clingon:getopt cmd :lex)))
- (emit? (not (clingon:getopt cmd :parse))))
+ (let* ((args (clingon:command-arguments cmd))
+ (file (car args))
+ (parse? (not (clingon:getopt cmd :lex)))
+ (emit? (not (clingon:getopt cmd :parse))))
(cond
;; complain about num arguments
- ((/= (length args) 1) (error "Wrong number of arguments."))
- ((not (util:asm-extension? (car args))) (error "The file is not an asm source code file."))))
- (error-cli "Nitimur in Vetitum"))
+ ((/= (length args) 1) (error "Wrong number of arguments.~%"))
+ ((not (util:asm-extension? file))
+ (error "The file is not an asm source code file.~%"))
+ (t (let ((tokens (lex:file->tokens file)))
+ (if tokens
+ (progn (pprint tokens)
+ (terpri))
+ (error "The file does not exist, or it could not be opened.~%"))
+ (format t "Nitimur in Vetitum~%"))))))
+
(defun cli/command ()
"Returns a clingon command."