36 lines
551 B
TypeScript
36 lines
551 B
TypeScript
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(); |