macro preprocessor

master
cynic 3 years ago
parent d7b423c78a
commit 8b165cb5e5
  1. 15
      lib/aids.klambda
  2. 15
      main.py
  3. 18
      test.klambda

@ -0,0 +1,15 @@
: get it? because std?
: i'm hilarious.
(defun spit
(id miracle
"builtins" "print" (id $1))
)
(defun input
(id miracle
"builtins" "input" (""))
)
(defun thesis
(id spit
("this language belongs to makise kurisu. there are many like it, but this one is hers."))
)

@ -8,6 +8,21 @@ def isnum(n):
return True return True
reps = ["(", ")", "\"", ","] reps = ["(", ")", "\"", ","]
f = open(sys.argv[1]).read() f = open(sys.argv[1]).read()
def expand(file):
tmp = file.split("\n")
for idx, i in enumerate(tmp):
if len(i) < 1:
continue
elif i[:8] == "INCLUDE:":
tmp[idx] = expand(open(i[8:]).read())
elif i[0] == ":":
tmp.pop(idx)
return "\n".join(tmp)
f = expand(f)
f = f.replace(" ", " RDANEELOLIVAW ") # spacer f = f.replace(" ", " RDANEELOLIVAW ") # spacer
for r in reps: f = f.replace(r, " "+r+" ") for r in reps: f = f.replace(r, " "+r+" ")
f = f.split() f = f.split()

@ -1,15 +1,4 @@
(defun spit INCLUDE:./lib/aids.klambda
(id miracle
"builtins" "print" (id $1))
)
(defun input
(id miracle
"builtins" "input" (""))
)
(defun thesis
(id spit
("this language belongs to makise kurisu. there are many like it, but this one is hers."))
)
(def a (id (id "desu"))) (def a (id (id "desu")))
(spit (spit
@ -20,7 +9,6 @@
(id spit ("one")) (id spit ("one"))
(id spit ("zero")) (id spit ("zero"))
) )
(thesis)
(spit ("how old are you? > ")) (spit ("how old are you? > "))
(def age (conv number (input))) (def age (conv number (input)))
@ -31,4 +19,6 @@
"not adult" "not adult"
) )
) )
) )
(thesis)
Loading…
Cancel
Save