summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-24 00:00:05 +0000
committerPeter Mikkelsen <petermikkelsen10@gmail.com>2022-01-24 00:00:05 +0000
commit464110afe0599efa5b876eb398769cdbf2a0c1df (patch)
treec572fdeb3773c20d12a9f104292b15f20d885143 /main.c
parent9a938d3ce26b2d3728d791c0f858acdbd50223b5 (diff)
Rework the lexer to lex from either a string or bio. This allows multiline dfn's.
Diffstat (limited to 'main.c')
-rw-r--r--main.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/main.c b/main.c
index 1397003..6218fa0 100644
--- a/main.c
+++ b/main.c
@@ -43,8 +43,8 @@ restart:
while(!off){
checkmem("main loop");
- Rune *input = prompt(L"\t");
- Datum *result = evalline(input, 1);
+ print("\t");
+ Datum *result = evalline(nil, stdin, 1);
if(result == nil)
continue;
else{
@@ -75,9 +75,16 @@ prompt(Rune *pr)
}
Datum *
-evalline(Rune *line, int toplevel)
+evalline(Rune *line, Biobuf *bio, int toplevel)
{
- Statement *stmts = lexline(line, toplevel);
+ Statement *stmts;
+ if(line)
+ stmts = lexlinestr(line, toplevel);
+ else if(bio)
+ stmts = lexlinebio(bio, toplevel);
+ else
+ stmts = lexlinebio(stdin, toplevel);
+
Datum *result = eval(stmts, toplevel);
if(result)
return result;