Added step0_repl.ts
This commit is contained in:
commit
5b5832e475
8 files changed
+75
No files matched your search
@@ -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();
|
||||
Reference in new issue
Block a user