Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
karlstroetmann committed Nov 13, 2024
1 parent 9f984df commit 329e16c
Show file tree
Hide file tree
Showing 6 changed files with 891 additions and 680 deletions.
32 changes: 24 additions & 8 deletions Python/Chapter-07/Interpreter-Frame.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Version 1.0.5\n"
]
}
],
"source": [
"%load_ext nb_mypy"
]
Expand Down Expand Up @@ -473,7 +481,7 @@
"\n",
"def p_stmnt_return(p):\n",
" \"stmnt : RETURN expr ';'\"\n",
" # your code here"
" # your code here"
]
},
{
Expand Down Expand Up @@ -762,7 +770,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -780,9 +788,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"42\n"
]
}
],
"source": [
"try:\n",
" raise ReturnValue(42)\n",
Expand Down
32 changes: 30 additions & 2 deletions Python/Chapter-08/Earley-Parser.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,34 @@
"## Implementing the Parser"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We use the following grammar to describe context free grammars:\n",
"```\n",
" grammar\n",
" : rule\n",
" | rule grammar\n",
" ;\n",
"\n",
" rule\n",
" : VARIABLE ':' item_list ';'\n",
" ;\n",
"\n",
" item_list\n",
" : λ\n",
" | item item_list\n",
" ;\n",
"\n",
" item\n",
" : VARIABLE\n",
" | TOKEN\n",
" | LITERAL\n",
" ;\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -316,7 +344,7 @@
"metadata": {},
"outputs": [],
"source": [
"parser = yacc.yacc(write_tables=False, debug=True)"
"yacc.yacc(write_tables=False, debug=True)"
]
},
{
Expand Down Expand Up @@ -1075,7 +1103,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.0"
"version": "3.12.7"
},
"varInspector": {
"cols": {
Expand Down
153 changes: 9 additions & 144 deletions Python/Chapter-09/Parse-Table.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,144 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<link href='http://fonts.googleapis.com/css?family=Alegreya+Sans:100,300,400,500,700,800,900,100italic,300italic,400italic,500italic,700italic,800italic,900italic' rel='stylesheet' type='text/css'>\n",
"<link href='http://fonts.googleapis.com/css?family=Arvo:400,700,400italic' rel='stylesheet' type='text/css'>\n",
"<link href='http://fonts.googleapis.com/css?family=PT+Mono' rel='stylesheet' type='text/css'>\n",
"<link href='http://fonts.googleapis.com/css?family=Shadows+Into+Light' rel='stylesheet' type='text/css'>\n",
"<link href='http://fonts.googleapis.com/css?family=Philosopher:400,700,400italic,700italic' rel='stylesheet' type='text/css'>\n",
"\n",
"<style>\n",
"\n",
"@font-face {\n",
" font-family: \"Computer Modern\";\n",
" src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');\n",
"}\n",
"\n",
".container { width: 100% }\n",
"\n",
"/* Formatting for header cells */\n",
".text_cell_render h1 {\n",
" font-family: 'Philosopher', sans-serif;\n",
" font-weight: 400;\n",
" font-size: 2.2em;\n",
" line-height: 100%;\n",
" color: rgb(0, 80, 120);\n",
" margin-bottom: 0.1em;\n",
" margin-top: 0.1em;\n",
" display: block;\n",
"}\t\n",
".text_cell_render h2 {\n",
" font-family: 'Philosopher', serif;\n",
" font-weight: 400;\n",
" font-size: 1.9em;\n",
" line-height: 100%;\n",
" color: rgb(200,100,0);\n",
" margin-bottom: 0.1em;\n",
" margin-top: 0.1em;\n",
" display: block;\n",
"}\t\n",
"\n",
".text_cell_render h3 {\n",
" font-family: 'Philosopher', serif;\n",
" margin-top:12px;\n",
" margin-bottom: 3px;\n",
" font-style: italic;\n",
" color: rgb(94,127,192);\n",
"}\n",
"\n",
".text_cell_render h4 {\n",
" font-family: 'Philosopher', serif;\n",
"}\n",
"\n",
".text_cell_render h5 {\n",
" font-family: 'Alegreya Sans', sans-serif;\n",
" font-weight: 300;\n",
" font-size: 16pt;\n",
" color: grey;\n",
" font-style: italic;\n",
" margin-bottom: .1em;\n",
" margin-top: 0.1em;\n",
" display: block;\n",
"}\n",
"\n",
".text_cell_render h6 {\n",
" font-family: 'PT Mono', sans-serif;\n",
" font-weight: 300;\n",
" font-size: 10pt;\n",
" color: grey;\n",
" margin-bottom: 1px;\n",
" margin-top: 1px;\n",
"}\n",
"\n",
".text_cell_render em {\n",
" font-family: 'Philosopher', sans-serif;\n",
" color: blue;\n",
" background-color: rgb(255,220,180);\n",
" font-size: 110%;\n",
" margin-left: 2px;\n",
" margin-right: 2px;\n",
" font-weight: 100;\n",
"}\n",
"\n",
".text_cell_render b {\n",
" color: rgb(255,195,195);\n",
" background-color: rgb(0,0,0);\n",
" font-size: 110%;\n",
" margin-left: 2px;\n",
" margin-right: 2px;\n",
" font-weight: 650;\n",
"}\n",
"\n",
".text_cell_render tt {\n",
" font-size: 120%;\n",
" margin-left: 2px;\n",
" margin-right: 2px;\n",
" font-weight: 150;\n",
"}\n",
"\n",
".CodeMirror{\n",
" font-family: \"PT Mono\";\n",
" font-size: 100%;\n",
"}\n",
"\n",
"</style>\n",
"\n"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.core.display import HTML\n",
"with open (\"../style.css\", \"r\") as file:\n",
" css = file.read()\n",
"HTML(css)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Version 1.0.5\n"
]
}
],
"outputs": [],
"source": [
"%load_ext nb_mypy"
]
Expand Down Expand Up @@ -174,7 +39,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -187,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -196,7 +61,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -221,7 +86,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -328,7 +193,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -361,7 +226,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -427,7 +292,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
"version": "3.12.7"
},
"varInspector": {
"cols": {
Expand Down
Loading

0 comments on commit 329e16c

Please sign in to comment.