From 6e338215192c26dfb16236398ca8e3762a8d4d0e Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 20 Mar 2025 13:51:28 -0400 Subject: Add logic to open file, lex single character symbols, tests --- src/main.lisp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/main.lisp') diff --git a/src/main.lisp b/src/main.lisp index c85e392..1f0afdd 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -35,14 +35,19 @@ _/_/ _/_/ " (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")) + ((not (util:asm-extension? file)) + (error "The file is not an asm source code file, or it could not be opened.")) + (t (let ((tokens (lex:file->tokens file))) + (format t "~a" tokens) + (format t "Nitimur in Vetitum~%")))))) + (defun cli/command () "Returns a clingon command." -- cgit v1.2.3