~technomancy/antifennel

53e813b0331a0b2c09a12ca009643a1bc80e675d — Phil Hagelberg 10 months ago 2696315
Fix a bug with raw iterator values in a for loop.
3 files changed, 16 insertions(+), 6 deletions(-)

M anticompiler.fnl
M antifennel_expected.fnl
M changelog.md
M anticompiler.fnl => anticompiler.fnl +6 -3
@@ 212,10 212,13 @@

(fn each* [compile scope {: namelist : explist : body}]
  (let [subscope (make-scope scope)
        binding (map namelist.names (partial compile scope))]
        binding (map namelist.names (partial compile scope))
        iter (if (= 1 (length explist))
                 (compile scope (. explist 1))
                 (icollect [_ exp (ipairs explist) :into (list (sym :values))]
                   (compile scope exp)))]
    (add-to-scope subscope :param binding)
    (each [_ form (ipairs (map explist (partial compile scope)))]
      (table.insert binding form))
    (table.insert binding iter)
    (list (sym :each)
          binding
          (unpack (map body (partial compile subscope))))))

M antifennel_expected.fnl => antifennel_expected.fnl +4 -3
@@ 52,7 52,7 @@
(if (and (and debug debug.getinfo) (= (debug.getinfo 3) nil))
    (let [filename (or (and (= (. arg 1) "-") :/dev/stdin) (. arg 1))]
      (var comments false)
      (each [_ a (pairs arg)] (when (= a :--comments) (set comments true)))
      (each [_ a (ipairs arg)] (when (= a :--comments) (set comments true)))
      (local f (and filename (io.open filename)))
      (if f (do
              (f:close)


@@ 63,9 63,10 @@
            (print (: "Usage: %s LUA_FILENAME" :format (. arg 0)))
            (print "Compiles LUA_FILENAME to Fennel and prints output.")
            (os.exit 1))))
    (fn [str source]
    (fn [str source filename comments]
      (let [out {}]
        (each [_ code (ipairs (compile (reader.string str) (or source :*source)))]
        (each [_ code (ipairs (compile (reader.string str) (or source :*source))
                              filename comments)]
          (table.insert out (fnlfmt.fnlfmt code)))
        (table.concat out "\n"))))


M changelog.md => changelog.md +6 -0
@@ 1,5 1,11 @@
# Summary of user-visible changes

## 0.3.0 / ???

* Fix a bug with raw iterator values in a for loop.
* Add support for comments.
* Add support for bitwise operators.

## 0.2.0 / 2023-02-18

* Use version 1.3.0 of Fennel and 0.3.0 of fnlfmt.