From a2525f2fc3f41c792065e61079e8e7126210529e Mon Sep 17 00:00:00 2001 From: ubq323 Date: Wed, 26 Jun 2024 12:09:30 +0100 Subject: parse multiple expressions --- com.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'com.c') diff --git a/com.c b/com.c index 66d3941..8102497 100644 --- a/com.c +++ b/com.c @@ -6,8 +6,8 @@ #include "mem.h" #include "chunk.h" #include "ast.h" -#include "read.h" #include "util.h" +#include "prs.h" #define BYTECODE(C) (C->ch->bc) @@ -473,17 +473,24 @@ int main(int argc, char **argv) { } } - AstNode an = read(); Compiler com = (Compiler){ 0 }; com.S = S; com.ch = &ch; - Compiler *C = &com; - compile_node(C, an); - compile_opcode(C, OP_PUTS); - compile_opcode(C, OP_HALT); + AstNode an; + memset(&an, 0, sizeof an); + pcc_context_t *parser = pcc_create(NULL); + int rv; + do { + rv = pcc_parse(parser, &an); + compile_node(&com, an); + } while (rv != 0); + pcc_destroy(parser); + + compile_opcode(&com, OP_PUTS); + compile_opcode(&com, OP_HALT); Thread th = thread_new(S); th.ch = &ch; -- cgit v1.2.3