tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | README | LICENSE

os.tsp (829B)


      1 (docstr-add!
      2   '((cd!
      3       "(cd! dir)"
      4       "Change directory")
      5     (pwd
      6       "(pwd)"
      7       "String of current working directory")
      8     (now
      9       "(now)"
     10       "Number of milliseconds since 1970 (unix time stamp)")
     11     (time
     12       "(time expr)"
     13       "Time taken to run given expression")))
     14 
     15 (def (repl)
     16   "Read, evaluate, print, loop
     17   To exit enter (quit) or CTRL-D"
     18   (print "> ")
     19   (let ((expr (parse (read))))
     20     (unless (and (pair? expr) (= (car expr) 'quit))
     21       ; TODO push! ans to stack of outputs
     22       (let ((ans (eval expr)))
     23         (unless (void? ans)
     24           (displayln ans))
     25         (repl)))))
     26 
     27 (def (repl-simple)
     28   "Simple REPL interface, only requires io.c tib, no tisp code
     29   See repl for more advanced REPL"
     30   (write 'stdout Nil "> ")
     31   (write 'stdout Nil (eval (parse (read))) "\n")
     32   (repl-simple))