Start a Modula-2 experiment
This commit is contained in:
24
boot/Transpiler.mod
Normal file
24
boot/Transpiler.mod
Normal file
@@ -0,0 +1,24 @@
|
||||
IMPLEMENTATION MODULE Transpiler;
|
||||
|
||||
FROM FIO IMPORT WriteNBytes, StdOut;
|
||||
FROM SYSTEM IMPORT ADDRESS;
|
||||
|
||||
FROM Terminal IMPORT WriteLn;
|
||||
FROM Lexer IMPORT Lexer, LexerToken, LexerLex, LexerKind;
|
||||
|
||||
PROCEDURE Transpile(ALexer: PLexer);
|
||||
VAR
|
||||
Token: LexerToken;
|
||||
WrittenBytes: CARDINAL;
|
||||
BEGIN
|
||||
Token := LexerLex(ALexer);
|
||||
|
||||
WHILE Token.Kind <> lexerKindEof DO
|
||||
WrittenBytes := WriteNBytes(StdOut, ADDRESS(ALexer^.Current - ALexer^.Start), ALexer^.Start);
|
||||
WriteLn();
|
||||
|
||||
Token := LexerLex(ALexer)
|
||||
END
|
||||
END Transpile;
|
||||
|
||||
END Transpiler.
|
Reference in New Issue
Block a user