~technomancy/antifennel

4641f06a1e086f6df876933920fa91f0680391ed — Phil Hagelberg a month ago f69e944
Fix outdated test case.
1 files changed, 19 insertions(+), 18 deletions(-)

M antifennel_expected.fnl
M antifennel_expected.fnl => antifennel_expected.fnl +19 -18
@@ 58,22 58,23 @@
  (or (and field name) (: (uncamelize name) "gsub" "([a-z0-9])_" "%1-")))

(fn compile [rdr filename]
  (local ls (lex-setup rdr filename))
  (local ast-builder (lua-ast.New mangle))
  (local ast-tree (parse ast-builder ls))
  (letter (compiler nil ast-tree)))

(local filename (. arg 1))

(local f (and filename (io.open filename)))

(if f
    (do
      (: f "close")
      (each [_ code (ipairs (compile (reader.file filename) filename))]
        (print (fnlfmt.fnlfmt code))))
    (do
      (print (: "Usage: %s LUA_FILENAME" "format" (. arg 0)))
      (print "Compiles LUA_FILENAME to Fennel and prints output.")
      (os.exit 1)))
  (let [ls (lex-setup rdr filename) ast-builder (lua-ast.New mangle) ast-tree (parse ast-builder ls)]
    (letter (compiler nil ast-tree))))

(if (and (and debug debug.getinfo) (= (debug.getinfo 3) nil))
    (let [filename (. arg 1) f (and filename (io.open filename))]
      (if f
          (do
            (: f "close")
            (each [_ code (ipairs (compile (reader.file filename) filename))]
              (print (fnlfmt.fnlfmt code))))
          (do
            (print (: "Usage: %s LUA_FILENAME" "format" (. arg 0)))
            (print "Compiles LUA_FILENAME to Fennel and prints output.")
            (os.exit 1))))
    (fn [str source]
      (let [out []]
        (each [_ code (ipairs (compile (reader.string str) (or source "*source")))]
          (table.insert out (fnlfmt.fnlfmt code)))
        (table.concat out "\n"))))