;;;; A compiler plugin which allows you to write Fennel programs in Indonesian.
;; (currently requires the "plugin" branch of Fennel from git)

;;; Example:

;; ~/src/fennel $ cat lihat.fnl
;; (lokal lihat (butuh :fennelview))
;;
;; (tulis (lihat {:apa "kabar"}))
;;
;; ~/src/fennel $ ./fennel --compiler-plugin indonesian.fnl lihat.fnl
;; {
;;   :apa "kabar"
;; }

(local dictionary
       {;; Fennel specials

        :arti-arti :values
        :atau :or
        :isi :include
        :biar :let
        :buat :do
        :cocok :match
        :dan :and
        :dok :doc
        :lamda :lambda
        :evaluasi-kompiler :eval-compiler
        :fungsi :fn
        :global :global
        :jika :if
        :kapan :when
        :lokal :local
        :butuh-makro :require-macros
        :makro :macro
        :makro-makro :macros
        :kari :partial
        :merubah :doto ; ??
        :panjangnya :length
        :setiap :each
        :tak :not
        :tak= :not=
        :tetap :set
        :tetap-di :tset
        :untuk :for
        :var :var
        :waktu :while

        ;; Lua built-ins: global functions
        :butuh :require ; ??
        :jenis :type
        :ke-kata :tostring
        :ke-nomor :tonumber
        :lindung :pcall
        :lanjut :next
        :masalah :error
        :nyata :assert
        :pasang :pairs
        :npasang :ipairs ; ??
        :pilih :select
        :sebar :unpack
        :tulis :print
        :xlindung :xpcall

        ;; Lua built-in: global tables
        :meja :table
        ;; :meja. :table.concat
        ;; :meja. :table.insert
        ;; :meja. :table.maxn
        ;; :meja. :table.pack
        ;; :meja. :table.remove
        ;; :meja. :table.sort
        ;; :meja. :table.unpack

        :debug :debug
        :debug.debug :debug.debug
        ;; :debug. :debug.gethook
        ;; :debug. :debug.getinfo
        ;; :debug. :debug.getlocal
        ;; :debug. :debug.getmetatable
        ;; :debug. :debug.getregistry
        ;; :debug. :debug.getupvalue
        ;; :debug. :debug.getuservalue
        ;; :debug. :debug.sethook
        ;; :debug. :debug.setlocal
        ;; :debug. :debug.setmetatable
        ;; :debug. :debug.setupvalue
        ;; :debug. :debug.setuservalue
        ;; :debug. :debug.traceback
        ;; :debug. :debug.upvalueid
        ;; :debug. :debug.upvaluejoin

        :math :matematika
        ;; :matematika. :math.randomseed
        ;; :matematika. :math.asin
        ;; :matematika. :math.fmod
        ;; :matematika. :math.atan
        ;; :matematika. :math.pow
        ;; :matematika. :math.max
        ;; :matematika. :math.pi
        ;; :matematika. :math.frexp
        ;; :matematika. :math.cos
        ;; :matematika. :math.min
        ;; :matematika. :math.huge
        ;; :matematika. :math.sin
        ;; :matematika. :math.cosh
        ;; :matematika. :math.sinh
        ;; :matematika. :math.sqrt
        ;; :matematika. :math.log10
        ;; :matematika. :math.acos
        ;; :matematika. :math.rad
        ;; :matematika. :math.atan2
        ;; :matematika. :math.random
        ;; :matematika. :math.modf
        ;; :matematika. :math.deg
        ;; :matematika. :math.ldexp
        ;; :matematika. :math.ceil
        ;; :matematika. :math.tan
        ;; :matematika. :math.abs
        ;; :matematika. :math.tanh
        ;; :matematika. :math.log
        ;; :matematika. :math.floor
        ;; :matematika. :math.exp

        :kata :string
        ;; :kata. :string.rep
        ;; :kata. :string.match
        ;; :kata. :string.sub
        ;; :kata. :string.char
        ;; :kata. :string.dump
        ;; :kata. :string.byte
        ;; :kata. :string.reverse
        ;; :kata. :string.len
        ;; :kata. :string.upper
        ;; :kata. :string.lower
        ;; :kata. :string.format
        ;; :kata. :string.gmatch
        ;; :kata. :string.gsub
        ;; :kata. :string.find

        :paket :package
        ;; :paket. :package.config
        ;; :paket. :package.path
        ;; :paket. :package.cpath
        ;; :paket. :package.loaders
        ;; :paket. :package.preload
        ;; :paket. :package.loaded
        ;; :paket. :package.searchpath
        ;; :paket. :package.searchers
        ;; :paket. :package.seeall
        ;; :paket. :package.loadlib

        :korutin :coroutine
        ;; :korutin. :coroutine.create
        ;; :korutin. :coroutine.resume
        ;; :korutin. :coroutine.running
        ;; :korutin. :coroutine.yield
        ;; :korutin. :coroutine.status
        ;; :korutin. :coroutine.wrap
        })

(each [k v (pairs dictionary)]
  (when (. _SPECIALS v)
    (tset _SPECIALS k (. _SPECIALS v))))

(fn translate [symbol _scope]
  (when (not (in-scope? symbol))
    (let [translation (. dictionary (tostring symbol))]
      (when translation
        (tset symbol 1 translation)))))

{:symbol-to-expression translate}

Generated by Phil Hagelberg using scpaste at Tue Aug 25 10:38:26 2020. PDT. (original)