Skip to content

Commit

Permalink
Fix issue with parsing envrefs that contain _ at the beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
shevchuk committed Nov 20, 2023
1 parent e36e8aa commit cb161be
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject rm-hull/infix "0.4.1"
(defproject rm-hull/infix "0.4.2"
:description "A small Clojure library for expressing LISP expressions as infix rather than prefix notation"
:url "https://github.com/rm-hull/infix"
:license {
Expand Down
2 changes: 1 addition & 1 deletion src/infix/grammar.clj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

(def envref
(m/do*
(fst <- letter)
(fst <- (any-of letter (match "_")))
(rst <- (token (many alpha-num)))
(m/return (let [kw (keyword (strip-location (cons fst rst)))]
(fn [env]
Expand Down
1 change: 1 addition & 0 deletions test/infix/macros_tests.clj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
(is (= 1 ((from-string "1 - 1 + 1"))))
(is (= 2 ((from-string "1 - 2 + 3"))))
(is (= 7 ((from-string [x] "x + 3") 4)))
(is (= 7 ((from-string [_x] "_x + 3") 4)))
(is (= 1 ((from-string [x] {:+ -} "x + 3") 4)))
(is (= 7 ((from-string [] {:x 6 :+ +} "x + 1"))))
(is (= 28.0 ((from-string [] "3 + 5**2"))))
Expand Down

0 comments on commit cb161be

Please sign in to comment.