Missed from last commit -- still doesn't work.

This commit is contained in:
Simon Brooke 2024-06-10 11:43:51 +01:00
parent d5b1b91315
commit 4a3a07e354

View file

@ -1,11 +1,9 @@
(ns antonine.core (ns antonine.core
(:require [antonine.calculator :refer [calculate write-roman]] (:require [antonine.calculator :refer [calculate grammar write-roman]]
[antonine.char-reader :refer [read-chars]] [antonine.char-reader :refer [read-chars]]
[clojure.java.io :refer [resource]]
[clojure.pprint :refer [pprint]] [clojure.pprint :refer [pprint]]
[clojure.string :as s] [clojure.string :as s]
[clojure.tools.cli :refer [parse-opts]] [clojure.tools.cli :refer [parse-opts]])
[instaparse.core :refer [parser]])
(:gen-class)) (:gen-class))
(defn- romanise [arg] (defn- romanise [arg]
@ -30,8 +28,6 @@
;; A boolean option defaulting to nil ;; A boolean option defaulting to nil
["-h" "--help"]]) ["-h" "--help"]])
(def grammar (parser (resource "grammar.bnf")))
(defn repl (defn repl
"Read/eval/print loop, using these command line `options`." "Read/eval/print loop, using these command line `options`."
[options] [options]
@ -47,10 +43,9 @@
(ex-info (ex-info
(format "\nVALE %s" (romanise (System/getProperty "user.name"))) (format "\nVALE %s" (romanise (System/getProperty "user.name")))
{:cause :quit})) {:cause :quit}))
(let [tree (grammar input) (let [v (calculate input)]
v (calculate tree)]
(when (> vrb 1) (when (> vrb 1)
(println (format "(Parse tree: %s)" tree))) (println (format "(Parse tree: %s)" (grammar input))))
(when (> vrb 0) (println (format "(Arabic: %d)" v))) (when (> vrb 0) (println (format "(Arabic: %d)" v)))
(println (write-roman v)))) (println (write-roman v))))
(println)) (println))