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)
; (defp separator choice [:comma :newline :break])
(defn separator [] (choice :separator [:comma :newline :break]))
(defp separator choice [:comma :newline :break])
(defp separators quiet one+ separator)

View File

@ -84,10 +84,16 @@
[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]
(and char
(>= (int char) (int start))
(<= (int char) (int end))))
(>= (char-code char) (char-code start))
(<= (char-code char) (char-code end))))
(defn- digit? [c]
(char-in-range? \0 \9 c))