Get it working! Ludus in cljs works.

This commit is contained in:
Scott Richmond 2023-11-24 13:54:06 -05:00
parent 8a456e1d02
commit 8c19cca9e7
2 changed files with 9 additions and 5 deletions

View File

@ -11,9 +11,7 @@
(declare expression pattern) (declare expression pattern)
; (defp separator choice [:comma :newline :break]) (defp separator choice [:comma :newline :break])
(defn separator [] (choice :separator [:comma :newline :break]))
(defp separators quiet one+ separator) (defp separators quiet one+ separator)

View File

@ -84,10 +84,16 @@
[scanner] [scanner]
(subs (:source scanner) (:start scanner) (:current scanner))) (subs (:source scanner) (:start scanner) (:current scanner)))
(defn- char-code [char]
#?(
:clj (int char)
:cljs (.charCodeAt char 0)
))
(defn- char-in-range? [start end char] (defn- char-in-range? [start end char]
(and char (and char
(>= (int char) (int start)) (>= (char-code char) (char-code start))
(<= (int char) (int end)))) (<= (char-code char) (char-code end))))
(defn- digit? [c] (defn- digit? [c]
(char-in-range? \0 \9 c)) (char-in-range? \0 \9 c))