relative path includes

master
cynic 3 years ago
parent 3ccff8371d
commit 2eea4e2c48
  1. 2
      lib/aids.klambda
  2. 11
      main.py

@ -1,7 +1,7 @@
: get it? because std? : get it? because std?
: i'm hilarious. : i'm hilarious.
INCLUDE:./lib/loop.klambda INCLUDE:./loop.klambda
(defun spit (defun spit
(miracle (miracle

@ -1,4 +1,4 @@
import lib, sys import lib, sys, pathlib
def isnum(n): def isnum(n):
try: try:
@ -9,7 +9,9 @@ def isnum(n):
reps = ["(", ")", "\"", ","] reps = ["(", ")", "\"", ","]
f = open(sys.argv[1]).read() f = open(sys.argv[1]).read()
def expand(file): def expand(file, path):
working_directory = pathlib.Path(path).parent.resolve()
print(working_directory)
tmp = file.replace("\\\n", "").split("\n") tmp = file.replace("\\\n", "").split("\n")
defs = {} defs = {}
for idx, i in enumerate(tmp): for idx, i in enumerate(tmp):
@ -17,7 +19,8 @@ def expand(file):
if len(i) < 1: if len(i) < 1:
continue continue
elif i[:8] == "INCLUDE:": elif i[:8] == "INCLUDE:":
tdefs, tmp[idx] = expand(open(i[8:]).read()) fpath = str(working_directory)+"/"+i[8:]
tdefs, tmp[idx] = expand(open(fpath).read(), fpath)
defs.update(tdefs) defs.update(tdefs)
elif i[:7] == "DEFINE:": elif i[:7] == "DEFINE:":
parts = parts[1:] parts = parts[1:]
@ -38,7 +41,7 @@ def expand(file):
#print(i, "\nsep") #print(i, "\nsep")
return (defs, "\n".join(tmp)) return (defs, "\n".join(tmp))
f = expand(f)[1] f = expand(f, sys.argv[1])[1]
f = f.replace(" ", " RDANEELOLIVAW ") # spacer f = f.replace(" ", " RDANEELOLIVAW ") # spacer

Loading…
Cancel
Save