Add examples/. Install to system on `make install`

Installs examples/* to /usr/share/pebblisp
A basic REPL is one of these examples, replacing the built-in C version
with one actually written in PebbLisp. It can be invoked the same way:
running `pl` without any arguments.
This commit is contained in:
Sage Vaillancourt 2020-11-06 15:30:14 -05:00
parent 7c7a68df5f
commit 775be84f5f
3 changed files with 16 additions and 7 deletions

View File

@ -18,3 +18,6 @@ run:
install: install:
cp ./$(exe) /usr/bin/pl cp ./$(exe) /usr/bin/pl
mkdir -p /usr/share/pebblisp/
rm /usr/share/pebblisp/*
cp ./examples/* /usr/share/pebblisp/

12
src/examples/repl.pbl Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/pl
(def repl (fn (_) (
(prn "pebblisp::> ")
(def input (inp 0))
(if (= input "q") () (
(prn (eval input))
(pch 10)
(repl 0)
))
)))
(repl 0)

View File

@ -774,13 +774,7 @@ int readFile(const char *filename, struct Environment *env) {
void repl(struct Environment *env) void repl(struct Environment *env)
{ {
char input[200] = ""; readFile("/usr/share/pebblisp/repl.pbl", env);
while(input[0] != 'q') {
printf("pebblisp>> ");
fgets(input, 100, stdin);
Object obj = parseEval(input, env);
printAndClean(&obj);
}
} }
int main(int argc, const char* argv[]) int main(int argc, const char* argv[])