Split the parser from the code generator

This commit is contained in:
2025-06-11 22:36:35 +02:00
parent 00e557686b
commit e3f094c8a5
7 changed files with 409 additions and 230 deletions

View File

@ -7,6 +7,7 @@ from M2RTS import HALT, ExitOnHalt;
from Lexer import Lexer, lexer_destroy, lexer_initialize;
from Transpiler import transpile;
from CommandLineInterface import PCommandLine, parse_command_line;
from Parser import PAstModule, parse_module;
var
command_line: PCommandLine;
@ -15,6 +16,7 @@ proc compile_from_stream();
var
lexer: Lexer;
source_input: File;
ast_module: PAstModule;
begin
source_input := OpenToRead(command_line^.input);
@ -29,7 +31,8 @@ begin
if IsNoError(source_input) then
lexer_initialize(ADR(lexer), source_input);
transpile(ADR(lexer), StdOut, command_line^.input);
ast_module := parse_module(ADR(lexer));
transpile(ast_module, StdOut, command_line^.input);
lexer_destroy(ADR(lexer));