<commit_before>(import argparse)
(import sys)

(import [hy.importer [import-file-to-hst]])
(import [hua.compiler [HuaASTCompiler]])
(import [hua.mlast [to-ml-table]])
(import [hua.lua [tlast->src]])

(defn huac-main []

  (def options {"prog" "huac" "usage" "%(prog)s [options] FILE"})
  (def parser (apply argparse.ArgumentParser [] options))
  (apply .add-argument
         [parser "args"]
         {"nargs" argparse.REMAINDER "help" argparse.SUPPRESS})
  

  (setv options (.parse-args parser (slice sys.argv 1)))

  (def filename (get options.args 0))
  (def result-ast (let [[hst (import-file-to-hst filename)]
                        [compiler (HuaASTCompiler "FIXME")]]
                    (.compile compiler hst)))

  ;; FIXME
  (def stmts (to-ml-table result-ast.stmts))
  (def result (tlast->src stmts))
  (print result))<commit_msg>huac write compiled result to file instead of standard output<commit_after>(import argparse)
(import sys)
(import os.path)

(import [hy.importer [import-file-to-hst]])
(import [hua.compiler [HuaASTCompiler]])
(import [hua.mlast [to-ml-table]])
(import [hua.lua [tlast->src]])

(defn huac-main []

  (def options {"prog" "huac" "usage" "%(prog)s [options] FILE"})
  (def parser (apply argparse.ArgumentParser [] options))
  (apply .add-argument
         [parser "args"]
         {"nargs" argparse.REMAINDER "help" argparse.SUPPRESS})
  

  (setv options (.parse-args parser (slice sys.argv 1)))

  (def filename (get options.args 0))
  (def result-ast (let [[hst (import-file-to-hst filename)]
                        [compiler (HuaASTCompiler "FIXME")]]
                    (.compile compiler hst)))

  ;; FIXME
  (def stmts (to-ml-table result-ast.stmts))
  (def result (tlast->src stmts))
  (def (, basename extname) (os.path.splitext filename))
  (def lua-filename (+ basename ".lua"))
  (with [[lua-f (open lua-filename "w")]]
        (.write lua-f result)))
{'fraction_non_alphanumeric': 0.16745406824146983, 'fraction_numerical': 0.002099737532808399, 'mean_word_length': 3.2927927927927927, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2042635', 'n_tokens_mistral': 684, 'n_tokens_neox': 654, 'n_words': 173}