aboutsummaryrefslogtreecommitdiff
path: root/src/lang.clj
blob: 77235dcf05651140a1afa548de4407772adb5e2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(ns lang
  (:require (lang [lexer :as &lexer]
                  [parser :as &parser]
                  [compiler :as &compiler])
            :reload))

(defn write-file [file data]
  (with-open [stream (java.io.BufferedOutputStream. (java.io.FileOutputStream. file))]
    (.write stream data)))

(comment
  (let [source-code (slurp "test2.lang")
        tokens (&lexer/lex source-code)
        _ (prn 'tokens tokens)
        syntax (&parser/parse tokens)
        _ (prn 'syntax syntax)
        class-data (&compiler/compile syntax)]
    (write-file "output.class" class-data))

  (->> (slurp "test2.lang")
       &lexer/lex
       &parser/parse
       &compiler/compile
       (write-file "output.class"))
  )