~pepe/jlnt.kak

f63b23b46f3fa3ac86d4c423d90ab7c5a1887cb7 — Josef Pospíšil 8 months ago fe92e3e
Try match
1 files changed, 10 insertions(+), 10 deletions(-)

M jlnt
M jlnt => jlnt +10 -10
@@ 1,7 1,7 @@
#!/usr/bin/env janet

(defn main [_ file]
  (def c (= file "project.janet"))
  (def com (= file "project.janet"))
  (var lines 0)
  (def p (parser/new))
  (def emit (partial printf "%s:%i:%i: %s: %s" file))


@@ 16,23 16,23 @@
      (var [l c] (:where p))
      (when (> l lines) (set l lines) (set c 1))
      (emit l c "error" (:error p)))
    (unless c
    (unless com
      (def- importers {'import true 'import* true 'dofile true 'require true})
      (:eof p)
      (def macros @[])
      (while (:has-more p)
        (def pr (:produce p))
        (def [f s _] pr)
        (def cr (compile pr))
        (if (function? cr)
          (cond
            (= f 'tracev)
            (emit lines c "warning" "Tracev")
            (importers f) (cr)
            (= f 'defmacro) (do
                              (array/push macros s)
          (match (tracev pr)
            ['tracev _]
            (if (= (tuple/type pr) :parens)
              (emit lines 1 "warning" "Tracev"))
            [(i (importers i)) _] (cr)
            ['defmacro m _] (do
                              (array/push macros m)
                              (cr))
            (find |(= $ f) macros) (cr))
            [(m (find |(= $ m) macros)) _] (cr))
          (do
            (var {:line l :column c :error e} cr)
            (unless (pos? l) (set l 1) (set c 1))