Skip to content

Commit 1ef2bc7

Browse files
committed
update mini.clj to fix bug with some game.project files
1 parent 0db3f9d commit 1ef2bc7

1 file changed

Lines changed: 6 additions & 40 deletions

File tree

src/defold/mini.clj

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
; SOFTWARE.
2424

25-
(ns defold.mini
25+
(ns dev.atomicptr.mini
2626
(:require
2727
[clojure.string :as string]))
2828

@@ -67,46 +67,13 @@
6767
(inc end)]
6868
(lexer-error "Unterminated string" current)))
6969

70-
; parse numbers
71-
(\0 \1 \2 \3 \4 \5 \6 \7 \8 \9)
72-
(let [start current
73-
[pre post has-dot curr]
74-
(loop [curr (inc current)
75-
pre [c]
76-
post []
77-
has-dot false]
78-
(if (>= curr len)
79-
[pre post has-dot curr]
80-
81-
(let [c (nth data curr)]
82-
(case c
83-
(\0 \1 \2 \3 \4 \5 \6 \7 \8 \9)
84-
(if has-dot
85-
(recur (inc curr) pre (conj post c) has-dot)
86-
(recur (inc curr) (conj pre c) post has-dot))
87-
\.
88-
(if has-dot
89-
(lexer-error "Unexpected character: ." curr)
90-
(recur (inc curr) pre post true))
91-
[pre post has-dot curr]))))]
92-
(if (and has-dot (empty? post))
93-
(lexer-error "Trailing dot" current)
94-
(let [num-str (str (string/join pre) (if has-dot "." "") (string/join post))]
95-
(if has-dot
96-
(try [[:number (Double/parseDouble num-str) start] curr]
97-
(catch Exception _
98-
(lexer-error (str "Could not parse number: " num-str) curr)))
99-
(try [[:number (Integer/parseInt num-str) start] curr]
100-
(catch Exception _
101-
(lexer-error (str "Could not parse number: " num-str) curr)))))))
102-
10370
(let [start current
10471
[ident-str new-current]
10572
(loop [curr current
10673
chars []]
10774
(if (or (>= curr len)
108-
(let [c (nth data curr)]
109-
(or (= c \=) (= c \;) (= c \newline) (= c \]) (= c \[))))
75+
(let [c (nth data curr)]
76+
(or (= c \=) (= c \;) (= c \newline) (= c \]) (= c \[))))
11077
[(string/join chars) curr]
11178
(recur (inc curr) (conj chars (nth data curr)))))]
11279
[[:ident (string/trim ident-str) start] new-current]))]
@@ -124,11 +91,11 @@
12491
(parser-error "Unexpected end of file" pos)
12592

12693
(and (not (coll? token-type))
127-
(not= toktype token-type))
94+
(not= toktype token-type))
12895
(parser-error (format "Expected token %s but found %s instead" token-type toktype) pos)
12996

13097
(and (coll? token-type)
131-
(not (some #(= toktype %) token-type)))
98+
(not (some #(= toktype %) token-type)))
13299
(parser-error (format "Expected token %s but found %s instead" token-type toktype) pos)
133100

134101
:else
@@ -166,12 +133,11 @@
166133
tokens (expect-token tokens [:newline :eof])]
167134
(recur tokens result (string/split ident #"\.") nil))
168135

169-
(:ident :number :string)
136+
(:ident :string)
170137
(let [k value
171138
tokens (expect-token (rest tokens) :equal)
172139
[v tokens] (case (peek-token tokens)
173140
:ident (consume-token tokens)
174-
:number (consume-token tokens)
175141
:string (consume-token tokens)
176142
(parser-error (format "Unexpected token: %s" (ffirst tokens)) (last (first tokens))))
177143
tokens (expect-token tokens [:newline :eof])]

0 commit comments

Comments
 (0)