diff --git a/Python/Chapter-04-05/RegExp-Parser.ipynb b/Python/Chapter-04-05/RegExp-Parser.ipynb
index 2a619c4..4a7d74a 100644
--- a/Python/Chapter-04-05/RegExp-Parser.ipynb
+++ b/Python/Chapter-04-05/RegExp-Parser.ipynb
@@ -264,7 +264,7 @@
"source": [
"def parseProduct(TokenList: list[str]) -> tuple[ParseTree, list[str]]:\n",
" result, Rest = parseFactor(TokenList)\n",
- " while len(Rest) > 0 and Rest[0] in string.ascii_letters + '(':\n",
+ " while len(Rest) > 0 and Rest[0] in string.ascii_letters + '(∅𝜀':\n",
" arg, Rest = parseFactor(Rest)\n",
" result = (result, '⋅', arg)\n",
" return result, Rest"
diff --git a/Python/Chapter-06/1-Top-Down-Parser.ipynb b/Python/Chapter-06/1-Top-Down-Parser.ipynb
index e812c22..d44fb17 100644
--- a/Python/Chapter-06/1-Top-Down-Parser.ipynb
+++ b/Python/Chapter-06/1-Top-Down-Parser.ipynb
@@ -2,7 +2,75 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": 2,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Collecting mypy\n",
+ " Downloading mypy-1.13.0-cp312-cp312-macosx_11_0_arm64.whl.metadata (2.1 kB)\n",
+ "Requirement already satisfied: typing-extensions>=4.6.0 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from mypy) (4.11.0)\n",
+ "Collecting mypy-extensions>=1.0.0 (from mypy)\n",
+ " Using cached mypy_extensions-1.0.0-py3-none-any.whl.metadata (1.1 kB)\n",
+ "Downloading mypy-1.13.0-cp312-cp312-macosx_11_0_arm64.whl (10.1 MB)\n",
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.1/10.1 MB\u001b[0m \u001b[31m16.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m \u001b[36m0:00:01\u001b[0m\n",
+ "\u001b[?25hUsing cached mypy_extensions-1.0.0-py3-none-any.whl (4.7 kB)\n",
+ "Installing collected packages: mypy-extensions, mypy\n",
+ "Successfully installed mypy-1.13.0 mypy-extensions-1.0.0\n"
+ ]
+ }
+ ],
+ "source": [
+ "!pip install mypy"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Collecting nb_mypy\n",
+ " Using cached nb_mypy-1.0.5-py3-none-any.whl\n",
+ "Collecting astor<1,>=0.8 (from nb_mypy)\n",
+ " Using cached astor-0.8.1-py2.py3-none-any.whl.metadata (4.2 kB)\n",
+ "Requirement already satisfied: mypy<2,>=1 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from nb_mypy) (1.13.0)\n",
+ "Requirement already satisfied: ipython<9,>=8.0 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from nb_mypy) (8.27.0)\n",
+ "Requirement already satisfied: decorator in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from ipython<9,>=8.0->nb_mypy) (5.1.1)\n",
+ "Requirement already satisfied: jedi>=0.16 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from ipython<9,>=8.0->nb_mypy) (0.19.1)\n",
+ "Requirement already satisfied: matplotlib-inline in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from ipython<9,>=8.0->nb_mypy) (0.1.6)\n",
+ "Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from ipython<9,>=8.0->nb_mypy) (3.0.43)\n",
+ "Requirement already satisfied: pygments>=2.4.0 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from ipython<9,>=8.0->nb_mypy) (2.15.1)\n",
+ "Requirement already satisfied: stack-data in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from ipython<9,>=8.0->nb_mypy) (0.2.0)\n",
+ "Requirement already satisfied: traitlets>=5.13.0 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from ipython<9,>=8.0->nb_mypy) (5.14.3)\n",
+ "Requirement already satisfied: pexpect>4.3 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from ipython<9,>=8.0->nb_mypy) (4.8.0)\n",
+ "Requirement already satisfied: typing-extensions>=4.6.0 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from mypy<2,>=1->nb_mypy) (4.11.0)\n",
+ "Requirement already satisfied: mypy-extensions>=1.0.0 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from mypy<2,>=1->nb_mypy) (1.0.0)\n",
+ "Requirement already satisfied: parso<0.9.0,>=0.8.3 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from jedi>=0.16->ipython<9,>=8.0->nb_mypy) (0.8.3)\n",
+ "Requirement already satisfied: ptyprocess>=0.5 in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from pexpect>4.3->ipython<9,>=8.0->nb_mypy) (0.7.0)\n",
+ "Requirement already satisfied: wcwidth in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython<9,>=8.0->nb_mypy) (0.2.5)\n",
+ "Requirement already satisfied: executing in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from stack-data->ipython<9,>=8.0->nb_mypy) (0.8.3)\n",
+ "Requirement already satisfied: asttokens in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from stack-data->ipython<9,>=8.0->nb_mypy) (2.0.5)\n",
+ "Requirement already satisfied: pure-eval in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from stack-data->ipython<9,>=8.0->nb_mypy) (0.2.2)\n",
+ "Requirement already satisfied: six in /Users/stroetmann/opt/anaconda3/envs/ds/lib/python3.12/site-packages (from asttokens->stack-data->ipython<9,>=8.0->nb_mypy) (1.16.0)\n",
+ "Using cached astor-0.8.1-py2.py3-none-any.whl (27 kB)\n",
+ "Installing collected packages: astor, nb_mypy\n",
+ "Successfully installed astor-0.8.1 nb_mypy-1.0.5\n"
+ ]
+ }
+ ],
+ "source": [
+ "!pip install nb_mypy"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -52,7 +120,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -77,7 +145,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -100,7 +168,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -109,7 +177,7 @@
"['123', '+', '(', '234', '+', '345', '-', '2', '*', '*', '0', ')', '/', '7']"
]
},
- "execution_count": 4,
+ "execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@@ -134,7 +202,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -164,7 +232,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -189,7 +257,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -222,7 +290,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -258,7 +326,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@@ -292,7 +360,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -333,7 +401,7 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -356,7 +424,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
@@ -369,7 +437,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 16,
"metadata": {},
"outputs": [
{
@@ -378,7 +446,7 @@
"16.37777777777778"
]
},
- "execution_count": 13,
+ "execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@@ -389,7 +457,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": 17,
"metadata": {},
"outputs": [
{
@@ -398,7 +466,7 @@
"5.377777777777778"
]
},
- "execution_count": 14,
+ "execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@@ -409,7 +477,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": 18,
"metadata": {},
"outputs": [
{
@@ -418,7 +486,7 @@
"-5.0"
]
},
- "execution_count": 15,
+ "execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
@@ -455,7 +523,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.6"
+ "version": "3.12.7"
},
"varInspector": {
"cols": {
diff --git a/Python/Chapter-06/2-EBNF-Parser.ipynb b/Python/Chapter-06/2-EBNF-Parser.ipynb
index 9588259..a924da0 100644
--- a/Python/Chapter-06/2-EBNF-Parser.ipynb
+++ b/Python/Chapter-06/2-EBNF-Parser.ipynb
@@ -301,7 +301,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.6"
+ "version": "3.12.7"
},
"varInspector": {
"cols": {
diff --git a/Python/Chapter-07/01-Calculator.ipynb b/Python/Chapter-07/01-Calculator.ipynb
index 8627749..5e77cbd 100644
--- a/Python/Chapter-07/01-Calculator.ipynb
+++ b/Python/Chapter-07/01-Calculator.ipynb
@@ -33,7 +33,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -51,7 +51,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -67,7 +67,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -79,7 +79,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -88,7 +88,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -97,7 +97,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -108,7 +108,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -124,7 +124,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -140,7 +140,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -158,7 +158,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -174,7 +174,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -190,7 +190,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@@ -206,7 +206,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -222,7 +222,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -234,12 +234,12 @@
"metadata": {},
"source": [
"The function `p_stmnt_assign` implements the following grammar rule:\n",
- "$$ \\texttt{stmnt} \\rightarrow \\texttt{IDENTIFIER}\\; \\texttt{':='} \\; \\texttt{expr} $$"
+ "$$ \\texttt{stmnt} \\rightarrow \\texttt{IDENTIFIER}\\; \\texttt{':='} \\; \\texttt{expr} \\; \\texttt{';'}$$"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
@@ -253,12 +253,12 @@
"metadata": {},
"source": [
"The function `p_stmnt_expr` implements the following grammar rule:\n",
- "$$ \\texttt{stmnt} \\rightarrow \\texttt{expr} $$"
+ "$$ \\texttt{stmnt} \\rightarrow \\texttt{expr} \\; \\texttt{';'} $$"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
@@ -283,7 +283,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
@@ -316,7 +316,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
@@ -348,7 +348,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
@@ -374,7 +374,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
@@ -387,11 +387,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 22,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Generating LALR tables\n"
+ ]
+ }
+ ],
"source": [
- "parser = yacc.yacc(debug=True)"
+ "parser = yacc.yacc(write_tables=False, debug=True)"
]
},
{
@@ -410,7 +418,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
@@ -424,18 +432,54 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 24,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "calc> a := 3 * 3;\n",
+ "calc> b:= 4 * 4;\n",
+ "calc> z := a + b;\n",
+ "calc> z;\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "25.0\n"
+ ]
+ },
+ {
+ "name": "stdin",
+ "output_type": "stream",
+ "text": [
+ "calc> \n"
+ ]
+ }
+ ],
"source": [
"main()"
]
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'a': 9.0, 'b': 16.0, 'z': 25.0}"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"Names2Values"
]
@@ -464,7 +508,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.6"
+ "version": "3.12.7"
},
"varInspector": {
"cols": {
diff --git a/Python/Chapter-07/02-Differentiator.ipynb b/Python/Chapter-07/02-Differentiator.ipynb
index 2b76304..5fae297 100644
--- a/Python/Chapter-07/02-Differentiator.ipynb
+++ b/Python/Chapter-07/02-Differentiator.ipynb
@@ -232,14 +232,6 @@
"start = 'expr'"
]
},
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "The function `p_stmnt_assign` implements the following grammar rule:\n",
- "$$ \\texttt{stmnt} \\rightarrow \\texttt{IDENTIFIER}\\; \\texttt{':='} \\; \\texttt{expr} $$"
- ]
- },
{
"cell_type": "markdown",
"metadata": {},
@@ -401,7 +393,7 @@
"metadata": {},
"outputs": [],
"source": [
- "parser = yacc.yacc()"
+ "parser = yacc.yacc(write_tables=False, debug=True)"
]
},
{
@@ -616,6 +608,15 @@
"test(\"x ** x\")"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "test(\"x * ln(x) / exp(x/x)\")"
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
@@ -640,7 +641,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.6"
+ "version": "3.12.7"
},
"varInspector": {
"cols": {
diff --git a/Python/Chapter-07/03-Interpreter.ipynb b/Python/Chapter-07/03-Interpreter.ipynb
index 32b4b0b..09c16e8 100644
--- a/Python/Chapter-07/03-Interpreter.ipynb
+++ b/Python/Chapter-07/03-Interpreter.ipynb
@@ -2,17 +2,9 @@
"cells": [
{
"cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Version 1.0.5\n"
- ]
- }
- ],
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"%load_ext nb_mypy"
]
@@ -33,7 +25,7 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -42,7 +34,7 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -67,7 +59,7 @@
" Multi-line comments start with the string `/*` and end with the string `*/`.\n",
" Note the use of the *non-greedy* quantor `*?`. If we have code like\n",
" ```\n",
- " /* blah */ a = 1; /* blub */\n",
+ " /* blah */ a := 1; /* blub */\n",
" ```\n",
" the greedy quantor would recognize the whole line as one comment. \n",
"- The regular expression `//.*` recognizes single-line comments.\n",
@@ -76,7 +68,7 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -95,7 +87,7 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -107,7 +99,7 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -127,7 +119,7 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -143,7 +135,7 @@
},
{
"cell_type": "code",
- "execution_count": 8,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -163,7 +155,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -179,7 +171,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -195,7 +187,7 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -214,7 +206,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -233,7 +225,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -245,7 +237,7 @@
},
{
"cell_type": "code",
- "execution_count": 14,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -254,7 +246,7 @@
},
{
"cell_type": "code",
- "execution_count": 15,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -263,7 +255,7 @@
},
{
"cell_type": "code",
- "execution_count": 16,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -279,138 +271,25 @@
},
{
"cell_type": "code",
- "execution_count": 17,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "n := read();\n",
- "s := 0;\n",
- "i := 0;\n",
- "while (i < n * n) {\n",
- " i := i + 1;\n",
- " s := s + i;\n",
- "}\n",
- "print(s);\n",
- "\n",
- "LexToken(ID,'n',1,0)\n",
- "LexToken(ASSIGN,':=',1,2)\n",
- "LexToken(ID,'read',1,5)\n",
- "LexToken((,'(',1,9)\n",
- "LexToken(),')',1,10)\n",
- "LexToken(;,';',1,11)\n",
- "LexToken(ID,'s',2,13)\n",
- "LexToken(ASSIGN,':=',2,15)\n",
- "LexToken(NUMBER,0,2,18)\n",
- "LexToken(;,';',2,19)\n",
- "LexToken(ID,'i',3,21)\n",
- "LexToken(ASSIGN,':=',3,23)\n",
- "LexToken(NUMBER,0,3,26)\n",
- "LexToken(;,';',3,27)\n",
- "LexToken(WHILE,'while',4,29)\n",
- "LexToken((,'(',4,35)\n",
- "LexToken(ID,'i',4,36)\n",
- "LexToken(<,'<',4,38)\n",
- "LexToken(ID,'n',4,40)\n",
- "LexToken(*,'*',4,42)\n",
- "LexToken(ID,'n',4,44)\n",
- "LexToken(),')',4,45)\n",
- "LexToken({,'{',4,47)\n",
- "LexToken(ID,'i',5,53)\n",
- "LexToken(ASSIGN,':=',5,55)\n",
- "LexToken(ID,'i',5,58)\n",
- "LexToken(+,'+',5,60)\n",
- "LexToken(NUMBER,1,5,62)\n",
- "LexToken(;,';',5,63)\n",
- "LexToken(ID,'s',6,69)\n",
- "LexToken(ASSIGN,':=',6,71)\n",
- "LexToken(ID,'s',6,74)\n",
- "LexToken(+,'+',6,76)\n",
- "LexToken(ID,'i',6,78)\n",
- "LexToken(;,';',6,79)\n",
- "LexToken(},'}',7,81)\n",
- "LexToken(ID,'print',8,83)\n",
- "LexToken((,'(',8,88)\n",
- "LexToken(ID,'s',8,89)\n",
- "LexToken(),')',8,90)\n",
- "LexToken(;,';',8,91)\n"
- ]
- }
- ],
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"test_scanner('sum.sl')"
]
},
{
"cell_type": "code",
- "execution_count": 18,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "f := 1;\n",
- "i := 0;\n",
- "n := read();\n",
- "while (i < n) {\n",
- " i := i + 1;\n",
- " f := i * f;\n",
- "}\n",
- "print(f);\n",
- "\n",
- "\n",
- "LexToken(ID,'f',1,0)\n",
- "LexToken(ASSIGN,':=',1,2)\n",
- "LexToken(NUMBER,1,1,5)\n",
- "LexToken(;,';',1,6)\n",
- "LexToken(ID,'i',2,8)\n",
- "LexToken(ASSIGN,':=',2,10)\n",
- "LexToken(NUMBER,0,2,13)\n",
- "LexToken(;,';',2,14)\n",
- "LexToken(ID,'n',3,16)\n",
- "LexToken(ASSIGN,':=',3,18)\n",
- "LexToken(ID,'read',3,21)\n",
- "LexToken((,'(',3,25)\n",
- "LexToken(),')',3,26)\n",
- "LexToken(;,';',3,27)\n",
- "LexToken(WHILE,'while',4,29)\n",
- "LexToken((,'(',4,35)\n",
- "LexToken(ID,'i',4,36)\n",
- "LexToken(<,'<',4,38)\n",
- "LexToken(ID,'n',4,40)\n",
- "LexToken(),')',4,41)\n",
- "LexToken({,'{',4,43)\n",
- "LexToken(ID,'i',5,49)\n",
- "LexToken(ASSIGN,':=',5,51)\n",
- "LexToken(ID,'i',5,54)\n",
- "LexToken(+,'+',5,56)\n",
- "LexToken(NUMBER,1,5,58)\n",
- "LexToken(;,';',5,59)\n",
- "LexToken(ID,'f',6,65)\n",
- "LexToken(ASSIGN,':=',6,67)\n",
- "LexToken(ID,'i',6,70)\n",
- "LexToken(*,'*',6,72)\n",
- "LexToken(ID,'f',6,74)\n",
- "LexToken(;,';',6,75)\n",
- "LexToken(},'}',7,77)\n",
- "LexToken(ID,'print',8,79)\n",
- "LexToken((,'(',8,84)\n",
- "LexToken(ID,'f',8,85)\n",
- "LexToken(),')',8,86)\n",
- "LexToken(;,';',8,87)\n"
- ]
- }
- ],
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"test_scanner('factorial.sl')"
]
},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -477,7 +356,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -493,24 +372,9 @@
},
{
"cell_type": "code",
- "execution_count": 21,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "n := read();\n",
- "s := 0;\n",
- "i := 0;\n",
- "while (i < n * n) {\n",
- " i := i + 1;\n",
- " s := s + i;\n",
- "}\n",
- "print(s);\n"
- ]
- }
- ],
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"!cat sum.sl"
]
@@ -524,7 +388,7 @@
},
{
"cell_type": "code",
- "execution_count": 22,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -535,7 +399,7 @@
},
{
"cell_type": "code",
- "execution_count": 23,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -550,7 +414,7 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -577,7 +441,7 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -608,7 +472,7 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -625,11 +489,11 @@
" p[0] = p[1]\n",
" \n",
"def p_product_times(p):\n",
- " \"product : product '*' expr\"\n",
+ " \"product : product '*' factor\"\n",
" p[0] = ('*', p[1], p[3])\n",
" \n",
"def p_product_divide(p):\n",
- " \"product : product '/' expr\"\n",
+ " \"product : product '/' factor\"\n",
" p[0] = ('/', p[1], p[3])\n",
"\n",
"def p_product_modulo(p):\n",
@@ -659,7 +523,7 @@
},
{
"cell_type": "code",
- "execution_count": 27,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -686,7 +550,7 @@
},
{
"cell_type": "code",
- "execution_count": 28,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -700,11 +564,11 @@
},
{
"cell_type": "code",
- "execution_count": 30,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
- "parser = yacc.yacc()"
+ "parser = yacc.yacc(write_tables=False, debug=True)"
]
},
{
@@ -716,7 +580,7 @@
},
{
"cell_type": "code",
- "execution_count": 31,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -734,7 +598,7 @@
},
{
"cell_type": "code",
- "execution_count": 32,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -749,415 +613,16 @@
},
{
"cell_type": "code",
- "execution_count": 33,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "('.', (':=', 'n', ('call', 'read')), (':=', 's', 0), (':=', 'i', 0), ('while', ('<', 'i', ('*', 'n', 'n')), ('.', (':=', 'i', ('+', 'i', 1)), (':=', 's', ('+', 's', 'i')))), ('call', 'print', 's'))\n"
- ]
- },
- {
- "data": {
- "image/svg+xml": [
- "\n",
- "\n",
- "\n",
- "\n",
- "\n"
- ],
- "text/plain": [
- ""
- ]
- },
- "execution_count": 33,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"parse('sum.sl')"
]
},
{
"cell_type": "code",
- "execution_count": 34,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -1176,7 +641,7 @@
},
{
"cell_type": "code",
- "execution_count": 35,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -1186,7 +651,7 @@
},
{
"cell_type": "code",
- "execution_count": 36,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -1196,7 +661,7 @@
},
{
"cell_type": "code",
- "execution_count": 37,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -1218,7 +683,7 @@
},
{
"cell_type": "code",
- "execution_count": 38,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -1241,7 +706,7 @@
},
{
"cell_type": "code",
- "execution_count": 39,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -1276,7 +741,7 @@
},
{
"cell_type": "code",
- "execution_count": 40,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -1311,7 +776,7 @@
},
{
"cell_type": "code",
- "execution_count": 41,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -1339,31 +804,16 @@
},
{
"cell_type": "code",
- "execution_count": 42,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "n := read();\n",
- "s := 0;\n",
- "i := 0;\n",
- "while (i < n * n) {\n",
- " i := i + 1;\n",
- " s := s + i;\n",
- "}\n",
- "print(s);\n"
- ]
- }
- ],
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"!cat sum.sl"
]
},
{
"cell_type": "code",
- "execution_count": 45,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -1378,87 +828,27 @@
},
{
"cell_type": "code",
- "execution_count": 46,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "('.', (':=', 'n', ('call', 'read')), (':=', 's', 0), (':=', 'i', 0), ('while', ('<', 'i', ('*', 'n', 'n')), ('.', (':=', 'i', ('+', 'i', 1)), (':=', 's', ('+', 's', 'i')))), ('call', 'print', 's'))\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "Please enter a natural number: 6\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "666\n"
- ]
- }
- ],
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"main('sum.sl')"
]
},
{
"cell_type": "code",
- "execution_count": 47,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "f := 1;\n",
- "i := 0;\n",
- "n := read();\n",
- "while (i < n) {\n",
- " i := i + 1;\n",
- " f := i * f;\n",
- "}\n",
- "print(f);\n",
- "\n"
- ]
- }
- ],
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"!cat factorial.sl"
]
},
{
"cell_type": "code",
- "execution_count": 48,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "('.', (':=', 'f', 1), (':=', 'i', 0), (':=', 'n', ('call', 'read')), ('while', ('<', 'i', 'n'), ('.', (':=', 'i', ('+', 'i', 1)), (':=', 'f', ('*', 'i', 'f')))), ('call', 'print', 'f'))\n"
- ]
- },
- {
- "name": "stdin",
- "output_type": "stream",
- "text": [
- "Please enter a natural number: 7\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "5040\n"
- ]
- }
- ],
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
"source": [
"main('factorial.sl')"
]
@@ -1487,7 +877,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.6"
+ "version": "3.12.7"
},
"varInspector": {
"cols": {
diff --git a/Python/Chapter-12/Compiler.ipynb b/Python/Chapter-12/Compiler.ipynb
index aee6cc5..ff7eb15 100644
--- a/Python/Chapter-12/Compiler.ipynb
+++ b/Python/Chapter-12/Compiler.ipynb
@@ -46,7 +46,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -55,7 +55,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -73,7 +73,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -89,7 +89,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -119,7 +119,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
@@ -138,7 +138,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -159,7 +159,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -178,7 +178,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -194,7 +194,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -210,7 +210,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -229,7 +229,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
@@ -248,7 +248,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
@@ -267,7 +267,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
@@ -276,7 +276,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
@@ -285,7 +285,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
@@ -300,9 +300,93 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "int sum(int n) {\n",
+ " int s;\n",
+ " s = 0;\n",
+ " while (n != 0) {\n",
+ " s = s + n;\n",
+ " n = n - 1;\n",
+ " }\n",
+ " return s;\n",
+ "}\n",
+ "\n",
+ "int main() {\n",
+ " int n;\n",
+ " n = 6 * 6;\n",
+ " println(sum(n));\n",
+ "}\n",
+ "\n",
+ "LexToken(INT,'int',1,0)\n",
+ "LexToken(ID,'sum',1,4)\n",
+ "LexToken((,'(',1,7)\n",
+ "LexToken(INT,'int',1,8)\n",
+ "LexToken(ID,'n',1,12)\n",
+ "LexToken(),')',1,13)\n",
+ "LexToken({,'{',1,15)\n",
+ "LexToken(INT,'int',2,21)\n",
+ "LexToken(ID,'s',2,25)\n",
+ "LexToken(;,';',2,26)\n",
+ "LexToken(ID,'s',3,32)\n",
+ "LexToken(=,'=',3,34)\n",
+ "LexToken(NUMBER,'0',3,36)\n",
+ "LexToken(;,';',3,37)\n",
+ "LexToken(WHILE,'while',4,43)\n",
+ "LexToken((,'(',4,49)\n",
+ "LexToken(ID,'n',4,50)\n",
+ "LexToken(NE,'!=',4,52)\n",
+ "LexToken(NUMBER,'0',4,55)\n",
+ "LexToken(),')',4,56)\n",
+ "LexToken({,'{',4,58)\n",
+ "LexToken(ID,'s',5,68)\n",
+ "LexToken(=,'=',5,70)\n",
+ "LexToken(ID,'s',5,72)\n",
+ "LexToken(+,'+',5,74)\n",
+ "LexToken(ID,'n',5,76)\n",
+ "LexToken(;,';',5,77)\n",
+ "LexToken(ID,'n',6,87)\n",
+ "LexToken(=,'=',6,89)\n",
+ "LexToken(ID,'n',6,91)\n",
+ "LexToken(-,'-',6,93)\n",
+ "LexToken(NUMBER,'1',6,95)\n",
+ "LexToken(;,';',6,96)\n",
+ "LexToken(},'}',7,102)\n",
+ "LexToken(RETURN,'return',8,108)\n",
+ "LexToken(ID,'s',8,115)\n",
+ "LexToken(;,';',8,116)\n",
+ "LexToken(},'}',9,118)\n",
+ "LexToken(INT,'int',11,121)\n",
+ "LexToken(ID,'main',11,125)\n",
+ "LexToken((,'(',11,129)\n",
+ "LexToken(),')',11,130)\n",
+ "LexToken({,'{',11,132)\n",
+ "LexToken(INT,'int',12,138)\n",
+ "LexToken(ID,'n',12,142)\n",
+ "LexToken(;,';',12,143)\n",
+ "LexToken(ID,'n',13,149)\n",
+ "LexToken(=,'=',13,151)\n",
+ "LexToken(NUMBER,'6',13,153)\n",
+ "LexToken(*,'*',13,155)\n",
+ "LexToken(NUMBER,'6',13,157)\n",
+ "LexToken(;,';',13,158)\n",
+ "LexToken(ID,'println',14,164)\n",
+ "LexToken((,'(',14,171)\n",
+ "LexToken(ID,'sum',14,172)\n",
+ "LexToken((,'(',14,175)\n",
+ "LexToken(ID,'n',14,176)\n",
+ "LexToken(),')',14,177)\n",
+ "LexToken(),')',14,178)\n",
+ "LexToken(;,';',14,179)\n",
+ "LexToken(},'}',15,181)\n"
+ ]
+ }
+ ],
"source": [
"for t in test_scanner('Examples/MySum.c'):\n",
" print(t)"
@@ -391,7 +475,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
@@ -407,7 +491,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
@@ -447,7 +531,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
@@ -465,7 +549,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
@@ -480,7 +564,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
@@ -491,7 +575,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
@@ -518,7 +602,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
@@ -533,7 +617,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
@@ -559,7 +643,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
@@ -594,7 +678,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 26,
"metadata": {},
"outputs": [],
"source": [
@@ -641,7 +725,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
@@ -684,7 +768,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
@@ -711,7 +795,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
@@ -732,9 +816,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 30,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Generating LALR tables\n"
+ ]
+ }
+ ],
"source": [
"parser = yacc.yacc(write_tables=False, debug=True)"
]
@@ -748,11 +840,1851 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 31,
"metadata": {
"scrolled": true
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Created by PLY version 3.11 (http://www.dabeaz.com/ply)\n",
+ "\n",
+ "Grammar\n",
+ "\n",
+ "Rule 0 S' -> program\n",
+ "Rule 1 bool_expr -> bool_expr OR bool_expr\n",
+ "Rule 2 decl_list -> \n",
+ "Rule 3 expr_list -> \n",
+ "Rule 4 expr -> expr + expr\n",
+ "Rule 5 function -> INT ID ( param_list ) { decl_list stmnt_list }\n",
+ "Rule 6 param_list -> \n",
+ "Rule 7 program -> function\n",
+ "Rule 8 stmnt -> IF ( bool_expr ) stmnt\n",
+ "Rule 9 stmnt_list -> \n",
+ "Rule 10 bool_expr -> bool_expr AND bool_expr\n",
+ "Rule 11 decl_list -> INT ID ; decl_list\n",
+ "Rule 12 expr_list -> expr\n",
+ "Rule 13 expr -> expr - expr\n",
+ "Rule 14 param_list -> INT ID\n",
+ "Rule 15 program -> function program\n",
+ "Rule 16 stmnt -> IF ( bool_expr ) stmnt ELSE stmnt\n",
+ "Rule 17 stmnt_list -> stmnt stmnt_list\n",
+ "Rule 18 bool_expr -> ! bool_expr\n",
+ "Rule 19 expr_list -> expr , ne_expr_list\n",
+ "Rule 20 expr -> expr * expr\n",
+ "Rule 21 param_list -> INT ID , ne_param_list\n",
+ "Rule 22 stmnt -> WHILE ( bool_expr ) stmnt\n",
+ "Rule 23 bool_expr -> ( bool_expr )\n",
+ "Rule 24 expr -> expr / expr\n",
+ "Rule 25 ne_expr_list -> expr\n",
+ "Rule 26 ne_param_list -> INT ID\n",
+ "Rule 27 stmnt -> { stmnt_list }\n",
+ "Rule 28 bool_expr -> expr EQ expr\n",
+ "Rule 29 expr -> expr % expr\n",
+ "Rule 30 ne_expr_list -> expr , ne_expr_list\n",
+ "Rule 31 ne_param_list -> INT ID , ne_param_list\n",
+ "Rule 32 stmnt -> ID = expr ;\n",
+ "Rule 33 bool_expr -> expr NE expr\n",
+ "Rule 34 expr -> ( expr )\n",
+ "Rule 35 stmnt -> RETURN expr ;\n",
+ "Rule 36 bool_expr -> expr LE expr\n",
+ "Rule 37 expr -> NUMBER\n",
+ "Rule 38 stmnt -> expr ;\n",
+ "Rule 39 bool_expr -> expr GE expr\n",
+ "Rule 40 expr -> ID\n",
+ "Rule 41 bool_expr -> expr < expr\n",
+ "Rule 42 expr -> ID ( expr_list )\n",
+ "Rule 43 bool_expr -> expr > expr\n",
+ "\n",
+ "Terminals, with rules where they appear\n",
+ "\n",
+ "! : 18\n",
+ "% : 29\n",
+ "( : 5 8 16 22 23 34 42\n",
+ ") : 5 8 16 22 23 34 42\n",
+ "* : 20\n",
+ "+ : 4\n",
+ ", : 19 21 30 31\n",
+ "- : 13\n",
+ "/ : 24\n",
+ "; : 11 32 35 38\n",
+ "< : 41\n",
+ "= : 32\n",
+ "> : 43\n",
+ "AND : 10\n",
+ "ELSE : 16\n",
+ "EQ : 28\n",
+ "GE : 39\n",
+ "ID : 5 11 14 21 26 31 32 40 42\n",
+ "IF : 8 16\n",
+ "INT : 5 11 14 21 26 31\n",
+ "LE : 36\n",
+ "NE : 33\n",
+ "NUMBER : 37\n",
+ "OR : 1\n",
+ "RETURN : 35\n",
+ "WHILE : 22\n",
+ "error : \n",
+ "{ : 5 27\n",
+ "} : 5 27\n",
+ "\n",
+ "Nonterminals, with rules where they appear\n",
+ "\n",
+ "bool_expr : 1 1 8 10 10 16 18 22 23\n",
+ "decl_list : 5 11\n",
+ "expr : 4 4 12 13 13 19 20 20 24 24 25 28 28 29 29 30 32 33 33 34 35 36 36 38 39 39 41 41 43 43\n",
+ "expr_list : 42\n",
+ "function : 7 15\n",
+ "ne_expr_list : 19 30\n",
+ "ne_param_list : 21 31\n",
+ "param_list : 5\n",
+ "program : 15 0\n",
+ "stmnt : 8 16 16 17 22\n",
+ "stmnt_list : 5 17 27\n",
+ "\n",
+ "Parsing method: LALR\n",
+ "\n",
+ "state 0\n",
+ "\n",
+ " (0) S' -> . program\n",
+ " (7) program -> . function\n",
+ " (15) program -> . function program\n",
+ " (5) function -> . INT ID ( param_list ) { decl_list stmnt_list }\n",
+ "\n",
+ " INT shift and go to state 3\n",
+ "\n",
+ " program shift and go to state 1\n",
+ " function shift and go to state 2\n",
+ "\n",
+ "state 1\n",
+ "\n",
+ " (0) S' -> program .\n",
+ "\n",
+ "\n",
+ "\n",
+ "state 2\n",
+ "\n",
+ " (7) program -> function .\n",
+ " (15) program -> function . program\n",
+ " (7) program -> . function\n",
+ " (15) program -> . function program\n",
+ " (5) function -> . INT ID ( param_list ) { decl_list stmnt_list }\n",
+ "\n",
+ " $end reduce using rule 7 (program -> function .)\n",
+ " INT shift and go to state 3\n",
+ "\n",
+ " function shift and go to state 2\n",
+ " program shift and go to state 4\n",
+ "\n",
+ "state 3\n",
+ "\n",
+ " (5) function -> INT . ID ( param_list ) { decl_list stmnt_list }\n",
+ "\n",
+ " ID shift and go to state 5\n",
+ "\n",
+ "\n",
+ "state 4\n",
+ "\n",
+ " (15) program -> function program .\n",
+ "\n",
+ " $end reduce using rule 15 (program -> function program .)\n",
+ "\n",
+ "\n",
+ "state 5\n",
+ "\n",
+ " (5) function -> INT ID . ( param_list ) { decl_list stmnt_list }\n",
+ "\n",
+ " ( shift and go to state 6\n",
+ "\n",
+ "\n",
+ "state 6\n",
+ "\n",
+ " (5) function -> INT ID ( . param_list ) { decl_list stmnt_list }\n",
+ " (6) param_list -> .\n",
+ " (14) param_list -> . INT ID\n",
+ " (21) param_list -> . INT ID , ne_param_list\n",
+ "\n",
+ " ) reduce using rule 6 (param_list -> .)\n",
+ " INT shift and go to state 7\n",
+ "\n",
+ " param_list shift and go to state 8\n",
+ "\n",
+ "state 7\n",
+ "\n",
+ " (14) param_list -> INT . ID\n",
+ " (21) param_list -> INT . ID , ne_param_list\n",
+ "\n",
+ " ID shift and go to state 9\n",
+ "\n",
+ "\n",
+ "state 8\n",
+ "\n",
+ " (5) function -> INT ID ( param_list . ) { decl_list stmnt_list }\n",
+ "\n",
+ " ) shift and go to state 10\n",
+ "\n",
+ "\n",
+ "state 9\n",
+ "\n",
+ " (14) param_list -> INT ID .\n",
+ " (21) param_list -> INT ID . , ne_param_list\n",
+ "\n",
+ " ) reduce using rule 14 (param_list -> INT ID .)\n",
+ " , shift and go to state 11\n",
+ "\n",
+ "\n",
+ "state 10\n",
+ "\n",
+ " (5) function -> INT ID ( param_list ) . { decl_list stmnt_list }\n",
+ "\n",
+ " { shift and go to state 12\n",
+ "\n",
+ "\n",
+ "state 11\n",
+ "\n",
+ " (21) param_list -> INT ID , . ne_param_list\n",
+ " (26) ne_param_list -> . INT ID\n",
+ " (31) ne_param_list -> . INT ID , ne_param_list\n",
+ "\n",
+ " INT shift and go to state 13\n",
+ "\n",
+ " ne_param_list shift and go to state 14\n",
+ "\n",
+ "state 12\n",
+ "\n",
+ " (5) function -> INT ID ( param_list ) { . decl_list stmnt_list }\n",
+ " (2) decl_list -> .\n",
+ " (11) decl_list -> . INT ID ; decl_list\n",
+ "\n",
+ " IF reduce using rule 2 (decl_list -> .)\n",
+ " WHILE reduce using rule 2 (decl_list -> .)\n",
+ " { reduce using rule 2 (decl_list -> .)\n",
+ " ID reduce using rule 2 (decl_list -> .)\n",
+ " RETURN reduce using rule 2 (decl_list -> .)\n",
+ " ( reduce using rule 2 (decl_list -> .)\n",
+ " NUMBER reduce using rule 2 (decl_list -> .)\n",
+ " } reduce using rule 2 (decl_list -> .)\n",
+ " INT shift and go to state 15\n",
+ "\n",
+ " decl_list shift and go to state 16\n",
+ "\n",
+ "state 13\n",
+ "\n",
+ " (26) ne_param_list -> INT . ID\n",
+ " (31) ne_param_list -> INT . ID , ne_param_list\n",
+ "\n",
+ " ID shift and go to state 17\n",
+ "\n",
+ "\n",
+ "state 14\n",
+ "\n",
+ " (21) param_list -> INT ID , ne_param_list .\n",
+ "\n",
+ " ) reduce using rule 21 (param_list -> INT ID , ne_param_list .)\n",
+ "\n",
+ "\n",
+ "state 15\n",
+ "\n",
+ " (11) decl_list -> INT . ID ; decl_list\n",
+ "\n",
+ " ID shift and go to state 18\n",
+ "\n",
+ "\n",
+ "state 16\n",
+ "\n",
+ " (5) function -> INT ID ( param_list ) { decl_list . stmnt_list }\n",
+ " (9) stmnt_list -> .\n",
+ " (17) stmnt_list -> . stmnt stmnt_list\n",
+ " (8) stmnt -> . IF ( bool_expr ) stmnt\n",
+ " (16) stmnt -> . IF ( bool_expr ) stmnt ELSE stmnt\n",
+ " (22) stmnt -> . WHILE ( bool_expr ) stmnt\n",
+ " (27) stmnt -> . { stmnt_list }\n",
+ " (32) stmnt -> . ID = expr ;\n",
+ " (35) stmnt -> . RETURN expr ;\n",
+ " (38) stmnt -> . expr ;\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " } reduce using rule 9 (stmnt_list -> .)\n",
+ " IF shift and go to state 24\n",
+ " WHILE shift and go to state 25\n",
+ " { shift and go to state 21\n",
+ " ID shift and go to state 19\n",
+ " RETURN shift and go to state 27\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ "\n",
+ " stmnt_list shift and go to state 22\n",
+ " stmnt shift and go to state 23\n",
+ " expr shift and go to state 26\n",
+ "\n",
+ "state 17\n",
+ "\n",
+ " (26) ne_param_list -> INT ID .\n",
+ " (31) ne_param_list -> INT ID . , ne_param_list\n",
+ "\n",
+ " ) reduce using rule 26 (ne_param_list -> INT ID .)\n",
+ " , shift and go to state 29\n",
+ "\n",
+ "\n",
+ "state 18\n",
+ "\n",
+ " (11) decl_list -> INT ID . ; decl_list\n",
+ "\n",
+ " ; shift and go to state 30\n",
+ "\n",
+ "\n",
+ "state 19\n",
+ "\n",
+ " (32) stmnt -> ID . = expr ;\n",
+ " (40) expr -> ID .\n",
+ " (42) expr -> ID . ( expr_list )\n",
+ "\n",
+ " = shift and go to state 31\n",
+ " ; reduce using rule 40 (expr -> ID .)\n",
+ " + reduce using rule 40 (expr -> ID .)\n",
+ " - reduce using rule 40 (expr -> ID .)\n",
+ " * reduce using rule 40 (expr -> ID .)\n",
+ " / reduce using rule 40 (expr -> ID .)\n",
+ " % reduce using rule 40 (expr -> ID .)\n",
+ " ( shift and go to state 32\n",
+ "\n",
+ "\n",
+ "state 20\n",
+ "\n",
+ " (34) expr -> ( . expr )\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 33\n",
+ "\n",
+ "state 21\n",
+ "\n",
+ " (27) stmnt -> { . stmnt_list }\n",
+ " (9) stmnt_list -> .\n",
+ " (17) stmnt_list -> . stmnt stmnt_list\n",
+ " (8) stmnt -> . IF ( bool_expr ) stmnt\n",
+ " (16) stmnt -> . IF ( bool_expr ) stmnt ELSE stmnt\n",
+ " (22) stmnt -> . WHILE ( bool_expr ) stmnt\n",
+ " (27) stmnt -> . { stmnt_list }\n",
+ " (32) stmnt -> . ID = expr ;\n",
+ " (35) stmnt -> . RETURN expr ;\n",
+ " (38) stmnt -> . expr ;\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " } reduce using rule 9 (stmnt_list -> .)\n",
+ " IF shift and go to state 24\n",
+ " WHILE shift and go to state 25\n",
+ " { shift and go to state 21\n",
+ " ID shift and go to state 19\n",
+ " RETURN shift and go to state 27\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ "\n",
+ " stmnt_list shift and go to state 35\n",
+ " stmnt shift and go to state 23\n",
+ " expr shift and go to state 26\n",
+ "\n",
+ "state 22\n",
+ "\n",
+ " (5) function -> INT ID ( param_list ) { decl_list stmnt_list . }\n",
+ "\n",
+ " } shift and go to state 36\n",
+ "\n",
+ "\n",
+ "state 23\n",
+ "\n",
+ " (17) stmnt_list -> stmnt . stmnt_list\n",
+ " (9) stmnt_list -> .\n",
+ " (17) stmnt_list -> . stmnt stmnt_list\n",
+ " (8) stmnt -> . IF ( bool_expr ) stmnt\n",
+ " (16) stmnt -> . IF ( bool_expr ) stmnt ELSE stmnt\n",
+ " (22) stmnt -> . WHILE ( bool_expr ) stmnt\n",
+ " (27) stmnt -> . { stmnt_list }\n",
+ " (32) stmnt -> . ID = expr ;\n",
+ " (35) stmnt -> . RETURN expr ;\n",
+ " (38) stmnt -> . expr ;\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " } reduce using rule 9 (stmnt_list -> .)\n",
+ " IF shift and go to state 24\n",
+ " WHILE shift and go to state 25\n",
+ " { shift and go to state 21\n",
+ " ID shift and go to state 19\n",
+ " RETURN shift and go to state 27\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ "\n",
+ " stmnt shift and go to state 23\n",
+ " stmnt_list shift and go to state 37\n",
+ " expr shift and go to state 26\n",
+ "\n",
+ "state 24\n",
+ "\n",
+ " (8) stmnt -> IF . ( bool_expr ) stmnt\n",
+ " (16) stmnt -> IF . ( bool_expr ) stmnt ELSE stmnt\n",
+ "\n",
+ " ( shift and go to state 38\n",
+ "\n",
+ "\n",
+ "state 25\n",
+ "\n",
+ " (22) stmnt -> WHILE . ( bool_expr ) stmnt\n",
+ "\n",
+ " ( shift and go to state 39\n",
+ "\n",
+ "\n",
+ "state 26\n",
+ "\n",
+ " (38) stmnt -> expr . ;\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ; shift and go to state 40\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 27\n",
+ "\n",
+ " (35) stmnt -> RETURN . expr ;\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 46\n",
+ "\n",
+ "state 28\n",
+ "\n",
+ " (37) expr -> NUMBER .\n",
+ "\n",
+ " ; reduce using rule 37 (expr -> NUMBER .)\n",
+ " + reduce using rule 37 (expr -> NUMBER .)\n",
+ " - reduce using rule 37 (expr -> NUMBER .)\n",
+ " * reduce using rule 37 (expr -> NUMBER .)\n",
+ " / reduce using rule 37 (expr -> NUMBER .)\n",
+ " % reduce using rule 37 (expr -> NUMBER .)\n",
+ " ) reduce using rule 37 (expr -> NUMBER .)\n",
+ " , reduce using rule 37 (expr -> NUMBER .)\n",
+ " EQ reduce using rule 37 (expr -> NUMBER .)\n",
+ " NE reduce using rule 37 (expr -> NUMBER .)\n",
+ " LE reduce using rule 37 (expr -> NUMBER .)\n",
+ " GE reduce using rule 37 (expr -> NUMBER .)\n",
+ " < reduce using rule 37 (expr -> NUMBER .)\n",
+ " > reduce using rule 37 (expr -> NUMBER .)\n",
+ " OR reduce using rule 37 (expr -> NUMBER .)\n",
+ " AND reduce using rule 37 (expr -> NUMBER .)\n",
+ "\n",
+ "\n",
+ "state 29\n",
+ "\n",
+ " (31) ne_param_list -> INT ID , . ne_param_list\n",
+ " (26) ne_param_list -> . INT ID\n",
+ " (31) ne_param_list -> . INT ID , ne_param_list\n",
+ "\n",
+ " INT shift and go to state 13\n",
+ "\n",
+ " ne_param_list shift and go to state 47\n",
+ "\n",
+ "state 30\n",
+ "\n",
+ " (11) decl_list -> INT ID ; . decl_list\n",
+ " (2) decl_list -> .\n",
+ " (11) decl_list -> . INT ID ; decl_list\n",
+ "\n",
+ " IF reduce using rule 2 (decl_list -> .)\n",
+ " WHILE reduce using rule 2 (decl_list -> .)\n",
+ " { reduce using rule 2 (decl_list -> .)\n",
+ " ID reduce using rule 2 (decl_list -> .)\n",
+ " RETURN reduce using rule 2 (decl_list -> .)\n",
+ " ( reduce using rule 2 (decl_list -> .)\n",
+ " NUMBER reduce using rule 2 (decl_list -> .)\n",
+ " } reduce using rule 2 (decl_list -> .)\n",
+ " INT shift and go to state 15\n",
+ "\n",
+ " decl_list shift and go to state 48\n",
+ "\n",
+ "state 31\n",
+ "\n",
+ " (32) stmnt -> ID = . expr ;\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 49\n",
+ "\n",
+ "state 32\n",
+ "\n",
+ " (42) expr -> ID ( . expr_list )\n",
+ " (3) expr_list -> .\n",
+ " (12) expr_list -> . expr\n",
+ " (19) expr_list -> . expr , ne_expr_list\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ) reduce using rule 3 (expr_list -> .)\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr_list shift and go to state 50\n",
+ " expr shift and go to state 51\n",
+ "\n",
+ "state 33\n",
+ "\n",
+ " (34) expr -> ( expr . )\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) shift and go to state 52\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 34\n",
+ "\n",
+ " (40) expr -> ID .\n",
+ " (42) expr -> ID . ( expr_list )\n",
+ "\n",
+ " ) reduce using rule 40 (expr -> ID .)\n",
+ " + reduce using rule 40 (expr -> ID .)\n",
+ " - reduce using rule 40 (expr -> ID .)\n",
+ " * reduce using rule 40 (expr -> ID .)\n",
+ " / reduce using rule 40 (expr -> ID .)\n",
+ " % reduce using rule 40 (expr -> ID .)\n",
+ " ; reduce using rule 40 (expr -> ID .)\n",
+ " , reduce using rule 40 (expr -> ID .)\n",
+ " EQ reduce using rule 40 (expr -> ID .)\n",
+ " NE reduce using rule 40 (expr -> ID .)\n",
+ " LE reduce using rule 40 (expr -> ID .)\n",
+ " GE reduce using rule 40 (expr -> ID .)\n",
+ " < reduce using rule 40 (expr -> ID .)\n",
+ " > reduce using rule 40 (expr -> ID .)\n",
+ " OR reduce using rule 40 (expr -> ID .)\n",
+ " AND reduce using rule 40 (expr -> ID .)\n",
+ " ( shift and go to state 32\n",
+ "\n",
+ "\n",
+ "state 35\n",
+ "\n",
+ " (27) stmnt -> { stmnt_list . }\n",
+ "\n",
+ " } shift and go to state 53\n",
+ "\n",
+ "\n",
+ "state 36\n",
+ "\n",
+ " (5) function -> INT ID ( param_list ) { decl_list stmnt_list } .\n",
+ "\n",
+ " INT reduce using rule 5 (function -> INT ID ( param_list ) { decl_list stmnt_list } .)\n",
+ " $end reduce using rule 5 (function -> INT ID ( param_list ) { decl_list stmnt_list } .)\n",
+ "\n",
+ "\n",
+ "state 37\n",
+ "\n",
+ " (17) stmnt_list -> stmnt stmnt_list .\n",
+ "\n",
+ " } reduce using rule 17 (stmnt_list -> stmnt stmnt_list .)\n",
+ "\n",
+ "\n",
+ "state 38\n",
+ "\n",
+ " (8) stmnt -> IF ( . bool_expr ) stmnt\n",
+ " (16) stmnt -> IF ( . bool_expr ) stmnt ELSE stmnt\n",
+ " (1) bool_expr -> . bool_expr OR bool_expr\n",
+ " (10) bool_expr -> . bool_expr AND bool_expr\n",
+ " (18) bool_expr -> . ! bool_expr\n",
+ " (23) bool_expr -> . ( bool_expr )\n",
+ " (28) bool_expr -> . expr EQ expr\n",
+ " (33) bool_expr -> . expr NE expr\n",
+ " (36) bool_expr -> . expr LE expr\n",
+ " (39) bool_expr -> . expr GE expr\n",
+ " (41) bool_expr -> . expr < expr\n",
+ " (43) bool_expr -> . expr > expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ! shift and go to state 56\n",
+ " ( shift and go to state 54\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " bool_expr shift and go to state 55\n",
+ " expr shift and go to state 57\n",
+ "\n",
+ "state 39\n",
+ "\n",
+ " (22) stmnt -> WHILE ( . bool_expr ) stmnt\n",
+ " (1) bool_expr -> . bool_expr OR bool_expr\n",
+ " (10) bool_expr -> . bool_expr AND bool_expr\n",
+ " (18) bool_expr -> . ! bool_expr\n",
+ " (23) bool_expr -> . ( bool_expr )\n",
+ " (28) bool_expr -> . expr EQ expr\n",
+ " (33) bool_expr -> . expr NE expr\n",
+ " (36) bool_expr -> . expr LE expr\n",
+ " (39) bool_expr -> . expr GE expr\n",
+ " (41) bool_expr -> . expr < expr\n",
+ " (43) bool_expr -> . expr > expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ! shift and go to state 56\n",
+ " ( shift and go to state 54\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " bool_expr shift and go to state 58\n",
+ " expr shift and go to state 57\n",
+ "\n",
+ "state 40\n",
+ "\n",
+ " (38) stmnt -> expr ; .\n",
+ "\n",
+ " IF reduce using rule 38 (stmnt -> expr ; .)\n",
+ " WHILE reduce using rule 38 (stmnt -> expr ; .)\n",
+ " { reduce using rule 38 (stmnt -> expr ; .)\n",
+ " ID reduce using rule 38 (stmnt -> expr ; .)\n",
+ " RETURN reduce using rule 38 (stmnt -> expr ; .)\n",
+ " ( reduce using rule 38 (stmnt -> expr ; .)\n",
+ " NUMBER reduce using rule 38 (stmnt -> expr ; .)\n",
+ " } reduce using rule 38 (stmnt -> expr ; .)\n",
+ " ELSE reduce using rule 38 (stmnt -> expr ; .)\n",
+ "\n",
+ "\n",
+ "state 41\n",
+ "\n",
+ " (4) expr -> expr + . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 59\n",
+ "\n",
+ "state 42\n",
+ "\n",
+ " (13) expr -> expr - . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 60\n",
+ "\n",
+ "state 43\n",
+ "\n",
+ " (20) expr -> expr * . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 61\n",
+ "\n",
+ "state 44\n",
+ "\n",
+ " (24) expr -> expr / . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 62\n",
+ "\n",
+ "state 45\n",
+ "\n",
+ " (29) expr -> expr % . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 63\n",
+ "\n",
+ "state 46\n",
+ "\n",
+ " (35) stmnt -> RETURN expr . ;\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ; shift and go to state 64\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 47\n",
+ "\n",
+ " (31) ne_param_list -> INT ID , ne_param_list .\n",
+ "\n",
+ " ) reduce using rule 31 (ne_param_list -> INT ID , ne_param_list .)\n",
+ "\n",
+ "\n",
+ "state 48\n",
+ "\n",
+ " (11) decl_list -> INT ID ; decl_list .\n",
+ "\n",
+ " IF reduce using rule 11 (decl_list -> INT ID ; decl_list .)\n",
+ " WHILE reduce using rule 11 (decl_list -> INT ID ; decl_list .)\n",
+ " { reduce using rule 11 (decl_list -> INT ID ; decl_list .)\n",
+ " ID reduce using rule 11 (decl_list -> INT ID ; decl_list .)\n",
+ " RETURN reduce using rule 11 (decl_list -> INT ID ; decl_list .)\n",
+ " ( reduce using rule 11 (decl_list -> INT ID ; decl_list .)\n",
+ " NUMBER reduce using rule 11 (decl_list -> INT ID ; decl_list .)\n",
+ " } reduce using rule 11 (decl_list -> INT ID ; decl_list .)\n",
+ "\n",
+ "\n",
+ "state 49\n",
+ "\n",
+ " (32) stmnt -> ID = expr . ;\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ; shift and go to state 65\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 50\n",
+ "\n",
+ " (42) expr -> ID ( expr_list . )\n",
+ "\n",
+ " ) shift and go to state 66\n",
+ "\n",
+ "\n",
+ "state 51\n",
+ "\n",
+ " (12) expr_list -> expr .\n",
+ " (19) expr_list -> expr . , ne_expr_list\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) reduce using rule 12 (expr_list -> expr .)\n",
+ " , shift and go to state 67\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 52\n",
+ "\n",
+ " (34) expr -> ( expr ) .\n",
+ "\n",
+ " ; reduce using rule 34 (expr -> ( expr ) .)\n",
+ " + reduce using rule 34 (expr -> ( expr ) .)\n",
+ " - reduce using rule 34 (expr -> ( expr ) .)\n",
+ " * reduce using rule 34 (expr -> ( expr ) .)\n",
+ " / reduce using rule 34 (expr -> ( expr ) .)\n",
+ " % reduce using rule 34 (expr -> ( expr ) .)\n",
+ " ) reduce using rule 34 (expr -> ( expr ) .)\n",
+ " , reduce using rule 34 (expr -> ( expr ) .)\n",
+ " EQ reduce using rule 34 (expr -> ( expr ) .)\n",
+ " NE reduce using rule 34 (expr -> ( expr ) .)\n",
+ " LE reduce using rule 34 (expr -> ( expr ) .)\n",
+ " GE reduce using rule 34 (expr -> ( expr ) .)\n",
+ " < reduce using rule 34 (expr -> ( expr ) .)\n",
+ " > reduce using rule 34 (expr -> ( expr ) .)\n",
+ " OR reduce using rule 34 (expr -> ( expr ) .)\n",
+ " AND reduce using rule 34 (expr -> ( expr ) .)\n",
+ "\n",
+ "\n",
+ "state 53\n",
+ "\n",
+ " (27) stmnt -> { stmnt_list } .\n",
+ "\n",
+ " IF reduce using rule 27 (stmnt -> { stmnt_list } .)\n",
+ " WHILE reduce using rule 27 (stmnt -> { stmnt_list } .)\n",
+ " { reduce using rule 27 (stmnt -> { stmnt_list } .)\n",
+ " ID reduce using rule 27 (stmnt -> { stmnt_list } .)\n",
+ " RETURN reduce using rule 27 (stmnt -> { stmnt_list } .)\n",
+ " ( reduce using rule 27 (stmnt -> { stmnt_list } .)\n",
+ " NUMBER reduce using rule 27 (stmnt -> { stmnt_list } .)\n",
+ " } reduce using rule 27 (stmnt -> { stmnt_list } .)\n",
+ " ELSE reduce using rule 27 (stmnt -> { stmnt_list } .)\n",
+ "\n",
+ "\n",
+ "state 54\n",
+ "\n",
+ " (23) bool_expr -> ( . bool_expr )\n",
+ " (34) expr -> ( . expr )\n",
+ " (1) bool_expr -> . bool_expr OR bool_expr\n",
+ " (10) bool_expr -> . bool_expr AND bool_expr\n",
+ " (18) bool_expr -> . ! bool_expr\n",
+ " (23) bool_expr -> . ( bool_expr )\n",
+ " (28) bool_expr -> . expr EQ expr\n",
+ " (33) bool_expr -> . expr NE expr\n",
+ " (36) bool_expr -> . expr LE expr\n",
+ " (39) bool_expr -> . expr GE expr\n",
+ " (41) bool_expr -> . expr < expr\n",
+ " (43) bool_expr -> . expr > expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ! shift and go to state 56\n",
+ " ( shift and go to state 54\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " bool_expr shift and go to state 68\n",
+ " expr shift and go to state 69\n",
+ "\n",
+ "state 55\n",
+ "\n",
+ " (8) stmnt -> IF ( bool_expr . ) stmnt\n",
+ " (16) stmnt -> IF ( bool_expr . ) stmnt ELSE stmnt\n",
+ " (1) bool_expr -> bool_expr . OR bool_expr\n",
+ " (10) bool_expr -> bool_expr . AND bool_expr\n",
+ "\n",
+ " ) shift and go to state 70\n",
+ " OR shift and go to state 71\n",
+ " AND shift and go to state 72\n",
+ "\n",
+ "\n",
+ "state 56\n",
+ "\n",
+ " (18) bool_expr -> ! . bool_expr\n",
+ " (1) bool_expr -> . bool_expr OR bool_expr\n",
+ " (10) bool_expr -> . bool_expr AND bool_expr\n",
+ " (18) bool_expr -> . ! bool_expr\n",
+ " (23) bool_expr -> . ( bool_expr )\n",
+ " (28) bool_expr -> . expr EQ expr\n",
+ " (33) bool_expr -> . expr NE expr\n",
+ " (36) bool_expr -> . expr LE expr\n",
+ " (39) bool_expr -> . expr GE expr\n",
+ " (41) bool_expr -> . expr < expr\n",
+ " (43) bool_expr -> . expr > expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ! shift and go to state 56\n",
+ " ( shift and go to state 54\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " bool_expr shift and go to state 73\n",
+ " expr shift and go to state 57\n",
+ "\n",
+ "state 57\n",
+ "\n",
+ " (28) bool_expr -> expr . EQ expr\n",
+ " (33) bool_expr -> expr . NE expr\n",
+ " (36) bool_expr -> expr . LE expr\n",
+ " (39) bool_expr -> expr . GE expr\n",
+ " (41) bool_expr -> expr . < expr\n",
+ " (43) bool_expr -> expr . > expr\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " EQ shift and go to state 74\n",
+ " NE shift and go to state 75\n",
+ " LE shift and go to state 76\n",
+ " GE shift and go to state 77\n",
+ " < shift and go to state 78\n",
+ " > shift and go to state 79\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 58\n",
+ "\n",
+ " (22) stmnt -> WHILE ( bool_expr . ) stmnt\n",
+ " (1) bool_expr -> bool_expr . OR bool_expr\n",
+ " (10) bool_expr -> bool_expr . AND bool_expr\n",
+ "\n",
+ " ) shift and go to state 80\n",
+ " OR shift and go to state 71\n",
+ " AND shift and go to state 72\n",
+ "\n",
+ "\n",
+ "state 59\n",
+ "\n",
+ " (4) expr -> expr + expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ; reduce using rule 4 (expr -> expr + expr .)\n",
+ " + reduce using rule 4 (expr -> expr + expr .)\n",
+ " - reduce using rule 4 (expr -> expr + expr .)\n",
+ " ) reduce using rule 4 (expr -> expr + expr .)\n",
+ " , reduce using rule 4 (expr -> expr + expr .)\n",
+ " EQ reduce using rule 4 (expr -> expr + expr .)\n",
+ " NE reduce using rule 4 (expr -> expr + expr .)\n",
+ " LE reduce using rule 4 (expr -> expr + expr .)\n",
+ " GE reduce using rule 4 (expr -> expr + expr .)\n",
+ " < reduce using rule 4 (expr -> expr + expr .)\n",
+ " > reduce using rule 4 (expr -> expr + expr .)\n",
+ " OR reduce using rule 4 (expr -> expr + expr .)\n",
+ " AND reduce using rule 4 (expr -> expr + expr .)\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ " ! * [ reduce using rule 4 (expr -> expr + expr .) ]\n",
+ " ! / [ reduce using rule 4 (expr -> expr + expr .) ]\n",
+ " ! % [ reduce using rule 4 (expr -> expr + expr .) ]\n",
+ " ! + [ shift and go to state 41 ]\n",
+ " ! - [ shift and go to state 42 ]\n",
+ "\n",
+ "\n",
+ "state 60\n",
+ "\n",
+ " (13) expr -> expr - expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ; reduce using rule 13 (expr -> expr - expr .)\n",
+ " + reduce using rule 13 (expr -> expr - expr .)\n",
+ " - reduce using rule 13 (expr -> expr - expr .)\n",
+ " ) reduce using rule 13 (expr -> expr - expr .)\n",
+ " , reduce using rule 13 (expr -> expr - expr .)\n",
+ " EQ reduce using rule 13 (expr -> expr - expr .)\n",
+ " NE reduce using rule 13 (expr -> expr - expr .)\n",
+ " LE reduce using rule 13 (expr -> expr - expr .)\n",
+ " GE reduce using rule 13 (expr -> expr - expr .)\n",
+ " < reduce using rule 13 (expr -> expr - expr .)\n",
+ " > reduce using rule 13 (expr -> expr - expr .)\n",
+ " OR reduce using rule 13 (expr -> expr - expr .)\n",
+ " AND reduce using rule 13 (expr -> expr - expr .)\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ " ! * [ reduce using rule 13 (expr -> expr - expr .) ]\n",
+ " ! / [ reduce using rule 13 (expr -> expr - expr .) ]\n",
+ " ! % [ reduce using rule 13 (expr -> expr - expr .) ]\n",
+ " ! + [ shift and go to state 41 ]\n",
+ " ! - [ shift and go to state 42 ]\n",
+ "\n",
+ "\n",
+ "state 61\n",
+ "\n",
+ " (20) expr -> expr * expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ; reduce using rule 20 (expr -> expr * expr .)\n",
+ " + reduce using rule 20 (expr -> expr * expr .)\n",
+ " - reduce using rule 20 (expr -> expr * expr .)\n",
+ " * reduce using rule 20 (expr -> expr * expr .)\n",
+ " / reduce using rule 20 (expr -> expr * expr .)\n",
+ " % reduce using rule 20 (expr -> expr * expr .)\n",
+ " ) reduce using rule 20 (expr -> expr * expr .)\n",
+ " , reduce using rule 20 (expr -> expr * expr .)\n",
+ " EQ reduce using rule 20 (expr -> expr * expr .)\n",
+ " NE reduce using rule 20 (expr -> expr * expr .)\n",
+ " LE reduce using rule 20 (expr -> expr * expr .)\n",
+ " GE reduce using rule 20 (expr -> expr * expr .)\n",
+ " < reduce using rule 20 (expr -> expr * expr .)\n",
+ " > reduce using rule 20 (expr -> expr * expr .)\n",
+ " OR reduce using rule 20 (expr -> expr * expr .)\n",
+ " AND reduce using rule 20 (expr -> expr * expr .)\n",
+ "\n",
+ " ! + [ shift and go to state 41 ]\n",
+ " ! - [ shift and go to state 42 ]\n",
+ " ! * [ shift and go to state 43 ]\n",
+ " ! / [ shift and go to state 44 ]\n",
+ " ! % [ shift and go to state 45 ]\n",
+ "\n",
+ "\n",
+ "state 62\n",
+ "\n",
+ " (24) expr -> expr / expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ; reduce using rule 24 (expr -> expr / expr .)\n",
+ " + reduce using rule 24 (expr -> expr / expr .)\n",
+ " - reduce using rule 24 (expr -> expr / expr .)\n",
+ " * reduce using rule 24 (expr -> expr / expr .)\n",
+ " / reduce using rule 24 (expr -> expr / expr .)\n",
+ " % reduce using rule 24 (expr -> expr / expr .)\n",
+ " ) reduce using rule 24 (expr -> expr / expr .)\n",
+ " , reduce using rule 24 (expr -> expr / expr .)\n",
+ " EQ reduce using rule 24 (expr -> expr / expr .)\n",
+ " NE reduce using rule 24 (expr -> expr / expr .)\n",
+ " LE reduce using rule 24 (expr -> expr / expr .)\n",
+ " GE reduce using rule 24 (expr -> expr / expr .)\n",
+ " < reduce using rule 24 (expr -> expr / expr .)\n",
+ " > reduce using rule 24 (expr -> expr / expr .)\n",
+ " OR reduce using rule 24 (expr -> expr / expr .)\n",
+ " AND reduce using rule 24 (expr -> expr / expr .)\n",
+ "\n",
+ " ! + [ shift and go to state 41 ]\n",
+ " ! - [ shift and go to state 42 ]\n",
+ " ! * [ shift and go to state 43 ]\n",
+ " ! / [ shift and go to state 44 ]\n",
+ " ! % [ shift and go to state 45 ]\n",
+ "\n",
+ "\n",
+ "state 63\n",
+ "\n",
+ " (29) expr -> expr % expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ; reduce using rule 29 (expr -> expr % expr .)\n",
+ " + reduce using rule 29 (expr -> expr % expr .)\n",
+ " - reduce using rule 29 (expr -> expr % expr .)\n",
+ " * reduce using rule 29 (expr -> expr % expr .)\n",
+ " / reduce using rule 29 (expr -> expr % expr .)\n",
+ " % reduce using rule 29 (expr -> expr % expr .)\n",
+ " ) reduce using rule 29 (expr -> expr % expr .)\n",
+ " , reduce using rule 29 (expr -> expr % expr .)\n",
+ " EQ reduce using rule 29 (expr -> expr % expr .)\n",
+ " NE reduce using rule 29 (expr -> expr % expr .)\n",
+ " LE reduce using rule 29 (expr -> expr % expr .)\n",
+ " GE reduce using rule 29 (expr -> expr % expr .)\n",
+ " < reduce using rule 29 (expr -> expr % expr .)\n",
+ " > reduce using rule 29 (expr -> expr % expr .)\n",
+ " OR reduce using rule 29 (expr -> expr % expr .)\n",
+ " AND reduce using rule 29 (expr -> expr % expr .)\n",
+ "\n",
+ " ! + [ shift and go to state 41 ]\n",
+ " ! - [ shift and go to state 42 ]\n",
+ " ! * [ shift and go to state 43 ]\n",
+ " ! / [ shift and go to state 44 ]\n",
+ " ! % [ shift and go to state 45 ]\n",
+ "\n",
+ "\n",
+ "state 64\n",
+ "\n",
+ " (35) stmnt -> RETURN expr ; .\n",
+ "\n",
+ " IF reduce using rule 35 (stmnt -> RETURN expr ; .)\n",
+ " WHILE reduce using rule 35 (stmnt -> RETURN expr ; .)\n",
+ " { reduce using rule 35 (stmnt -> RETURN expr ; .)\n",
+ " ID reduce using rule 35 (stmnt -> RETURN expr ; .)\n",
+ " RETURN reduce using rule 35 (stmnt -> RETURN expr ; .)\n",
+ " ( reduce using rule 35 (stmnt -> RETURN expr ; .)\n",
+ " NUMBER reduce using rule 35 (stmnt -> RETURN expr ; .)\n",
+ " } reduce using rule 35 (stmnt -> RETURN expr ; .)\n",
+ " ELSE reduce using rule 35 (stmnt -> RETURN expr ; .)\n",
+ "\n",
+ "\n",
+ "state 65\n",
+ "\n",
+ " (32) stmnt -> ID = expr ; .\n",
+ "\n",
+ " IF reduce using rule 32 (stmnt -> ID = expr ; .)\n",
+ " WHILE reduce using rule 32 (stmnt -> ID = expr ; .)\n",
+ " { reduce using rule 32 (stmnt -> ID = expr ; .)\n",
+ " ID reduce using rule 32 (stmnt -> ID = expr ; .)\n",
+ " RETURN reduce using rule 32 (stmnt -> ID = expr ; .)\n",
+ " ( reduce using rule 32 (stmnt -> ID = expr ; .)\n",
+ " NUMBER reduce using rule 32 (stmnt -> ID = expr ; .)\n",
+ " } reduce using rule 32 (stmnt -> ID = expr ; .)\n",
+ " ELSE reduce using rule 32 (stmnt -> ID = expr ; .)\n",
+ "\n",
+ "\n",
+ "state 66\n",
+ "\n",
+ " (42) expr -> ID ( expr_list ) .\n",
+ "\n",
+ " ; reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " + reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " - reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " * reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " / reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " % reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " ) reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " , reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " EQ reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " NE reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " LE reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " GE reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " < reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " > reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " OR reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ " AND reduce using rule 42 (expr -> ID ( expr_list ) .)\n",
+ "\n",
+ "\n",
+ "state 67\n",
+ "\n",
+ " (19) expr_list -> expr , . ne_expr_list\n",
+ " (25) ne_expr_list -> . expr\n",
+ " (30) ne_expr_list -> . expr , ne_expr_list\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 81\n",
+ " ne_expr_list shift and go to state 82\n",
+ "\n",
+ "state 68\n",
+ "\n",
+ " (23) bool_expr -> ( bool_expr . )\n",
+ " (1) bool_expr -> bool_expr . OR bool_expr\n",
+ " (10) bool_expr -> bool_expr . AND bool_expr\n",
+ "\n",
+ " ) shift and go to state 83\n",
+ " OR shift and go to state 71\n",
+ " AND shift and go to state 72\n",
+ "\n",
+ "\n",
+ "state 69\n",
+ "\n",
+ " (34) expr -> ( expr . )\n",
+ " (28) bool_expr -> expr . EQ expr\n",
+ " (33) bool_expr -> expr . NE expr\n",
+ " (36) bool_expr -> expr . LE expr\n",
+ " (39) bool_expr -> expr . GE expr\n",
+ " (41) bool_expr -> expr . < expr\n",
+ " (43) bool_expr -> expr . > expr\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) shift and go to state 52\n",
+ " EQ shift and go to state 74\n",
+ " NE shift and go to state 75\n",
+ " LE shift and go to state 76\n",
+ " GE shift and go to state 77\n",
+ " < shift and go to state 78\n",
+ " > shift and go to state 79\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 70\n",
+ "\n",
+ " (8) stmnt -> IF ( bool_expr ) . stmnt\n",
+ " (16) stmnt -> IF ( bool_expr ) . stmnt ELSE stmnt\n",
+ " (8) stmnt -> . IF ( bool_expr ) stmnt\n",
+ " (16) stmnt -> . IF ( bool_expr ) stmnt ELSE stmnt\n",
+ " (22) stmnt -> . WHILE ( bool_expr ) stmnt\n",
+ " (27) stmnt -> . { stmnt_list }\n",
+ " (32) stmnt -> . ID = expr ;\n",
+ " (35) stmnt -> . RETURN expr ;\n",
+ " (38) stmnt -> . expr ;\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " IF shift and go to state 24\n",
+ " WHILE shift and go to state 25\n",
+ " { shift and go to state 21\n",
+ " ID shift and go to state 19\n",
+ " RETURN shift and go to state 27\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ "\n",
+ " stmnt shift and go to state 84\n",
+ " expr shift and go to state 26\n",
+ "\n",
+ "state 71\n",
+ "\n",
+ " (1) bool_expr -> bool_expr OR . bool_expr\n",
+ " (1) bool_expr -> . bool_expr OR bool_expr\n",
+ " (10) bool_expr -> . bool_expr AND bool_expr\n",
+ " (18) bool_expr -> . ! bool_expr\n",
+ " (23) bool_expr -> . ( bool_expr )\n",
+ " (28) bool_expr -> . expr EQ expr\n",
+ " (33) bool_expr -> . expr NE expr\n",
+ " (36) bool_expr -> . expr LE expr\n",
+ " (39) bool_expr -> . expr GE expr\n",
+ " (41) bool_expr -> . expr < expr\n",
+ " (43) bool_expr -> . expr > expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ! shift and go to state 56\n",
+ " ( shift and go to state 54\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " bool_expr shift and go to state 85\n",
+ " expr shift and go to state 57\n",
+ "\n",
+ "state 72\n",
+ "\n",
+ " (10) bool_expr -> bool_expr AND . bool_expr\n",
+ " (1) bool_expr -> . bool_expr OR bool_expr\n",
+ " (10) bool_expr -> . bool_expr AND bool_expr\n",
+ " (18) bool_expr -> . ! bool_expr\n",
+ " (23) bool_expr -> . ( bool_expr )\n",
+ " (28) bool_expr -> . expr EQ expr\n",
+ " (33) bool_expr -> . expr NE expr\n",
+ " (36) bool_expr -> . expr LE expr\n",
+ " (39) bool_expr -> . expr GE expr\n",
+ " (41) bool_expr -> . expr < expr\n",
+ " (43) bool_expr -> . expr > expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ! shift and go to state 56\n",
+ " ( shift and go to state 54\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " bool_expr shift and go to state 86\n",
+ " expr shift and go to state 57\n",
+ "\n",
+ "state 73\n",
+ "\n",
+ " (18) bool_expr -> ! bool_expr .\n",
+ " (1) bool_expr -> bool_expr . OR bool_expr\n",
+ " (10) bool_expr -> bool_expr . AND bool_expr\n",
+ "\n",
+ " ) reduce using rule 18 (bool_expr -> ! bool_expr .)\n",
+ " OR reduce using rule 18 (bool_expr -> ! bool_expr .)\n",
+ " AND reduce using rule 18 (bool_expr -> ! bool_expr .)\n",
+ "\n",
+ " ! OR [ shift and go to state 71 ]\n",
+ " ! AND [ shift and go to state 72 ]\n",
+ "\n",
+ "\n",
+ "state 74\n",
+ "\n",
+ " (28) bool_expr -> expr EQ . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 87\n",
+ "\n",
+ "state 75\n",
+ "\n",
+ " (33) bool_expr -> expr NE . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 88\n",
+ "\n",
+ "state 76\n",
+ "\n",
+ " (36) bool_expr -> expr LE . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 89\n",
+ "\n",
+ "state 77\n",
+ "\n",
+ " (39) bool_expr -> expr GE . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 90\n",
+ "\n",
+ "state 78\n",
+ "\n",
+ " (41) bool_expr -> expr < . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 91\n",
+ "\n",
+ "state 79\n",
+ "\n",
+ " (43) bool_expr -> expr > . expr\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 92\n",
+ "\n",
+ "state 80\n",
+ "\n",
+ " (22) stmnt -> WHILE ( bool_expr ) . stmnt\n",
+ " (8) stmnt -> . IF ( bool_expr ) stmnt\n",
+ " (16) stmnt -> . IF ( bool_expr ) stmnt ELSE stmnt\n",
+ " (22) stmnt -> . WHILE ( bool_expr ) stmnt\n",
+ " (27) stmnt -> . { stmnt_list }\n",
+ " (32) stmnt -> . ID = expr ;\n",
+ " (35) stmnt -> . RETURN expr ;\n",
+ " (38) stmnt -> . expr ;\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " IF shift and go to state 24\n",
+ " WHILE shift and go to state 25\n",
+ " { shift and go to state 21\n",
+ " ID shift and go to state 19\n",
+ " RETURN shift and go to state 27\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ "\n",
+ " stmnt shift and go to state 93\n",
+ " expr shift and go to state 26\n",
+ "\n",
+ "state 81\n",
+ "\n",
+ " (25) ne_expr_list -> expr .\n",
+ " (30) ne_expr_list -> expr . , ne_expr_list\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) reduce using rule 25 (ne_expr_list -> expr .)\n",
+ " , shift and go to state 94\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 82\n",
+ "\n",
+ " (19) expr_list -> expr , ne_expr_list .\n",
+ "\n",
+ " ) reduce using rule 19 (expr_list -> expr , ne_expr_list .)\n",
+ "\n",
+ "\n",
+ "state 83\n",
+ "\n",
+ " (23) bool_expr -> ( bool_expr ) .\n",
+ "\n",
+ " ) reduce using rule 23 (bool_expr -> ( bool_expr ) .)\n",
+ " OR reduce using rule 23 (bool_expr -> ( bool_expr ) .)\n",
+ " AND reduce using rule 23 (bool_expr -> ( bool_expr ) .)\n",
+ "\n",
+ "\n",
+ "state 84\n",
+ "\n",
+ " (8) stmnt -> IF ( bool_expr ) stmnt .\n",
+ " (16) stmnt -> IF ( bool_expr ) stmnt . ELSE stmnt\n",
+ "\n",
+ " IF reduce using rule 8 (stmnt -> IF ( bool_expr ) stmnt .)\n",
+ " WHILE reduce using rule 8 (stmnt -> IF ( bool_expr ) stmnt .)\n",
+ " { reduce using rule 8 (stmnt -> IF ( bool_expr ) stmnt .)\n",
+ " ID reduce using rule 8 (stmnt -> IF ( bool_expr ) stmnt .)\n",
+ " RETURN reduce using rule 8 (stmnt -> IF ( bool_expr ) stmnt .)\n",
+ " ( reduce using rule 8 (stmnt -> IF ( bool_expr ) stmnt .)\n",
+ " NUMBER reduce using rule 8 (stmnt -> IF ( bool_expr ) stmnt .)\n",
+ " } reduce using rule 8 (stmnt -> IF ( bool_expr ) stmnt .)\n",
+ " ELSE shift and go to state 95\n",
+ "\n",
+ " ! ELSE [ reduce using rule 8 (stmnt -> IF ( bool_expr ) stmnt .) ]\n",
+ "\n",
+ "\n",
+ "state 85\n",
+ "\n",
+ " (1) bool_expr -> bool_expr OR bool_expr .\n",
+ " (1) bool_expr -> bool_expr . OR bool_expr\n",
+ " (10) bool_expr -> bool_expr . AND bool_expr\n",
+ "\n",
+ " ) reduce using rule 1 (bool_expr -> bool_expr OR bool_expr .)\n",
+ " OR reduce using rule 1 (bool_expr -> bool_expr OR bool_expr .)\n",
+ " AND shift and go to state 72\n",
+ "\n",
+ " ! AND [ reduce using rule 1 (bool_expr -> bool_expr OR bool_expr .) ]\n",
+ " ! OR [ shift and go to state 71 ]\n",
+ "\n",
+ "\n",
+ "state 86\n",
+ "\n",
+ " (10) bool_expr -> bool_expr AND bool_expr .\n",
+ " (1) bool_expr -> bool_expr . OR bool_expr\n",
+ " (10) bool_expr -> bool_expr . AND bool_expr\n",
+ "\n",
+ " ) reduce using rule 10 (bool_expr -> bool_expr AND bool_expr .)\n",
+ " OR reduce using rule 10 (bool_expr -> bool_expr AND bool_expr .)\n",
+ " AND reduce using rule 10 (bool_expr -> bool_expr AND bool_expr .)\n",
+ "\n",
+ " ! OR [ shift and go to state 71 ]\n",
+ " ! AND [ shift and go to state 72 ]\n",
+ "\n",
+ "\n",
+ "state 87\n",
+ "\n",
+ " (28) bool_expr -> expr EQ expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) reduce using rule 28 (bool_expr -> expr EQ expr .)\n",
+ " OR reduce using rule 28 (bool_expr -> expr EQ expr .)\n",
+ " AND reduce using rule 28 (bool_expr -> expr EQ expr .)\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 88\n",
+ "\n",
+ " (33) bool_expr -> expr NE expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) reduce using rule 33 (bool_expr -> expr NE expr .)\n",
+ " OR reduce using rule 33 (bool_expr -> expr NE expr .)\n",
+ " AND reduce using rule 33 (bool_expr -> expr NE expr .)\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 89\n",
+ "\n",
+ " (36) bool_expr -> expr LE expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) reduce using rule 36 (bool_expr -> expr LE expr .)\n",
+ " OR reduce using rule 36 (bool_expr -> expr LE expr .)\n",
+ " AND reduce using rule 36 (bool_expr -> expr LE expr .)\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 90\n",
+ "\n",
+ " (39) bool_expr -> expr GE expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) reduce using rule 39 (bool_expr -> expr GE expr .)\n",
+ " OR reduce using rule 39 (bool_expr -> expr GE expr .)\n",
+ " AND reduce using rule 39 (bool_expr -> expr GE expr .)\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 91\n",
+ "\n",
+ " (41) bool_expr -> expr < expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) reduce using rule 41 (bool_expr -> expr < expr .)\n",
+ " OR reduce using rule 41 (bool_expr -> expr < expr .)\n",
+ " AND reduce using rule 41 (bool_expr -> expr < expr .)\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 92\n",
+ "\n",
+ " (43) bool_expr -> expr > expr .\n",
+ " (4) expr -> expr . + expr\n",
+ " (13) expr -> expr . - expr\n",
+ " (20) expr -> expr . * expr\n",
+ " (24) expr -> expr . / expr\n",
+ " (29) expr -> expr . % expr\n",
+ "\n",
+ " ) reduce using rule 43 (bool_expr -> expr > expr .)\n",
+ " OR reduce using rule 43 (bool_expr -> expr > expr .)\n",
+ " AND reduce using rule 43 (bool_expr -> expr > expr .)\n",
+ " + shift and go to state 41\n",
+ " - shift and go to state 42\n",
+ " * shift and go to state 43\n",
+ " / shift and go to state 44\n",
+ " % shift and go to state 45\n",
+ "\n",
+ "\n",
+ "state 93\n",
+ "\n",
+ " (22) stmnt -> WHILE ( bool_expr ) stmnt .\n",
+ "\n",
+ " IF reduce using rule 22 (stmnt -> WHILE ( bool_expr ) stmnt .)\n",
+ " WHILE reduce using rule 22 (stmnt -> WHILE ( bool_expr ) stmnt .)\n",
+ " { reduce using rule 22 (stmnt -> WHILE ( bool_expr ) stmnt .)\n",
+ " ID reduce using rule 22 (stmnt -> WHILE ( bool_expr ) stmnt .)\n",
+ " RETURN reduce using rule 22 (stmnt -> WHILE ( bool_expr ) stmnt .)\n",
+ " ( reduce using rule 22 (stmnt -> WHILE ( bool_expr ) stmnt .)\n",
+ " NUMBER reduce using rule 22 (stmnt -> WHILE ( bool_expr ) stmnt .)\n",
+ " } reduce using rule 22 (stmnt -> WHILE ( bool_expr ) stmnt .)\n",
+ " ELSE reduce using rule 22 (stmnt -> WHILE ( bool_expr ) stmnt .)\n",
+ "\n",
+ "\n",
+ "state 94\n",
+ "\n",
+ " (30) ne_expr_list -> expr , . ne_expr_list\n",
+ " (25) ne_expr_list -> . expr\n",
+ " (30) ne_expr_list -> . expr , ne_expr_list\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ " ID shift and go to state 34\n",
+ "\n",
+ " expr shift and go to state 81\n",
+ " ne_expr_list shift and go to state 96\n",
+ "\n",
+ "state 95\n",
+ "\n",
+ " (16) stmnt -> IF ( bool_expr ) stmnt ELSE . stmnt\n",
+ " (8) stmnt -> . IF ( bool_expr ) stmnt\n",
+ " (16) stmnt -> . IF ( bool_expr ) stmnt ELSE stmnt\n",
+ " (22) stmnt -> . WHILE ( bool_expr ) stmnt\n",
+ " (27) stmnt -> . { stmnt_list }\n",
+ " (32) stmnt -> . ID = expr ;\n",
+ " (35) stmnt -> . RETURN expr ;\n",
+ " (38) stmnt -> . expr ;\n",
+ " (4) expr -> . expr + expr\n",
+ " (13) expr -> . expr - expr\n",
+ " (20) expr -> . expr * expr\n",
+ " (24) expr -> . expr / expr\n",
+ " (29) expr -> . expr % expr\n",
+ " (34) expr -> . ( expr )\n",
+ " (37) expr -> . NUMBER\n",
+ " (40) expr -> . ID\n",
+ " (42) expr -> . ID ( expr_list )\n",
+ "\n",
+ " IF shift and go to state 24\n",
+ " WHILE shift and go to state 25\n",
+ " { shift and go to state 21\n",
+ " ID shift and go to state 19\n",
+ " RETURN shift and go to state 27\n",
+ " ( shift and go to state 20\n",
+ " NUMBER shift and go to state 28\n",
+ "\n",
+ " stmnt shift and go to state 97\n",
+ " expr shift and go to state 26\n",
+ "\n",
+ "state 96\n",
+ "\n",
+ " (30) ne_expr_list -> expr , ne_expr_list .\n",
+ "\n",
+ " ) reduce using rule 30 (ne_expr_list -> expr , ne_expr_list .)\n",
+ "\n",
+ "\n",
+ "state 97\n",
+ "\n",
+ " (16) stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .\n",
+ "\n",
+ " IF reduce using rule 16 (stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .)\n",
+ " WHILE reduce using rule 16 (stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .)\n",
+ " { reduce using rule 16 (stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .)\n",
+ " ID reduce using rule 16 (stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .)\n",
+ " RETURN reduce using rule 16 (stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .)\n",
+ " ( reduce using rule 16 (stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .)\n",
+ " NUMBER reduce using rule 16 (stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .)\n",
+ " } reduce using rule 16 (stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .)\n",
+ " ELSE reduce using rule 16 (stmnt -> IF ( bool_expr ) stmnt ELSE stmnt .)\n",
+ "\n"
+ ]
+ }
+ ],
"source": [
"!cat parser.out"
]
@@ -766,7 +2698,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
@@ -784,7 +2716,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
@@ -799,18 +2731,655 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 34,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ " 1\tint sum(int n) {\n",
+ " 2\t int s;\n",
+ " 3\t s = 0;\n",
+ " 4\t while (n != 0) {\n",
+ " 5\t s = s + n;\n",
+ " 6\t n = n - 1;\n",
+ " 7\t }\n",
+ " 8\t return s;\n",
+ " 9\t}\n",
+ " 10\t\n",
+ " 11\tint main() {\n",
+ " 12\t int n;\n",
+ " 13\t n = 6 * 6;\n",
+ " 14\t println(sum(n));\n",
+ " 15\t}\n"
+ ]
+ }
+ ],
"source": [
"!cat -n Examples/MySum.c"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 35,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "('program', ('fct', 'sum', ('.', 'n'), ('.', 's'), ('.', ('=', 's', ('Number', '0')), ('while', ('!=', 'n', ('Number', '0')), ('.', ('=', 's', ('+', 's', 'n')), ('=', 'n', ('-', 'n', ('Number', '1'))))), ('return', 's'))), ('fct', 'main', ('.',), ('.', 'n'), ('.', ('=', 'n', ('*', ('Number', '6'), ('Number', '6'))), ('call', 'println', ('call', 'sum', 'n')))))\n"
+ ]
+ },
+ {
+ "data": {
+ "image/svg+xml": [
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "execution_count": 35,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"parse('Examples/MySum.c')"
]
@@ -824,7 +3393,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 36,
"metadata": {},
"outputs": [],
"source": [
@@ -852,7 +3421,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
@@ -905,9 +3474,24 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 38,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "([' iload 0',\n",
+ " ' iload 1',\n",
+ " ' iadd',\n",
+ " ' invokestatic Sum/sum(I)I'],\n",
+ " 2)"
+ ]
+ },
+ "execution_count": 38,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"expr = ('call', 'sum', ('+', 'x', 'y'))\n",
"st = { 'x': 0, 'y': 1}\n",
@@ -924,7 +3508,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
@@ -956,7 +3540,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 40,
"metadata": {},
"outputs": [],
"source": [
@@ -1007,9 +3591,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 41,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "([' iload 0',\n",
+ " ' ldc 0',\n",
+ " ' if_icmpeq l1',\n",
+ " ' bipush 0',\n",
+ " ' goto l2',\n",
+ " ' l1:',\n",
+ " ' bipush 1',\n",
+ " ' l2:'],\n",
+ " 2)"
+ ]
+ },
+ "execution_count": 41,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"expr = ('==', 'x', ('Number', '0'))\n",
"st = { 'x': 0, 'y': 1}\n",
@@ -1036,7 +3639,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
@@ -1094,9 +3697,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 43,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "([' iload 0',\n",
+ " ' iload 1',\n",
+ " ' if_icmpeq l3',\n",
+ " ' bipush 0',\n",
+ " ' goto l4',\n",
+ " ' l3:',\n",
+ " ' bipush 1',\n",
+ " ' l4:',\n",
+ " ' ifeq l5',\n",
+ " ' iload 1',\n",
+ " ' istore 0',\n",
+ " ' l5:'],\n",
+ " 2)"
+ ]
+ },
+ "execution_count": 43,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"stmnt = ('if', ('==', 'x', 'y'), ('=', 'x', 'y'))\n",
"compile_stmnt(stmnt, st, 'Sum')"
@@ -1104,9 +3730,36 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 44,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "([' iload 0',\n",
+ " ' iload 1',\n",
+ " ' if_icmplt l6',\n",
+ " ' bipush 0',\n",
+ " ' goto l7',\n",
+ " ' l6:',\n",
+ " ' bipush 1',\n",
+ " ' l7:',\n",
+ " ' ifeq l8',\n",
+ " ' iload 1',\n",
+ " ' istore 0',\n",
+ " ' goto l9',\n",
+ " ' l8:',\n",
+ " ' iload 0',\n",
+ " ' istore 1',\n",
+ " ' l9:'],\n",
+ " 2)"
+ ]
+ },
+ "execution_count": 44,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"stmnt = ('if-else', ('<', 'x', 'y'), ('=', 'x', 'y'), ('=', 'y', 'x'))\n",
"compile_stmnt(stmnt, st, 'Sum')"
@@ -1114,9 +3767,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 45,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "([' l12:',\n",
+ " ' iload 0',\n",
+ " ' iload 1',\n",
+ " ' if_icmplt l10',\n",
+ " ' bipush 0',\n",
+ " ' goto l11',\n",
+ " ' l10:',\n",
+ " ' bipush 1',\n",
+ " ' l11:',\n",
+ " ' ifeq l13',\n",
+ " ' iload 1',\n",
+ " ' istore 0',\n",
+ " ' goto l12',\n",
+ " ' l13:'],\n",
+ " 2)"
+ ]
+ },
+ "execution_count": 45,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"stmnt = ('while', ('<', 'x', 'y'), ('=', 'x', 'y'))\n",
"compile_stmnt(stmnt, st, 'Sum')"
@@ -1124,9 +3802,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 46,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "([' iload 1',\n",
+ " ' istore 0',\n",
+ " ' ldc 1',\n",
+ " ' istore 0',\n",
+ " ' iload 0',\n",
+ " ' istore 1'],\n",
+ " 1)"
+ ]
+ },
+ "execution_count": 46,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"stmnt = ('.', ('=', 'x', 'y'), ('.', ('=', 'x', ('Number', '1')), ('=', 'y', 'x')))\n",
"compile_stmnt(stmnt, st, 'Sum')"
@@ -1134,7 +3829,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 47,
"metadata": {},
"outputs": [],
"source": [
@@ -1173,9 +3868,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 48,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(['.method public static sum(I)I',\n",
+ " '.limit locals 3',\n",
+ " '.limit stack 1',\n",
+ " ' iload 0',\n",
+ " ' ireturn',\n",
+ " '.end method'],\n",
+ " 1)"
+ ]
+ },
+ "execution_count": 48,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"f = ('fct', 'sum', ('.', 'x'), ('.', 'y', 'z'), ('.', ('return', 'x')))\n",
"compile_fct(f, 'Sum')"
@@ -1183,7 +3895,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
@@ -1192,9 +3904,19 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 50,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "~/Dropbox/Kurse/Formal-Languages/Ply/Examples\n",
+ "Test.c\n",
+ "abc/xyz.c\n"
+ ]
+ }
+ ],
"source": [
"file = \"~/Dropbox/Kurse/Formal-Languages/Ply/Examples/Test.c\"\n",
"print(os.path.dirname(file))\n",
@@ -1212,7 +3934,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 51,
"metadata": {},
"outputs": [],
"source": [
@@ -1244,9 +3966,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 52,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "/Users/stroetmann/Library/Mobile Documents/com~apple~CloudDocs/Box/Kurse/Formal-Languages/Python/Chapter-12/Examples\n"
+ ]
+ }
+ ],
"source": [
"%cd Examples"
]
@@ -1260,16 +3990,50 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 53,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "/*** This function checks whether n is a prime number.\n",
+ " It returns the number n, if n is prime. Otherwise,\n",
+ " 0 is returned.\n",
+ " ***/\n",
+ "int is_prime(int n) {\n",
+ " int f;\n",
+ " f = 2;\n",
+ " while (f < n) {\n",
+ " if (n % f == 0)\n",
+ " return 0;\n",
+ " f = f + 1;\n",
+ " }\n",
+ " return n;\n",
+ "}\n",
+ "// This function computes all primes less than 100.\n",
+ "int main() {\n",
+ " int n;\n",
+ " int p;\n",
+ " n = 2; \n",
+ " while (n <= 100) {\n",
+ " p = is_prime(n);\n",
+ " if (p > 0) {\n",
+ " println(p);\n",
+ " }\n",
+ " n = n + 1;\n",
+ " }\n",
+ "}\n"
+ ]
+ }
+ ],
"source": [
"!cat Primes.c"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 54,
"metadata": {},
"outputs": [],
"source": [
@@ -1278,18 +4042,129 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 55,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "total 48\n",
+ "-rw------- 1 stroetmann staff 362 Feb 11 2024 Fakultaet.c\n",
+ "-rw------- 1 stroetmann staff 183 Feb 11 2024 MySum.c\n",
+ "-rw------- 1 stroetmann staff 518 Feb 11 2024 Primes.c\n",
+ "-rw-r--r--@ 1 stroetmann staff 1440 Nov 5 11:08 Primes.jas\n",
+ "-rw------- 1 stroetmann staff 464 Feb 11 2024 PrimesFor.c\n",
+ "-rw------- 1 stroetmann staff 200 Feb 11 2024 Ternary.c\n"
+ ]
+ }
+ ],
"source": [
"!ls -l"
]
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 56,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ ".class public Primes\n",
+ ".super java/lang/Object\n",
+ "\n",
+ ".method public ()V\n",
+ " aload 0\n",
+ " invokenonvirtual java/lang/Object/()V\n",
+ " return\n",
+ ".end method\n",
+ "\n",
+ ".method public static is_prime(I)I\n",
+ ".limit locals 2\n",
+ ".limit stack 2\n",
+ " ldc 2\n",
+ " istore 1\n",
+ " l6:\n",
+ " iload 1\n",
+ " iload 0\n",
+ " if_icmplt l1\n",
+ " bipush 0\n",
+ " goto l2\n",
+ " l1:\n",
+ " bipush 1\n",
+ " l2:\n",
+ " ifeq l7\n",
+ " iload 0\n",
+ " iload 1\n",
+ " irem\n",
+ " ldc 0\n",
+ " if_icmpeq l3\n",
+ " bipush 0\n",
+ " goto l4\n",
+ " l3:\n",
+ " bipush 1\n",
+ " l4:\n",
+ " ifeq l5\n",
+ " ldc 0\n",
+ " ireturn\n",
+ " l5:\n",
+ " iload 1\n",
+ " ldc 1\n",
+ " iadd\n",
+ " istore 1\n",
+ " goto l6\n",
+ " l7:\n",
+ " iload 0\n",
+ " ireturn\n",
+ ".end method\n",
+ "\n",
+ "\n",
+ ".method public static main([Ljava/lang/String;)V\n",
+ ".limit locals 2\n",
+ ".limit stack 2\n",
+ " ldc 2\n",
+ " istore 0\n",
+ " l6:\n",
+ " iload 0\n",
+ " ldc 100\n",
+ " if_icmple l1\n",
+ " bipush 0\n",
+ " goto l2\n",
+ " l1:\n",
+ " bipush 1\n",
+ " l2:\n",
+ " ifeq l7\n",
+ " iload 0\n",
+ " invokestatic Primes/is_prime(I)I\n",
+ " istore 1\n",
+ " iload 1\n",
+ " ldc 0\n",
+ " if_icmpgt l3\n",
+ " bipush 0\n",
+ " goto l4\n",
+ " l3:\n",
+ " bipush 1\n",
+ " l4:\n",
+ " ifeq l5\n",
+ " getstatic java/lang/System/out Ljava/io/PrintStream;\n",
+ " iload 1\n",
+ " invokevirtual java/io/PrintStream/println(I)V\n",
+ " l5:\n",
+ " iload 0\n",
+ " ldc 1\n",
+ " iadd\n",
+ " istore 0\n",
+ " goto l6\n",
+ " l7:\n",
+ " return\n",
+ ".end method\n",
+ "\n",
+ "\n"
+ ]
+ }
+ ],
"source": [
"!cat Primes.jas"
]
@@ -1304,9 +4179,17 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 57,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Generated: Primes.class\n"
+ ]
+ }
+ ],
"source": [
"!jasmin Primes.jas"
]
@@ -1320,9 +4203,41 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 58,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "2\n",
+ "3\n",
+ "5\n",
+ "7\n",
+ "11\n",
+ "13\n",
+ "17\n",
+ "19\n",
+ "23\n",
+ "29\n",
+ "31\n",
+ "37\n",
+ "41\n",
+ "43\n",
+ "47\n",
+ "53\n",
+ "59\n",
+ "61\n",
+ "67\n",
+ "71\n",
+ "73\n",
+ "79\n",
+ "83\n",
+ "89\n",
+ "97\n"
+ ]
+ }
+ ],
"source": [
"!java Primes"
]
@@ -1378,7 +4293,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.12.6"
+ "version": "3.12.7"
},
"varInspector": {
"cols": {