File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3636 data (vec source)
3737 len (count data)]
3838 (loop [current 0
39- tokens []]
39+ tokens []
40+ state :key ]
4041 (if (>= current len)
4142 (conj tokens [:eof ])
4243 (let [c (nth data current)
6869 (lexer-error " Unterminated string" current)))
6970
7071 (let [start current
72+ stop-chars (if (= state :key )
73+ #{\= \; \newline \] \[}
74+ #{\; \newline \] \[})
7175 [ident-str new-current]
7276 (loop [curr current
7377 chars []]
7478 (if (or (>= curr len)
75- (let [c (nth data curr)]
76- (or (= c \=) (= c \;) (= c \newline) (= c \]) (= c \[))))
79+ (stop-chars (nth data curr)))
7780 [(string/join chars) curr]
7881 (recur (inc curr) (conj chars (nth data curr)))))]
79- [[:ident (string/trim ident-str) start] new-current]))]
80- (recur new-current (if token (conj tokens token) tokens)))))))
82+ [[:ident (string/trim ident-str) start] new-current]))
83+ next-state (if token
84+ (let [tok-type (first token)]
85+ (cond
86+ (= tok-type :equal ) :value
87+ (#{:newline :rbracket } tok-type) :key
88+ :else state))
89+ state)]
90+ (recur new-current (if token (conj tokens token) tokens) next-state))))))
8191
8292(defn- parser-error [message pos]
8393 (throw (ex-info (format " Parser Error: %s" message) {:position pos})))
You can’t perform that action at this time.
0 commit comments