-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7cfc03
commit d712bf1
Showing
5 changed files
with
35 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
lark == 1.1.2 | ||
prompt_toolkit == 3.0.30 | ||
pycodestyle == 2.5.0 | ||
pytest | ||
versioneer == 0.22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# prompt_toolkit setup example taken from | ||
# https://stackoverflow.com/questions/59627995: | ||
from prompt_toolkit import prompt | ||
from prompt_toolkit import PromptSession | ||
from prompt_toolkit.history import FileHistory | ||
from os.path import expanduser | ||
|
||
from smallscheme.env import Env | ||
from smallscheme.scheme import parse_str, evalu, printable_value | ||
|
||
|
||
def repl(): | ||
session = PromptSession(history=FileHistory( | ||
expanduser('~/.smallscheme_history'))) | ||
|
||
env = Env() | ||
while True: | ||
try: | ||
x = session.prompt("scheme> ").strip() | ||
except EOFError: | ||
print() | ||
break | ||
if x: | ||
try: | ||
for parsed in parse_str(x): | ||
pv = printable_value(evalu(parsed, env)) | ||
if pv: | ||
print(pv) | ||
except Exception as e: | ||
print(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters