From 464110afe0599efa5b876eb398769cdbf2a0c1df Mon Sep 17 00:00:00 2001 From: Peter Mikkelsen Date: Mon, 24 Jan 2022 00:00:05 +0000 Subject: Rework the lexer to lex from either a string or bio. This allows multiline dfn's. --- main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'main.c') 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; -- cgit v1.2.3