fix REPL treating a regex literal as an unbalanced form
repl-form-complete? entered the :regex state on '#' but only consumed the '#', so the opening '"' was then read by the :regex handler as the CLOSING quote. The regex body got scanned in :code state, and any delimiter or quote inside it (a group like #"(a)", a char class #"[0-9]+") threw off the paren/string count — so a one-line regex form was judged incomplete and the REPL hung waiting for continuation lines. Consume the '#"' together. Adds a self-checking predicate test (test/chez/repl-reader-test.clj, run via joltc so jolt.main resolves) and an end-to-end regex REPL case in smoke.sh.
This commit is contained in:
parent
4889505204
commit
e4cbbb8912
3 changed files with 53 additions and 2 deletions
|
|
@ -103,8 +103,9 @@
|
|||
(= c \;) (recur (inc i) depth :comment)
|
||||
(= c \\) (recur (+ i 2) depth :code) ; char literal: \(
|
||||
(= c \") (recur (inc i) depth :string)
|
||||
(= c \#) (recur (inc i) depth
|
||||
(if (= (get s (inc i)) \") :regex :code))
|
||||
(= c \#) (if (= (get s (inc i)) \")
|
||||
(recur (+ i 2) depth :regex) ; consume the #" together
|
||||
(recur (inc i) depth :code))
|
||||
(#{\( \[ \{} c) (recur (inc i) (inc depth) :code)
|
||||
(#{\) \] \}} c) (recur (inc i) (dec depth) :code)
|
||||
:else (recur (inc i) depth :code))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue