Skip to content

Commit 17cd6be

Browse files
committed
bb
1 parent 599aa0f commit 17cd6be

File tree

3 files changed

+653
-190
lines changed

3 files changed

+653
-190
lines changed

Untitled.ipynb

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"reDef unknown\n",
13+
"reDef \\\n"
14+
]
15+
}
16+
],
17+
"source": [
18+
"import peforth\n",
19+
"peforth.dictate(r'''\n",
20+
"\\ Now we redefine the 'unknown' command that was do-nothing by default\n",
21+
": unknown ( token -- thing Y|N) // Try to find the unknown token in __main__\n",
22+
" py> getattr(sys.modules['__main__'],pop(),\"Ûnknôwn\") \n",
23+
" py> str(tos())==\"Ûnknôwn\" if drop false else true then ;\n",
24+
" /// here after, when FORTH come accross an unknown token, instead of alerting \n",
25+
" /// it try to find the token in python __main__ module name space.\n",
26+
"\n",
27+
"\\ Redefine \\ command to print the comment line\n",
28+
"code \\ print(nexttoken('\\n')) end-code \n",
29+
"''');\n"
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"metadata": {
36+
"collapsed": true
37+
},
38+
"outputs": [],
39+
"source": []
40+
}
41+
],
42+
"metadata": {
43+
"kernelspec": {
44+
"display_name": "Python 3",
45+
"language": "python",
46+
"name": "python3"
47+
},
48+
"language_info": {
49+
"codemirror_mode": {
50+
"name": "ipython",
51+
"version": 3
52+
},
53+
"file_extension": ".py",
54+
"mimetype": "text/x-python",
55+
"name": "python",
56+
"nbconvert_exporter": "python",
57+
"pygments_lexer": "ipython3",
58+
"version": "3.6.1"
59+
}
60+
},
61+
"nbformat": 4,
62+
"nbformat_minor": 2
63+
}

0 commit comments

Comments
 (0)