Split the parser from the code generator

This commit is contained in:
2025-06-11 22:36:05 +02:00
parent 6cfeb46dbf
commit 90aa5a0030
6 changed files with 392 additions and 222 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 @@ PROCEDURE 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));