Added step0_repl.ts

This commit is contained in:
didier committed 2025-05-24 12:23:15 -04:00
commit 5b5832e475
8 files changed
+75

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
function read(source: string): string {
return source;
}
function eval_(ast: string): string {
return ast;
}
function print(form: string): string {
return form
}
function rep(source: string): string{
return print(eval_(read( source)))
}
function* readUserInputs(): Generator<string>{
while(true){
const u = prompt("user> ")
if(u === null){
return
}
yield u
}
}
function main(): void {
for(const userInput of readUserInputs()){
rep(userInput);
}
}
main();