Compare commits

...

4 Commits

  1. 2
      lib.py
  2. 4
      lib/kokoro.klambda
  3. 2
      lib/lists.klambda
  4. 4
      lib/string.klambda
  5. 17
      main.py
  6. 3
      readme.txt
  7. 4
      test.klambda

@ -65,7 +65,7 @@ def execute(program):
return subs
elif ctx[0] == _ident("miracle"):
return _box(eval(_destr(subs[1]))[_destr(subs[2])](*[(i if type(i) == type([]) else i[1]) for i in _fixarr(subs[3])]))
return _box(getattr(eval(_destr(subs[1])), _destr(subs[2]))(*[(i if type(i) == type([]) else i[1]) for i in _fixarr(subs[3])]))
elif ctx[0] == _ident("def"):
ids[ctx[1]] = subs[2]
return ids[ctx[1]]

@ -1,10 +1,10 @@
(def spit (lambda (cunny)
(miracle
"__builtins__" "print" (id cunny))))
"__import__('builtins')" "print" (id cunny))))
(def input (lambda ()
(miracle
"__builtins__" "input" (""))))
"__import__('builtins')" "input" (""))))
(def thesis (lambda ()
(spit
("this language belongs to makise kurisu. there are many like it, but this one is hers."))))

@ -1,6 +1,6 @@
(def length (lambda (cunny)
(miracle
"__builtins__" "len" (cunny))))
"__import__('builtins')" "len" (cunny))))
(def append (lambda (item, victim)
(insert (length victim) item victim)))

@ -1,3 +1,3 @@
(def str2lst (lambda (l)
(def str2lst (lambda (s)
(miracle
"__builtins__" "list" (l))))
"__import__('builtins')" "list" (s))))

@ -6,10 +6,9 @@ def isnum(n):
except:
return False
return True
reps = ["(", ")", "\"", ","]
f = open(sys.argv[1]).read()
def expand(file, path):
def preprocess(filename):
def expand(file, path):
working_directory = pathlib.Path(path).parent.resolve()
tmp = file.replace("\\\n", "").split("\n")
defs = {}
@ -41,12 +40,12 @@ def expand(file, path):
#print(i, "\nsep")
return (defs, "\n".join(tmp))
f = expand(f, sys.argv[1])[1]
f = open(filename).read()
f = expand(f, sys.argv[1])[1]
f = f.replace(" ", " RDANEELOLIVAW ") # spacer
for r in reps: f = f.replace(r, " "+r+" ")
f = f.split()
f = f.replace(" ", " RDANEELOLIVAW ") # spacer
for r in ["(", ")", "\"", ","]: f = f.replace(r, " "+r+" ")
return f.split()
def tokenize(f):
toks = []
@ -125,7 +124,7 @@ def structurize(program):
#print(tokenize(f))
#print(lex(tokenize(f)), "\n")
program = structurize(lex(tokenize(f)))
program = structurize(lex(tokenize(preprocess(sys.argv[1]))))
#lib.execute(structurize(lex(tokenize(f))))
#print(program)

@ -8,11 +8,12 @@ standard library.
syntax:
a program is a series of functions executed using one environment -- that is, sharing
defined variables and functions.
some defined variables and functions.
these functions are executed homoiconic objects made up of language types:
- list, `()` and everything inside. items are delimited by whitespace.
- string, everything between `"` double quotes
- number, everything capable of being represented as a decimal float value
- lambda, an anonymous expression containing the args and procedure
- identifier, everything else
lists starting with defined function identifiers are executed with the rest of the list
as parameters, i.e. (spit "hello~" (+ 9000 1)). runs `spit` using "hello" and (+ 9000 1).

@ -19,7 +19,7 @@ INCLUDE:./lib/aids.klambda
(id spit (cond (% i 15) (cond (% i 5) (cond (% i 3) i "fizz") "buzz") "fizzbuzz")))
(def moeblob ("moe" "moe~" "kyun!!"))
(loop 0 (- (length moeblob) 1)
(id spit (at i moeblob)))
(each moeblob
(id spit item))
(thesis)
Loading…
Cancel
Save