Start a Modula-2 experiment
This commit is contained in:
26
boot/Transpiler.mod
Normal file
26
boot/Transpiler.mod
Normal file
@@ -0,0 +1,26 @@
|
||||
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);
|
||||
IF ALexer^.Current^ <> '.' THEN
|
||||
WriteLn()
|
||||
END;
|
||||
|
||||
Token := LexerLex(ALexer)
|
||||
END
|
||||
END Transpile;
|
||||
|
||||
END Transpiler.
|
Reference in New Issue
Block a user