diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-24 00:00:05 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-24 00:00:05 +0000 |
commit | 464110afe0599efa5b876eb398769cdbf2a0c1df (patch) | |
tree | c572fdeb3773c20d12a9f104292b15f20d885143 /main.c | |
parent | 9a938d3ce26b2d3728d791c0f858acdbd50223b5 (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.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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; |