diff --git a/Python/Chapter-04-05/02-Test-NFA-2-DFA.ipynb b/Python/Chapter-04-05/02-Test-NFA-2-DFA.ipynb index 861e86e..b262cfc 100644 --- a/Python/Chapter-04-05/02-Test-NFA-2-DFA.ipynb +++ b/Python/Chapter-04-05/02-Test-NFA-2-DFA.ipynb @@ -197,7 +197,7 @@ "\n", "\n", "\n", - "\n", + "\n", "q1\n", "\n", "q1\n", @@ -210,7 +210,7 @@ "𝜀\n", "\n", "\n", - "\n", + "\n", "q2\n", "\n", "q2\n", @@ -229,7 +229,7 @@ "q5\n", "\n", "\n", - "\n", + "\n", "q7\n", "\n", "\n", @@ -242,12 +242,38 @@ "\n", "𝜀\n", "\n", - "\n", + "\n", "\n", + "q3\n", + "\n", + "q3\n", + "\n", + "\n", + "\n", + "q3->q5\n", + "\n", + "\n", + "a\n", + "\n", + "\n", + "\n", + "q4\n", + "\n", + "q4\n", + "\n", + "\n", + "\n", "q6\n", "\n", "q6\n", "\n", + "\n", + "\n", + "q4->q6\n", + "\n", + "\n", + "b\n", + "\n", "\n", "\n", "q6->q7\n", @@ -262,51 +288,25 @@ "\n", "𝜀\n", "\n", - "\n", - "\n", - "q4\n", - "\n", - "q4\n", - "\n", - "\n", - "\n", - "q4->q6\n", - "\n", - "\n", - "b\n", - "\n", - "\n", - "\n", - "q3\n", - "\n", - "q3\n", - "\n", "\n", - "\n", + "\n", "q1->q3\n", "\n", "\n", "b\n", "\n", "\n", - "\n", + "\n", "q2->q4\n", "\n", "\n", "a\n", "\n", - "\n", - "\n", - "q3->q5\n", - "\n", - "\n", - "a\n", - "\n", "\n", "\n" ], "text/plain": [ - "" + "" ] }, "execution_count": 9, @@ -323,7 +323,7 @@ "metadata": {}, "source": [ "This recognizes the same language as the language described by\n", - "$$ (a \\cdot b + b \\cdot a) \\cdot ((a \\cdot b + b \\cdot a)\\cdot(a \\cdot b + b \\cdot a))^* $$\n", + "$$ (a \\cdot b + b \\cdot a) \\cdot (a \\cdot b + b \\cdot a)^* $$\n", "Let us convert it into a deterministic Fsm: " ] }, @@ -623,7 +623,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.13.0" + "version": "3.12.7" }, "varInspector": { "cols": { diff --git a/Python/Chapter-12/Compiler.ipynb b/Python/Chapter-12/Compiler.ipynb index 1940086..1400b35 100644 --- a/Python/Chapter-12/Compiler.ipynb +++ b/Python/Chapter-12/Compiler.ipynb @@ -47,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "metadata": {}, "outputs": [], "source": [ @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 44, "metadata": {}, "outputs": [], "source": [ @@ -74,7 +74,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 45, "metadata": {}, "outputs": [], "source": [ @@ -90,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 46, "metadata": {}, "outputs": [], "source": [ @@ -120,7 +120,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "metadata": {}, "outputs": [], "source": [ @@ -139,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 48, "metadata": {}, "outputs": [], "source": [ @@ -160,7 +160,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 49, "metadata": {}, "outputs": [], "source": [ @@ -179,7 +179,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 50, "metadata": {}, "outputs": [], "source": [ @@ -195,7 +195,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 51, "metadata": {}, "outputs": [], "source": [ @@ -211,7 +211,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 52, "metadata": {}, "outputs": [], "source": [ @@ -230,14 +230,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 53, "metadata": {}, "outputs": [], "source": [ "def find_column(token):\n", " program = token.lexer.lexdata # the complete string given to the scanner\n", - " line_start = program.rfind('\\n', 0, token.lexpos) + 1\n", - " return (token.lexpos - line_start) + 1" + " line_start = program.rfind('\\n', 0, token.lexpos) \n", + " return token.lexpos - line_start" ] }, { @@ -249,7 +249,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 54, "metadata": {}, "outputs": [], "source": [ @@ -268,7 +268,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 55, "metadata": {}, "outputs": [], "source": [ @@ -277,7 +277,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 56, "metadata": {}, "outputs": [], "source": [ @@ -286,7 +286,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 57, "metadata": {}, "outputs": [], "source": [ @@ -301,18 +301,124 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 58, + "metadata": {}, + "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" + ] + } + ], "source": [ "!cat Examples/MySum.c" ] }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 59, + "metadata": {}, + "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)" @@ -402,7 +508,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 60, "metadata": {}, "outputs": [], "source": [ @@ -418,7 +524,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": {}, "outputs": [], "source": [ @@ -458,7 +564,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 62, "metadata": {}, "outputs": [], "source": [ @@ -476,7 +582,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 63, "metadata": {}, "outputs": [], "source": [ @@ -491,7 +597,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 64, "metadata": {}, "outputs": [], "source": [ @@ -502,7 +608,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 65, "metadata": {}, "outputs": [], "source": [ @@ -529,7 +635,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 66, "metadata": {}, "outputs": [], "source": [ @@ -544,7 +650,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 67, "metadata": {}, "outputs": [], "source": [ @@ -570,7 +676,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 68, "metadata": {}, "outputs": [], "source": [ @@ -605,7 +711,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 69, "metadata": {}, "outputs": [], "source": [ @@ -652,7 +758,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 70, "metadata": {}, "outputs": [], "source": [ @@ -695,7 +801,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 71, "metadata": {}, "outputs": [], "source": [ @@ -722,7 +828,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 72, "metadata": {}, "outputs": [], "source": [ @@ -743,9 +849,17 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Generating LALR tables\n" + ] + } + ], "source": [ "parser = yacc.yacc(write_tables=False, debug=True);" ] @@ -761,9 +875,1849 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 74, + "metadata": {}, + "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" ] @@ -777,7 +2731,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 75, "metadata": {}, "outputs": [], "source": [ @@ -795,7 +2749,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 76, "metadata": {}, "outputs": [], "source": [ @@ -810,18 +2764,655 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 77, + "metadata": {}, + "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, - "metadata": {}, - "outputs": [], + "execution_count": 78, + "metadata": {}, + "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", + "\n", + "Abstract Syntax Tree\n", + "\n", + "\n", + "\n", + "0\n", + "\n", + "program\n", + "\n", + "\n", + "\n", + "1\n", + "\n", + "fct\n", + "\n", + "\n", + "\n", + "0->1\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "31\n", + "\n", + "fct\n", + "\n", + "\n", + "\n", + "0->31\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "2\n", + "\n", + "sum\n", + "\n", + "\n", + "\n", + "1->2\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "3\n", + "\n", + ".\n", + "\n", + "\n", + "\n", + "1->3\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "5\n", + "\n", + ".\n", + "\n", + "\n", + "\n", + "1->5\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "7\n", + "\n", + ".\n", + "\n", + "\n", + "\n", + "1->7\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "4\n", + "\n", + "n\n", + "\n", + "\n", + "\n", + "3->4\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "6\n", + "\n", + "s\n", + "\n", + "\n", + "\n", + "5->6\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "8\n", + "\n", + "=\n", + "\n", + "\n", + "\n", + "7->8\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "12\n", + "\n", + "while\n", + "\n", + "\n", + "\n", + "7->12\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "29\n", + "\n", + "return\n", + "\n", + "\n", + "\n", + "7->29\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "9\n", + "\n", + "s\n", + "\n", + "\n", + "\n", + "8->9\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "10\n", + "\n", + "Number\n", + "\n", + "\n", + "\n", + "8->10\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "11\n", + "\n", + "0\n", + "\n", + "\n", + "\n", + "10->11\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "13\n", + "\n", + "!=\n", + "\n", + "\n", + "\n", + "12->13\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "17\n", + "\n", + ".\n", + "\n", + "\n", + "\n", + "12->17\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "14\n", + "\n", + "n\n", + "\n", + "\n", + "\n", + "13->14\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "15\n", + "\n", + "Number\n", + "\n", + "\n", + "\n", + "13->15\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "16\n", + "\n", + "0\n", + "\n", + "\n", + "\n", + "15->16\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "18\n", + "\n", + "=\n", + "\n", + "\n", + "\n", + "17->18\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "23\n", + "\n", + "=\n", + "\n", + "\n", + "\n", + "17->23\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "19\n", + "\n", + "s\n", + "\n", + "\n", + "\n", + "18->19\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "20\n", + "\n", + "+\n", + "\n", + "\n", + "\n", + "18->20\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "21\n", + "\n", + "s\n", + "\n", + "\n", + "\n", + "20->21\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "22\n", + "\n", + "n\n", + "\n", + "\n", + "\n", + "20->22\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "24\n", + "\n", + "n\n", + "\n", + "\n", + "\n", + "23->24\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "25\n", + "\n", + "-\n", + "\n", + "\n", + "\n", + "23->25\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "26\n", + "\n", + "n\n", + "\n", + "\n", + "\n", + "25->26\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "27\n", + "\n", + "Number\n", + "\n", + "\n", + "\n", + "25->27\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "28\n", + "\n", + "1\n", + "\n", + "\n", + "\n", + "27->28\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "30\n", + "\n", + "s\n", + "\n", + "\n", + "\n", + "29->30\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "32\n", + "\n", + "main\n", + "\n", + "\n", + "\n", + "31->32\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "33\n", + "\n", + ".\n", + "\n", + "\n", + "\n", + "31->33\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "34\n", + "\n", + ".\n", + "\n", + "\n", + "\n", + "31->34\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "36\n", + "\n", + ".\n", + "\n", + "\n", + "\n", + "31->36\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "35\n", + "\n", + "n\n", + "\n", + "\n", + "\n", + "34->35\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "37\n", + "\n", + "=\n", + "\n", + "\n", + "\n", + "36->37\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "44\n", + "\n", + "call\n", + "\n", + "\n", + "\n", + "36->44\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "38\n", + "\n", + "n\n", + "\n", + "\n", + "\n", + "37->38\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "39\n", + "\n", + "*\n", + "\n", + "\n", + "\n", + "37->39\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "40\n", + "\n", + "Number\n", + "\n", + "\n", + "\n", + "39->40\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "42\n", + "\n", + "Number\n", + "\n", + "\n", + "\n", + "39->42\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "41\n", + "\n", + "6\n", + "\n", + "\n", + "\n", + "40->41\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "43\n", + "\n", + "6\n", + "\n", + "\n", + "\n", + "42->43\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "45\n", + "\n", + "println\n", + "\n", + "\n", + "\n", + "44->45\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "46\n", + "\n", + "call\n", + "\n", + "\n", + "\n", + "44->46\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "47\n", + "\n", + "sum\n", + "\n", + "\n", + "\n", + "46->47\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "48\n", + "\n", + "n\n", + "\n", + "\n", + "\n", + "46->48\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 78, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "parse('Examples/MySum.c')" ] @@ -835,7 +3426,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 79, "metadata": {}, "outputs": [], "source": [ @@ -863,7 +3454,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 80, "metadata": {}, "outputs": [], "source": [ @@ -916,9 +3507,24 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 81, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([' iload 0',\n", + " ' iload 1',\n", + " ' iadd',\n", + " ' invokestatic Sum/sum(I)I'],\n", + " 2)" + ] + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "expr = ('call', 'sum', ('+', 'x', 'y'))\n", "st = { 'x': 0, 'y': 1 }\n", @@ -1109,7 +3715,7 @@ "metadata": {}, "outputs": [], "source": [ - "stmnt = ('if', ('==', 'x', 'y'), ('=', 'x', 'y'))\n", + "stmnt = ('if', ('==', 'x', 'y'), ('=', 'x', ('Number', '42')))\n", "compile_stmnt(stmnt, st, 'Sum')" ] }, @@ -1129,7 +3735,7 @@ "metadata": {}, "outputs": [], "source": [ - "stmnt = ('while', ('<', 'x', 'y'), ('=', 'x', 'y'))\n", + "stmnt = ('while', ('<', 'x', 'y'), ('=', 'x', ('+', 'x', ('Number', '1'))))\n", "compile_stmnt(stmnt, st, 'Sum')" ] }, @@ -1175,11 +3781,11 @@ " if name != 'main':\n", " method = f'.method public static {name}({\"I\"*m})I'\n", " CmdLst = [method, limit_locals, limit_stack] + CmdLst + ['.end method']\n", - " return CmdLst, sz\n", + " return CmdLst, size\n", " else:\n", " method = '.method public static main([Ljava/lang/String;)V'\n", " CmdLst = [method, limit_locals, limit_stack] + CmdLst + [return_stmnt, '.end method']\n", - " return CmdLst, sz" + " return CmdLst, size" ] }, { @@ -1207,7 +3813,7 @@ "metadata": {}, "outputs": [], "source": [ - "file = \"~/Drive/Kurse/Formal-Languages/Ply/Examples/Test.c\"\n", + "file = \"~/Drive/Kurse/Formal-Languages/Python/Chapter-12/Examples/Primes.c\"\n", "print(os.path.dirname(file))\n", "print(os.path.basename(file))\n", "print(os.path.join('abc', 'xyz.c'))" @@ -1253,6 +3859,13 @@ " handle.write(cmd + '\\n')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "The file `Primes.c` is a simple `C` program that computes the prime numbers in a naive way." + ] + }, { "cell_type": "code", "execution_count": null, @@ -1263,10 +3876,12 @@ ] }, { - "cell_type": "markdown", + "cell_type": "code", + "execution_count": null, "metadata": {}, + "outputs": [], "source": [ - "The file `Primes.c` is a simple `C` program that computes the prime numbers in a naive way." + "ls -l" ] }, { @@ -1293,7 +3908,7 @@ "metadata": {}, "outputs": [], "source": [ - "!ls -l" + "!ls -l " ] }, { @@ -1335,16 +3950,7 @@ "metadata": {}, "outputs": [], "source": [ - "!java Primes" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "!rm *.jas *.class" + "!ls -l" ] }, { @@ -1353,7 +3959,7 @@ "metadata": {}, "outputs": [], "source": [ - "!ls -al" + "!java Primes" ] }, {