From 5b5832e475916863a0bb8ecddec5a0a433ab0a01 Mon Sep 17 00:00:00 2001 From: didier amyot Date: Sat, 24 May 2025 12:23:15 -0400 Subject: [PATCH] Added step0_repl.ts --- .idea/.gitignore | 8 ++++++++ .idea/deno-mal.iml | 12 ++++++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ Makefile | 1 + main.ts | 0 run | 4 ++++ step0_repl.ts | 36 ++++++++++++++++++++++++++++++++++++ 8 files changed, 75 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/deno-mal.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Makefile create mode 100644 main.ts create mode 100644 run create mode 100644 step0_repl.ts diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/deno-mal.iml b/.idea/deno-mal.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/deno-mal.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0e1eab3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6e4b3a2 --- /dev/null +++ b/Makefile @@ -0,0 +1 @@ +step0_repl.ts: diff --git a/main.ts b/main.ts new file mode 100644 index 0000000..e69de29 diff --git a/run b/run new file mode 100644 index 0000000..bc79d88 --- /dev/null +++ b/run @@ -0,0 +1,4 @@ +#!/usr/bin/env nix-shell +#! nix-shell -i bash --pure +#! nix-shell -p bash deno +exec deno run -A $(dirname $0)/${STEP:-stepA_mal}.ts "${@}" \ No newline at end of file diff --git a/step0_repl.ts b/step0_repl.ts new file mode 100644 index 0000000..e7b346c --- /dev/null +++ b/step0_repl.ts @@ -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{ + while(true){ + const u = prompt("user> ") + if(u === null){ + return + } + yield u + } +} + + +function main(): void { + for(const userInput of readUserInputs()){ + rep(userInput); + } + + +} + +main(); \ No newline at end of file