From 2f27179a9219ee61ed4e32b7fd4802e22aa19863 Mon Sep 17 00:00:00 2001 From: RustyRaptor Date: Tue, 14 Sep 2021 09:27:30 -0600 Subject: [PATCH] added final lab files i never commited for some reason --- 7LAB/Makefile | 16 +- 7LAB/README.md | 225 +- 7LAB/README.pdf | Bin 0 -> 47443 bytes 7LAB/ast.c | 146 +- 7LAB/ast.h | 83 +- 7LAB/cooperoutput.txt | 201 ++ 7LAB/lab6.y | 487 --- 7LAB/lab7_sub.decaf | 29 + 7LAB/{lab6.l => lab9.l} | 0 7LAB/lab9.y | 800 +++++ 7LAB/symtable.c | 251 +- 7LAB/symtable.h | 64 +- 7LAB/testinput.decaf | 78 +- 7LAB/y.output | 1885 +++++------ 7LAB/ziadoutput.txt | 191 ++ 8LAB/readwrite.asm | 84 + 8LAB/sum100.asm | 129 + 9LAB/Makefile | 24 +- 9LAB/bar.asm | 33 + 9LAB/bar2.asm | 33 + 9LAB/bar3.asm | 42 + 9LAB/bar4.asm | 186 ++ 9LAB/bar5.asm | 117 + 9LAB/emit.c | 968 +++--- 9LAB/emit.h | 36 - 9LAB/foo.asm | 15 + 9LAB/lab9 | Bin 63856 -> 63536 bytes 9LAB/lab9.y | 45 +- 9LAB/mytest.decaf | 11 + 9LAB/test.decaf | 31 + 9LAB/test1.asm | 33 + 9LAB/test1.decaf | 12 + 9LAB/test2.asm | 33 + 9LAB/test2.decaf | 17 + 9LAB/test3.asm | 43 + 9LAB/test3.decaf | 19 + 9LAB/test4.asm | 53 + 9LAB/test4.decaf | 42 + 9LAB/test5.asm | 178 ++ 9LAB/test5.decaf | 31 + 9LAB/testy/Makefile | 44 + .../Screenshot from 2021-05-07 23-26-28.png | Bin 0 -> 15463 bytes 9LAB/testy/Test.zip | Bin 0 -> 39660 bytes 9LAB/testy/ast.c | 378 +++ 9LAB/testy/ast.h | 127 + 9LAB/testy/bar4.asm | 186 ++ 9LAB/testy/emit.c | 750 +++++ 9LAB/testy/emit.h | 61 + 9LAB/testy/lab9 | Bin 0 -> 63536 bytes 9LAB/testy/lab9.l | 155 + 9LAB/testy/lab9.y | 891 ++++++ 9LAB/testy/lex.yy.c | 2117 +++++++++++++ 9LAB/testy/readme | 4 + 9LAB/testy/symtable.c | 201 ++ 9LAB/testy/symtable.h | 65 + 9LAB/testy/test4.decaf | 42 + 9LAB/testy/y.output | 1918 ++++++++++++ 9LAB/testy/y.tab.c | 2774 +++++++++++++++++ 9LAB/testy/y.tab.h | 134 + 9LAB/y.tab.c | 374 +-- exam2/exam.md | 40 + 61 files changed, 14651 insertions(+), 2281 deletions(-) create mode 100644 7LAB/README.pdf create mode 100644 7LAB/cooperoutput.txt delete mode 100644 7LAB/lab6.y create mode 100644 7LAB/lab7_sub.decaf rename 7LAB/{lab6.l => lab9.l} (100%) create mode 100644 7LAB/lab9.y create mode 100644 7LAB/ziadoutput.txt create mode 100644 8LAB/readwrite.asm create mode 100644 8LAB/sum100.asm create mode 100644 9LAB/bar.asm create mode 100644 9LAB/bar2.asm create mode 100644 9LAB/bar3.asm create mode 100644 9LAB/bar4.asm create mode 100644 9LAB/bar5.asm create mode 100644 9LAB/mytest.decaf create mode 100644 9LAB/test1.asm create mode 100644 9LAB/test1.decaf create mode 100644 9LAB/test2.asm create mode 100644 9LAB/test2.decaf create mode 100644 9LAB/test3.asm create mode 100644 9LAB/test3.decaf create mode 100644 9LAB/test4.asm create mode 100644 9LAB/test4.decaf create mode 100644 9LAB/test5.asm create mode 100644 9LAB/test5.decaf create mode 100644 9LAB/testy/Makefile create mode 100644 9LAB/testy/Screenshot from 2021-05-07 23-26-28.png create mode 100644 9LAB/testy/Test.zip create mode 100644 9LAB/testy/ast.c create mode 100644 9LAB/testy/ast.h create mode 100644 9LAB/testy/bar4.asm create mode 100644 9LAB/testy/emit.c create mode 100644 9LAB/testy/emit.h create mode 100755 9LAB/testy/lab9 create mode 100644 9LAB/testy/lab9.l create mode 100644 9LAB/testy/lab9.y create mode 100644 9LAB/testy/lex.yy.c create mode 100644 9LAB/testy/readme create mode 100644 9LAB/testy/symtable.c create mode 100644 9LAB/testy/symtable.h create mode 100644 9LAB/testy/test4.decaf create mode 100644 9LAB/testy/y.output create mode 100644 9LAB/testy/y.tab.c create mode 100644 9LAB/testy/y.tab.h create mode 100644 exam2/exam.md diff --git a/7LAB/Makefile b/7LAB/Makefile index 7e2693e..8115673 100644 --- a/7LAB/Makefile +++ b/7LAB/Makefile @@ -5,22 +5,22 @@ FLAGS = -O0 -Wextra -pedantic # Entry point target -all: lab6 +all: lab7 # Compile all the THINGS! -lab6: lab6.l lab6.y ast.c ast.h - lex lab6.l - yacc -d --verbose --debug lab6.y - gcc $(FLAGS) y.tab.c lex.yy.c ast.c -o lab6 -lm +lab7: lab7.l lab7.y ast.c ast.h symtable.c symtable.h + lex lab7.l + yacc -d --verbose --debug lab7.y + gcc $(FLAGS) y.tab.c lex.yy.c ast.c symtable.c -o lab7 -lm # remove the binary and other generated stuff clean: - rm lab6 lex.yy.c y.tab.c y.tab.h + rm lab7 lex.yy.c y.tab.c y.tab.h # runs valgrind to look for any memory mistakes memcheck: - valgrind ./lab6 -s + valgrind ./lab7 -s # executes our code to test it's functionality test: - ./lab6 < testinput.txt \ No newline at end of file + ./lab7 < testinput.txt \ No newline at end of file diff --git a/7LAB/README.md b/7LAB/README.md index faac1e1..a8f1ae5 100644 --- a/7LAB/README.md +++ b/7LAB/README.md @@ -1,29 +1,210 @@ -# CS370 Compilers Lab 5 -## Ziad Arafat - Mar 8 2021 +# CS370 Compilers Lab 7 +## Ziad Arafat - Apr 11 2021 -In this lab we take our previous lab code and implement the proper syntax rules from the DECAF programming language. +In this lab we will re-implement our symbol table to check if variable have been +declared and to check for matching operator sides. -## Screenshots -#### Good Test -![alt](GoodTest.png) +## How to run -#### Error Test +``` +make clean +make +./lab7 < lab7_sub.decaf +``` -![alt](ErrorTest.png) +## OUTPUT +#### lab7_sub.decaf +``` +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +print_int 0 0 0 VOID Extern Method -## Changelog +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method -#### LEX -- added the DECAF tokens -- Added some debug prints to the tokens -- Added square brackets to the lex directive -- Added '<' token to the directive -- Added modulus '%' -- Added directive for HEX numbers -- Created function to convert hex numbers to their int value -- Disabled the newline return token +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +_T4 18 1 2 INT Scalar +_T3 17 1 2 INT Scalar +_T2 16 1 2 INT Scalar +_T1 15 1 2 INT Scalar +_T0 14 1 2 INT Scalar +x 4 10 2 INT Array +y 3 1 1 INT Scalar +f 0 0 0 INT Method +b 2 1 1 INT Scalar +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method -#### YACC -- added all the rules from DECAF and reformatted them to work with Bison */ -- for each of the rules with a list of tokens I created a recursive rule that allows for one or more of the token. -- Replaced any instance of '=' with T_ASSIGN \ No newline at end of file +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +_T9 18 1 2 INT Scalar +_T8 17 1 2 INT Scalar +_T7 16 1 2 INT Scalar +_T6 15 1 2 INT Scalar +_T5 14 1 2 INT Scalar +x 4 10 2 INT Array +y 3 1 1 INT Scalar +f 0 0 0 INT Method +b 2 1 1 INT Scalar +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +y 3 1 1 INT Scalar +f 0 0 0 INT Method +b 2 1 1 INT Scalar +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +_T15 9 1 1 INT Scalar +_T14 8 1 1 INT Scalar +_T13 7 1 1 INT Scalar +_T12 6 1 1 INT Scalar +_T11 5 1 1 INT Scalar +_T10 4 1 1 INT Scalar +main 0 0 0 INT Method +arg1 3 1 1 INT Scalar +arg2 2 1 1 INT Scalar +f 0 19 0 INT Method +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + +Parsing completed +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +main 0 10 0 INT Method +f 0 19 0 INT Method +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + + EXTERN FUNC print_int + EXTERN Type INT +END EXTERN with Type: + VOID EXTERN FUNC print_string + EXTERN Type STRING +END EXTERN with Type: + VOID Package : foo + Variable y with type INT = 7 + Variable Z[100] with type INT + Variable Y[100] with type BOOLEAN + Variable z with type INT = 10 + METHOD FUNCTION 'f' with type INT + ( + Method ARGb INT + ) + BLOCK STATEMENT + Variable y with type INT + BLOCK STATEMENT + Variable x[10] with type INT + ASSIGNMENT STATEMENT + Variable Left x + [ + EXPR - + EXPR + + CONSTANT INTEGER 2 + CONSTANT INTEGER 3 + CONSTANT INTEGER 5 + ] + EXPR + + Variable Right b + METHOD CALL name: f + ( + METHOD ARG + EXPR + + CONSTANT INTEGER 5 + EXPR * + Variable Right x + [ + CONSTANT INTEGER 2 + ] + Variable Right b + ) + BLOCK STATEMENT + Variable x[10] with type INT + ASSIGNMENT STATEMENT + Variable Left x + [ + EXPR - + EXPR + + CONSTANT INTEGER 2 + CONSTANT INTEGER 3 + CONSTANT INTEGER 5 + ] + EXPR + + Variable Right b + METHOD CALL name: f + ( + METHOD ARG + EXPR + + CONSTANT INTEGER 5 + EXPR * + Variable Right x + [ + CONSTANT INTEGER 2 + ] + Variable Right b + ) + METHOD FUNCTION 'main' with type INT + ( + Method ARGarg1 INT + Method ARGarg2 INT + ) + BLOCK STATEMENT + METHOD CALL name: print_int + ( + METHOD ARG + METHOD CALL name: f + ( + METHOD ARG + EXPR + + EXPR - + EXPR + + Variable Right arg1 + Variable Right arg2 + Variable Right z + Variable Right y + ) + ) + METHOD CALL name: print_int + ( + METHOD ARG + METHOD CALL name: f + ( + METHOD ARG + EXPR + + EXPR - + EXPR + + Variable Right arg1 + Variable Right arg2 + Variable Right z + Variable Right y + ) + ) + METHOD CALL name: print_string + ( + METHOD ARG + CONSTANT STRING "hello world\n" + ) + +Finished printing AST + +``` diff --git a/7LAB/README.pdf b/7LAB/README.pdf new file mode 100644 index 0000000000000000000000000000000000000000..5832e782b9beaab7692787d7dbd2755e1fb0b5df GIT binary patch literal 47443 zcmd42WpG@bv-wwRfjnHel*iB@8bwgNUPvp|hPMfKtTV z(ay%g#fA!oLDA6;=wfX0*{EV=VaV_~7GT54_1WYM7=+~j4Dxo4Hip*!F2wQg zLgE(I&Yzkwh+BW^AZlW42Q-0UkTtP2b2bMsF*9@V^8=imKQYQ6rX(03Wm7Y%V_G3cP8cj~hM7#jQbXbzoC}4W;}_o|Si%08Ns~y{q9PudHr`(n-##BJ3NQMsA zqlF7{Dnx@uR@gxz9XpkwrNQ#Dkp$=9yZls)z65%e7FX?>`Zck0O1u@cvb`p=I!R(5 z$~b@^cR3+IlNQw9ygc33fRQ-HHLB$c(5ha^&$!ZM;;WTSCY+c3rZeREnQHm@t*SEB z0QK8p;FAZSni%b|d zh5QdCR}*`7Yj1n1QLHVh7shyPCm}>B4=F?p-=F*&-?IjJuI6!0&%k5e;v7!-hks-? zEgL)w*w@EU@QplLxjz=ddmHHA>awpPU$srleYhU@aJxj`-|Sx)8kBXL#Sxp`^0d0_ ztub_yA-Ft^waqP$xj((pchh6JDAvsz*iy_IJ#7b( zdxq6-f}mvK25W^Lc#*y8yul_M(3E4pf_IQ9_FtgFX+4)6k0*5N)OgGBNf)y0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81(b1dt`~voz@DMvVj+g?Q=n3$8}i2| z_yj3D2Bn+<(0WJuQ%Y0%{k&13$ZbN19K?Xq_E4i0vv!X)Z1rrAYpMv+vj)RNW=t%2 z;6_U;@B&Alz@uG+8-G^>vTy>FdbS1@FaYSoza@eHmdpawcmN6QUtt?Ewl=o^(g_2A z8UMxE08kzn*qOQ6S^rh19>CdPW%@56@4q-3?EfTWumivw|Dh9R=VIUh;5eB7H_iqN z8w1-P#EyS(HvT0K=3wGt;Ns!{U^f1{_dg4T|BxB}XEFRgpcH?L_n%SzJ8FQq_K(~C z=OX?84F3P4P?#G4lK>1W6E`OZ$KRO{|3Odr--MI^*uA(sMHH^zm9_RfLaLN(`&{$Ux7xz{Mkj+kj{{DM|EYo+S@VYe0M*O;jd8p zW;gINFjGU)pDfmMPNGk$-lut7ahdK}In~yjUqyS=-q6c-_e>jCPPW0m%fD^2yBSVe z-D|T0b7CI)*P<-$tYR(jfc>M_qO{6cVM{e9Z)?u2IwNhb0gWMrGWK)QZ6W6<6d%aaxcbe-OgP zI+Ik;LM%gV+fKe$Kz;l*Vf^s<9^|Nhtde22EB2dqJK}6FWq_dugc04EZanTjV+M$I|G0>3{>#S9#KI0}=}$H$CIGkcFE$nczXbp#`I8?jVAB58kBx)l zk16&iKR|ojf4!HPiH!>o)SvyB+5QJV4nVDdzxc6o{q32VnYfw$)*c5N+u!x z^XGoK*tq{12QxD(D}cc9CqHJuItHk|@K+lLpk%?HY=F84On)6`7AAJ~zxe^4 z92|eO0pLUIe~k^$!{5e*m6_>peXs&vMHyzHYW#t z0N=>rj}MBXxrgx|sm7>aYwPq!*@AzpssCUM{XwqzBP|`B^c|f3k(6v4faMH^oLuy~ G*#84 #include #include "ast.h" +// #include "symtable.h" /* uses malloc to create an ASTnode and passes back the heap address of the newley created node */ ASTnode *ASTCreateNode(enum AST_Tree_Element_Type mytype) @@ -68,14 +74,24 @@ void ASTprint(int level, ASTnode *p) PT(level); /* indent */ switch (p->type) { case A_VAR_RVALUE: - printf("Variable %s \n", p->name); - if (p->S1 != NULL) { - PT(level + 2); - printf("[\n"); - ASTprint(level+2, p->S1); - PT(level + 2); - printf("]\n"); - } + printf("Variable Right %s \n", p->name); + if (p->S1 != NULL) { + PT(level + 2); + printf("[\n"); + ASTprint(level + 2, p->S1); + PT(level + 2); + printf("]\n"); + } + break; + case A_VAR_LVALUE: + printf("Variable Left %s \n", p->name); + if (p->S1 != NULL) { + PT(level + 2); + printf("[\n"); + ASTprint(level + 2, p->S1); + PT(level + 2); + printf("]\n"); + } break; case A_PROGRAM: // printf("PROGRAM \n"); @@ -87,24 +103,24 @@ void ASTprint(int level, ASTnode *p) // printf("\n"); ASTprint(level + 1, p->S1); // printf("\n"); - + printf("END EXTERN with Type:\n "); - AST_Print_Type(p->A_Declared_Type); + AST_Print_Type(p->A_Declared_Type); break; case A_PACKAGE: printf("Package : %s\n", p->name); - PT(level + 2); + PT(level + 2); // printf("{\n"); ASTprint(level + 1, p->S1); ASTprint(level + 1, p->S2); - PT(level + 2); + PT(level + 2); printf("\n"); break; case A_ExternType: printf("EXTERN Type "); AST_Print_Type(p->A_Declared_Type); - printf("\n"); + printf("\n"); break; case A_VARDEC: @@ -116,7 +132,7 @@ void ASTprint(int level, ASTnode *p) printf("%d", p->S1->value); printf("] "); } - printf(" with type "); + printf(" with type "); AST_Print_Type(p->A_Declared_Type); printf(" "); if (p->S2 != NULL) { @@ -146,8 +162,10 @@ void ASTprint(int level, ASTnode *p) break; case A_METHODID: - printf("Method Variable"); - printf(" %s", p->name); + PT(level + 2); + printf("Method ARG"); + // fixed for indentation there was a stupid space here + printf("%s", p->name); AST_Print_Type(p->A_Declared_Type); printf("\n"); @@ -218,7 +236,7 @@ void ASTprint(int level, ASTnode *p) printf(" !"); break; case A_UMINUS: - // print words so we know it's not just minus + // print words so we know it's not just minus printf(" Unary Minus"); break; default: @@ -226,7 +244,7 @@ void ASTprint(int level, ASTnode *p) } printf("\n"); ASTprint(level + 1, p->S1); - if (p->operator!= A_NOT && p->operator != A_UMINUS) + if (p->operator!= A_NOT && p->operator!= A_UMINUS) ASTprint(level + 1, p->S2); break; case A_BLOCK: @@ -243,10 +261,10 @@ void ASTprint(int level, ASTnode *p) case A_CONSTANT_INT: printf("CONSTANT INTEGER %d\n", p->value); break; - case A_CONSTANT_STRING: + case A_CONSTANT_STRING: printf("CONSTANT STRING %s\n", p->name); break; - + case A_CONSTANT_BOOL: printf("CONSTANT BOOLEAN "); if (p->value == 1) { @@ -262,34 +280,35 @@ void ASTprint(int level, ASTnode *p) printf("RETURN STATEMENT \n"); ASTprint(level + 1, p->S1); break; - case A_ASSIGN: + case A_ASSIGN: printf("ASSIGNMENT STATEMENT\n"); ASTprint(level + 1, p->S1); - ASTprint(level + 1, p->S2); + ASTprint(level + 1, p->S2); break; - case A_IF: - printf("IF STATEMENT \n"); + case A_IF: + printf("IF STATEMENT \n"); ASTprint(level + 1, p->S1); - ASTprint(level + 1, p->S2); + ASTprint(level + 1, p->S2); break; - case A_IFBODY: - // printf("IF BODY \n"); + case A_IFBODY: + // printf("IF BODY \n"); ASTprint(level + 1, p->S1); - ASTprint(level + 1, p->S2); + ASTprint(level + 1, p->S2); break; - - case A_ELSE: - printf("ELSE \n"); + + case A_ELSE: + printf("ELSE \n"); ASTprint(level + 1, p->S1); break; - case A_METHODCALL: - printf(" METHOD CALL name: %s\n", p->name); + case A_METHODCALL: + printf(" METHOD CALL name: %s\n", p->name); + PT(level); + printf("(\n"); PT(level); - printf("(\n"); - printf("METHOD ARG \n"); + printf("METHOD ARG \n"); ASTprint(level + 1, p->S1); - PT(level); - printf(")\n"); + PT(level); + printf(")\n"); break; default: @@ -299,6 +318,59 @@ void ASTprint(int level, ASTnode *p) } } +// checks that two nodes match in type and length +int check_parameters(ASTnode *formal, ASTnode *actual) +{ + if (actual == NULL && formal == NULL) { + return (1); + } + if (actual == NULL) { + return (0); + } + if (formal == NULL) { + return (0); + } + if (actual->A_Declared_Type != formal->A_Declared_Type) { + return (0); + } + return check_parameters(formal->next, actual->next); +} + +// created this because it was starting to look messy in yacc +// takes an operator and a type and returns 1 if they are compatible 0 if not +int check_operators(enum AST_Operators op, enum AST_Decaf_Types type) +{ + switch (op) { + // I did it. I found a case where having no break statement + // in a switch is useful. + // This is the same as using a bunch of || statements but its nice + // and vertical + case A_TIMES: + case A_DIVIDE: + case A_MOD: + case A_PLUS: + case A_MINUS: + if (type == A_Decaf_BOOL) { + return (0); + } + return (1); + break; // breaks probably redundant but adding then anyway + case A_AND: + case A_OR: + case A_RIGHTSHIFT: + case A_LEFTSHIFT: + if (type == A_Decaf_INT) { + return (0); + } + return (1); + break; + default: + return (1); + break; + } + +} + /* dummy main program so I can compile for syntax error independently */ // void main() diff --git a/7LAB/ast.h b/7LAB/ast.h index c1973b7..55053d8 100644 --- a/7LAB/ast.h +++ b/7LAB/ast.h @@ -6,6 +6,11 @@ */ +/* +Ziad Arafat - Apr 11 2021 +Lab 7 +*/ + #include #include @@ -18,7 +23,7 @@ sort of production rule we came across */ /* added all the needed tree nodes */ enum AST_Tree_Element_Type { - A_PROGRAM, + A_PROGRAM, A_EXTERN, A_PACKAGE, A_METHODDEC, @@ -28,45 +33,44 @@ enum AST_Tree_Element_Type { A_EXPR, A_PARAM, A_VARDEC, - A_ExternType, - A_ARRAYTYPE, - A_METHODID, - A_CONSTANT_INT, - A_CONSTANT_BOOL, - A_CONSTANT_STRING, - A_BREAK, - A_VAR_RVALUE, - A_RETURN, - A_ASSIGN, - A_IF, - A_IFBODY, - A_ELSE, - A_METHODCALL, - A_CONTINUE - + A_ExternType, + A_ARRAYTYPE, + A_METHODID, + A_CONSTANT_INT, + A_CONSTANT_BOOL, + A_CONSTANT_STRING, + A_BREAK, + A_VAR_RVALUE, + A_VAR_LVALUE, // added this to fix last lab + A_RETURN, + A_ASSIGN, + A_IF, + A_IFBODY, + A_ELSE, + A_METHODCALL, + A_CONTINUE // missing }; - /* Added all the needed operators */ enum AST_Operators { A_PLUS, A_MINUS, - A_UMINUS, + A_UMINUS, A_TIMES, - A_DIVIDE, - A_MOD, - A_AND, - A_OR, - A_LEFTSHIFT, - A_RIGHTSHIFT, - A_LT, - A_GT, - A_EQ, - A_LEQ, - A_GEQ, - A_NEQ, + A_DIVIDE, + A_MOD, + A_AND, + A_OR, + A_LEFTSHIFT, + A_RIGHTSHIFT, + A_LT, + A_GT, + A_EQ, + A_LEQ, + A_GEQ, + A_NEQ, A_NOT // missing }; @@ -75,8 +79,8 @@ enum AST_Decaf_Types { A_Decaf_INT, A_Decaf_BOOL, A_Decaf_VOID, - A_Decaf_STRING, - A_Decaf_CHAR + A_Decaf_STRING, + A_Decaf_CHAR // missing }; @@ -88,12 +92,16 @@ typedef struct ASTnodetype { enum AST_Operators operator; char *name; int value; - enum AST_Decaf_Types A_Declared_Type; + struct SymbTab *symbol; + enum AST_Decaf_Types A_Declared_Type; + int size; ///.. missing struct ASTnodetype *S1, *S2, *next; /* used for holding IF and WHILE components -- not very descriptive */ } ASTnode; +#include "symtable.h" + /* uses malloc to create an ASTnode and passes back the heap address of the * newley created node */ ASTnode *ASTCreateNode(enum AST_Tree_Element_Type mytype); @@ -106,4 +114,11 @@ ASTnode *program; // Global Pointer for connection between YACC and backend void ASTprint(int level, ASTnode *p); // prints tree with level horizontal spaceing +// checks that two nodes match in type and length +int check_parameters(ASTnode *formal, ASTnode *actual); + +// created this because it was starting to look messy in yacc +// takes an operator and a type and returns 1 if they are compatible 0 if not +int check_operators(enum AST_Operators op, enum AST_Decaf_Types type); + #endif // of AST_H diff --git a/7LAB/cooperoutput.txt b/7LAB/cooperoutput.txt new file mode 100644 index 0000000..45c8fe7 --- /dev/null +++ b/7LAB/cooperoutput.txt @@ -0,0 +1,201 @@ + + LABEL Offset LEVEL type subtype + print_int 0 0 VOID Extern Method + + LABEL Offset LEVEL type subtype + print_string 0 0 VOID Extern Method + print_int 0 0 VOID Extern Method + + LABEL Offset LEVEL type subtype + foo 0 0 INT Package + print_string 0 0 VOID Extern Method + print_int 0 0 VOID Extern Method + + LABEL Offset LEVEL type subtype + foo1 0 0 INT Method + A 3 0 INT Array + Y 1 0 INT Array + x 0 0 INT Scalar + foo 0 0 INT Package + print_string 0 0 VOID Extern Method + print_int 0 0 VOID Extern Method + + LABEL Offset LEVEL type subtype + W11 4 1 INT Scalar + x 3 1 INT Scalar + y 2 1 BOOL Scalar + foo1 0 0 INT Method + A 3 0 INT Array + Y 1 0 INT Array + x 0 0 INT Scalar + foo 0 0 INT Package + print_string 0 0 VOID Extern Method + print_int 0 0 VOID Extern Method + + LABEL Offset LEVEL type subtype + _t2 107 2 INT Scalar + _t1 106 1 INT Scalar + _t0 105 1 INT Scalar + A 5 1 INT Array + W11 4 1 INT Scalar + x 3 1 INT Scalar + y 2 1 BOOL Scalar + foo1 0 0 INT Method + A 3 0 INT Array + Y 1 0 INT Array + x 0 0 INT Scalar + foo 0 0 INT Package + print_string 0 0 VOID Extern Method + print_int 0 0 VOID Extern Method + + LABEL Offset LEVEL type subtype + _t1 106 1 INT Scalar + _t0 105 1 INT Scalar + A 5 1 INT Array + W11 4 1 INT Scalar + x 3 1 INT Scalar + y 2 1 BOOL Scalar + foo1 0 0 INT Method + A 3 0 INT Array + Y 1 0 INT Array + x 0 0 INT Scalar + foo 0 0 INT Package + print_string 0 0 VOID Extern Method + print_int 0 0 VOID Extern Method + + LABEL Offset LEVEL type subtype + _t5 109 2 INT Scalar + _t4 108 1 BOOL Scalar + _t3 107 1 BOOL Scalar + _t1 106 1 INT Scalar + _t0 105 1 INT Scalar + A 5 1 INT Array + W11 4 1 INT Scalar + x 3 1 INT Scalar + y 2 1 BOOL Scalar + foo1 0 0 INT Method + A 3 0 INT Array + Y 1 0 INT Array + x 0 0 INT Scalar + foo 0 0 INT Package + print_string 0 0 VOID Extern Method + print_int 0 0 VOID Extern Method + + LABEL Offset LEVEL type subtype + _t4 108 1 BOOL Scalar + _t3 107 1 BOOL Scalar + _t1 106 1 INT Scalar + _t0 105 1 INT Scalar + A 5 1 INT Array + W11 4 1 INT Scalar + x 3 1 INT Scalar + y 2 1 BOOL Scalar + foo1 0 0 INT Method + A 3 0 INT Array + Y 1 0 INT Array + x 0 0 INT Scalar + foo 0 0 INT Package + print_string 0 0 VOID Extern Method + print_int 0 0 VOID Extern Method +Parsing completed + + LABEL Offset LEVEL type subtype + foo1 0 0 INT Method + A 3 0 INT Array + Y 1 0 INT Array + x 0 0 INT Scalar + foo 0 0 INT Package + print_string 0 0 VOID Extern Method + print_int 0 0 VOID Extern Method + + + +EXTERN FUNC print_int + EXTERN Type: INT +END EXTERN with Type: VOID + +EXTERN FUNC print_string + EXTERN Type: CONSTANT STRING +END EXTERN with Type: VOID + +Package : foo + + Variable x offset 0 with type INT = 3 + + Variable Y offset 1 [2] with type INT + Variable A offset 3 [100] with type INT + + METHOD FUNCTION foo1 INT + ( + PARAMETER INT x offset 3 + PARAMETER BOOLEAN y offset 2 + ) + BLOCK STATEMENT + Variable W11 offset 4 with type INT + Variable A offset 5 [100] with type INT + BREAK STATEMENT + ASSIGNMENT STATEMENT + Variable x + EXPR + + Variable x + Variable Y + [ + Variable A + [ + CONSTANT INTEGER 2 + ] + ] + ASSIGNMENT STATEMENT + Variable x + CONSTANT INTEGER 1 + ASSIGNMENT STATEMENT + Variable y + CONSTANT BOOLEAN false + IF STATEMENT + EXPR > + Variable x + Variable x + BLOCK STATEMENT + ASSIGNMENT STATEMENT + Variable x + EXPR + + CONSTANT INTEGER 3 + CONSTANT INTEGER 4 + ELSE + BLOCK STATEMENT + ASSIGNMENT STATEMENT + Variable x + Variable A + [ + CONSTANT INTEGER 2 + ] + RETURN STATEMENT + RETURN STATEMENT + RETURN STATEMENT + EXPR != + Variable y + Variable y + WHILE STATEMENT + EXPR != + CONSTANT BOOLEAN true + CONSTANT BOOLEAN false + BLOCK STATEMENT + ASSIGNMENT STATEMENT + Variable x + EXPR + + CONSTANT INTEGER 3 + CONSTANT INTEGER 2 + METHOD CALL name: print_string + ( + METHOD ARG + CONSTANT STRING "hello world" + ) + ASSIGNMENT STATEMENT + Variable x + METHOD CALL name: foo1 + ( + METHOD ARG + CONSTANT INTEGER 3 + METHOD ARG + CONSTANT BOOLEAN true + ) \ No newline at end of file diff --git a/7LAB/lab6.y b/7LAB/lab6.y deleted file mode 100644 index dbc2801..0000000 --- a/7LAB/lab6.y +++ /dev/null @@ -1,487 +0,0 @@ -/* -Ziad Arafat - Mar 8 2021 -Lab 5 -*/ - -%{ -#include -#include - -#include "ast.h" - -int yylex(); - -extern int yylineno; // import the yylineno variable -void yyerror (s) /* Called by yyparse on error */ - char *s; -{ - // changed these to output to stderr - fprintf(stderr, "%s \n", s); - - // print out the line number of the syntax error. - fprintf(stderr, "Error on line: %d \n", yylineno); -} - -struct ASTnodetype *PROGRAM; - -%} -/* defines the start symbol, what values come back -from LEX and how the operators are associated */ -/* changed to P */ -%start Program - -/* Defines possible types */ -%union -{ - int value; - char* string; - struct ASTnodetype *astnode; - enum AST_Decaf_Types asttype; - enum AST_Operators operator; -} - - -// I commented out the tokens that aren't being used. - -// I also removed the token for T_LT because idk why one was a token and the -// other was a char?? - - -// Added a token for each of the lex tokens -%token T_AND -%token T_ASSIGN -%token T_BOOLTYPE -%token T_BREAK -/* %token T_CHARCONSTANT */ -%token T_CONTINUE -/* %token T_DOT */ -%token T_ELSE -%token T_EQ -%token T_EXTERN -%token T_FALSE -/* %token T_FOR */ -%token T_FUNC -%token T_GEQ -/* %token T_GT */ -%token T_ID -%token T_IF -%token T_INTCONSTANT -%token T_INTTYPE -%token T_LEFTSHIFT -%token T_LEQ -%token T_NEQ -/* %token T_NULL */ -%token T_OR -%token T_PACKAGE -%token T_RETURN -%token T_RIGHTSHIFT -%token T_STRINGCONSTANT -%token T_STRINGTYPE -%token T_TRUE -%token T_VAR -%token T_VOID -%token T_WHILE - -/* %token T_STRING_LIT -%token T_INT_LIT */ - -%type Externs ExternDefn FullExternParmList ExternParmList FieldDecl -%type FieldDecls ArrayType MethodDecl MethodDecls Block VarDecl -%type IdTypeList IdTypeList1 VarDecls Statement Statements ReturnStmt -%type Constant BoolConstant BreakStmt Additiveexpression Term -%type Factor Simpleexpression Expr Assign Lvalue IfStmt WhileStmt -%type MethodCall MethodArgs FullMethodArgs MethodArg ContinueStmt -%type MethodType Type ExternType -%type Multop Addop Relop - - -/* added all the rules from DECAF and reformatted them to work with Bison */ -/* for each of the rules with a list of tokens I created a recursive rule -that allows for one or more of the token. -*/ - -/* Replaced any instance of '=' with T_ASSIGN */ - -%% /* end specs, begin rules */ -Program: - Externs T_PACKAGE T_ID '{' FieldDecls MethodDecls '}' { - PROGRAM = ASTCreateNode(A_PROGRAM); - PROGRAM->S1 = $1; - PROGRAM->S2 = ASTCreateNode(A_PACKAGE); - PROGRAM->S2->name = $3; - PROGRAM->S2->S1 = $5; - PROGRAM->S2->S2 = $6; - }; - -Externs: - /* empty */ { $$ = NULL; } - | ExternDefn Externs { $1->next = $2; }; - -ExternDefn: - T_EXTERN T_FUNC T_ID '(' ExternParmList ')' MethodType ';' { - $$ = ASTCreateNode(A_EXTERN); - $$->name = $3; - $$->A_Declared_Type = $7; - $$->S1 = $5; - }; - -ExternParmList: - /* empty */ { $$ = NULL; } - | FullExternParmList {$$ = $1;} ; - -FullExternParmList: - ExternType { - $$ = ASTCreateNode(A_ExternType); - $$->A_Declared_Type = $1; - } - | ExternType ',' ExternParmList { - $$ = ASTCreateNode(A_ExternType); - $$->A_Declared_Type = $1; - $$->next = $3; - }; - -FieldDecls: - /* empty */ {$$ = NULL;} - | FieldDecl FieldDecls { - $$ = $1; - $$->next = $2; - }; - -FieldDecl: - T_VAR T_ID Type ';' { - $$ = ASTCreateNode(A_VARDEC); - $$->name = $2; - $$->A_Declared_Type = $3; - - } - | T_VAR T_ID ArrayType ';' { - $$ = ASTCreateNode(A_VARDEC); - $$->name = $2; - $$->S1 = $3; - $$->A_Declared_Type = $3->A_Declared_Type; - - } - | T_VAR T_ID Type T_ASSIGN Constant ';' { - $$ = ASTCreateNode(A_VARDEC); - $$->name = $2; - $$->A_Declared_Type = $3; - $$->S2 = $5; - - }; - -MethodDecls: - /* empty */ {$$ = NULL;} - | MethodDecl MethodDecls { - $$ = $1; - $$->next = $2; - }; - -MethodDecl: - T_FUNC T_ID '(' IdTypeList ')' MethodType Block { - $$ = ASTCreateNode(A_METHODDEC); - $$->name = $2; - $$->A_Declared_Type = $6; - $$->S1 = $4; // $4; - $$->S2 = $7; // $7; - }; - -IdTypeList: - /* empty */ { $$ = NULL; } - | IdTypeList1 { $$ = $1; }; - -IdTypeList1: - T_ID Type { - $$ = ASTCreateNode(A_METHODID); - $$->name = $1; - $$->A_Declared_Type = $2; - } - | T_ID Type ',' IdTypeList { - $$ = ASTCreateNode(A_METHODID); - $$->name = $1; - $$->A_Declared_Type = $2; - $$->next = $4; - }; - -Block: - '{' VarDecls Statements '}' { - $$ = ASTCreateNode(A_BLOCK); - $$->S1 = $2; - $$->S2 = $3; - }; - -VarDecls: - /* empty */ { $$ = NULL; } - | VarDecl VarDecls { - $$ = $1; - $$->next = $2; - }; - -VarDecl: - T_VAR T_ID Type ';' { - $$ = ASTCreateNode(A_VARDEC); - $$->name = $2; - $$->A_Declared_Type = $3; - } - | T_VAR T_ID ArrayType ';' { - $$ = ASTCreateNode(A_VARDEC); - $$->name = $2; - $$->S1 = $3; - $$->A_Declared_Type = $$->S1->A_Declared_Type; - }; - -Statements: - /* empty */ { $$ = NULL; } - | Statement Statements { - $$ = $1; - $$->next = $2; - }; - -/* Moved all of the Statement into one rule and moved each item into it's own -separate rule. - */ - /* Connected these all */ -Statement: - Block { $$ = $1; } - | Assign ';' { $$ = $1; } - | MethodCall ';' { $$ = $1; } - | IfStmt { $$ = $1; } - | WhileStmt { $$ = $1; } - | ReturnStmt { $$ = $1; } - | BreakStmt { $$ = $1; } - | ContinueStmt { $$ = $1; } - ; - -/* Created a continue statement idk if this was needed */ -ContinueStmt: T_CONTINUE ';' {$$ = ASTCreateNode(A_CONTINUE);}; - -WhileStmt: - T_WHILE '(' Expr ')' Block { - $$ = ASTCreateNode(A_WHILESTMT); - $$->S1 = $3; - $$->S2 = $5; - }; - -BreakStmt: T_BREAK ';' { $$ = ASTCreateNode(A_BREAK); }; - -IfStmt: - T_IF '(' Expr ')' Block T_ELSE Block { - $$ = ASTCreateNode(A_IF); - $$->S1 = $3; - $$->S2 = ASTCreateNode(A_IFBODY); - $$->S2->S1 = $5; - $$->S2->S2 = ASTCreateNode(A_ELSE); - $$->S2->S2->S1 = $7; - } - | T_IF '(' Expr ')' Block { - $$ = ASTCreateNode(A_IF); - $$->S1 = $3; - $$->S2 = ASTCreateNode(A_IFBODY); - $$->S2->S1 = $5; - $$->S2->S2 = NULL; - } - ; - -ReturnStmt: - T_RETURN ';' { $$ = ASTCreateNode(A_RETURN);} - | T_RETURN '(' ')' ';' { $$ = ASTCreateNode(A_RETURN);} - | T_RETURN '(' Expr ')' ';' { - $$ = ASTCreateNode(A_RETURN); - $$->S1 = $3; - }; - -Assign: - Lvalue T_ASSIGN Expr { - $$ = ASTCreateNode(A_ASSIGN); - $$->S1 = $1; - $$->S2 = $3; - }; - -/* Assigns: Assign - | Assign ',' Assigns - - ; */ - -Lvalue: - T_ID { - /* I am using A_VAR_RVALUE for both the LVALUE and RVALUE - Mostly because the node serves the same purpose. - */ - $$ = ASTCreateNode(A_VAR_RVALUE); - $$->name = $1; - } - | T_ID '[' Expr ']' { - $$ = ASTCreateNode(A_VAR_RVALUE); - $$->name = $1; - $$->S1 = $3; - }; - - -MethodCall: - T_ID '(' MethodArgs ')' { - $$ = ASTCreateNode(A_METHODCALL); - $$->name = $1; - $$->S1 = $3; - }; - -MethodArg: Expr { $$ = $1; }; - -MethodArgs: - /* empty */ { - $$ = NULL; - } - | FullMethodArgs { - $$ = $1; - }; - -FullMethodArgs: - MethodArg { - $$ = $1; - } - | MethodArg ',' MethodArgs { - $$ = $1; - $$->next = $3; - } - ; - - - - -/* Statement: T_FOR '(' Assigns ';' Expr ';' Assigns ')' Block - ; */ - - - - - -Expr: Simpleexpression { $$ = $1; }; - -Simpleexpression: - Additiveexpression { $$ = $1; } - | Simpleexpression Relop Additiveexpression { - $$ = ASTCreateNode(A_EXPR); - $$->S1 = $1; - $$->operator = $2; - $$->S2 = $3; - }; - -Relop: - '<' { $$ = A_LT; } - | '>' { $$ = A_GT; } - | T_EQ { $$ = A_EQ; } - | T_LEQ { $$ = A_LEQ; } - | T_GEQ { $$ = A_GEQ; } - | T_NEQ { $$ = A_NEQ; }; - -Additiveexpression: - Term { $$ = $1; } - | Additiveexpression Addop Term { - $$ = ASTCreateNode(A_EXPR); - $$->S1 = $1; - $$->operator = $2; - $$->S2 = $3; - }; - -Addop: - '+' { $$ = A_PLUS; } - | '-' { $$ = A_MINUS; }; - -Term: - Factor { $$ = $1; } - | Term Multop Factor { - $$ = ASTCreateNode(A_EXPR); - $$->S1 = $1; - $$->operator = $2; - $$->S2 = $3; - }; -/* added modulus as a multi operator */ -Multop: - '*' { $$ = A_TIMES; } - | '/' { $$ = A_DIVIDE; } - | '%' { $$ = A_MOD; } - | T_AND { $$ = A_AND; } - | T_OR { $$ = A_OR; } - | T_LEFTSHIFT { $$ = A_LEFTSHIFT; } - | T_RIGHTSHIFT { $$ = A_RIGHTSHIFT; }; - -Factor: - T_ID { - $$ = ASTCreateNode(A_VAR_RVALUE); - $$->name = $1; - - } - | MethodCall { $$ = $1; } - | T_ID '[' Expr ']' { - $$ = ASTCreateNode(A_VAR_RVALUE); - $$->name = $1; - $$->S1 = $3; - } - | Constant { $$ = $1; } - | '(' Expr ')' { $$ = $2; } - | '!' Factor { - $$ = ASTCreateNode(A_EXPR); - $$->operator = A_NOT; - $$->S1 = $2; - } - /* moved this around a lot until I got it working in here */ - | T_STRINGCONSTANT { - $$ = ASTCreateNode(A_CONSTANT_STRING); - $$->name = $1; - } - | '-' Factor { - $$ = ASTCreateNode(A_EXPR); - $$->operator = A_UMINUS; - $$->S1 = $2; - }; - - - - -ExternType: - T_STRINGTYPE { $$ = A_Decaf_STRING; } - | Type - ; - -Type: - T_INTTYPE { $$ = A_Decaf_INT; } - | T_BOOLTYPE{ $$ = A_Decaf_BOOL; }; - -MethodType: - T_VOID { $$ = A_Decaf_VOID; } - | Type { $$ = $1; }; - -BoolConstant: - T_TRUE { - $$ = ASTCreateNode(A_CONSTANT_BOOL); - $$->value = 1; - } - | T_FALSE { - $$ = ASTCreateNode(A_CONSTANT_BOOL); - $$->value = 0; - }; - -ArrayType: - '[' T_INTCONSTANT ']' Type { - $$ = ASTCreateNode(A_ARRAYTYPE); - $$->value = $2; - $$->A_Declared_Type = $4; - } - ; -/* added String and Char as constants */ -Constant: - T_INTCONSTANT { - $$ = ASTCreateNode(A_CONSTANT_INT); - $$->value = $1; - } - - | BoolConstant { - $$ = $1; - }; -%% /* end of rules, start of program */ - -int main(){ - yyparse(); - printf("Parsing completed\n"); - // We know PROGRAM points to our AST - ASTprint(0, PROGRAM); - printf("Finished printing AST "); -} \ No newline at end of file diff --git a/7LAB/lab7_sub.decaf b/7LAB/lab7_sub.decaf new file mode 100644 index 0000000..7e6f8f2 --- /dev/null +++ b/7LAB/lab7_sub.decaf @@ -0,0 +1,29 @@ +extern func print_int (int) void; +extern func print_string (string) void; + +package foo { + var y int =7; + var Z[100] int; + var Y[100] bool; + var z int = 10; + + func f(b int) int + { + var y int; + { var x[10] int; + x[2+3-5]=b + f(5+x[2]*b); + } + { var x[10] int; + x[2+3-5]=b + f(5+x[2]*b); + } + } + + + func main(arg1 int, arg2 int) int + { + print_int( f(arg1 + arg2 -z + y)); + print_int( f(arg1 + arg2 -z + y)); + print_string("hello world\n"); + + } +} // of package foo diff --git a/7LAB/lab6.l b/7LAB/lab9.l similarity index 100% rename from 7LAB/lab6.l rename to 7LAB/lab9.l diff --git a/7LAB/lab9.y b/7LAB/lab9.y new file mode 100644 index 0000000..2a438ed --- /dev/null +++ b/7LAB/lab9.y @@ -0,0 +1,800 @@ +/* +Ziad Arafat - Mar 8 2021 +Lab 5 +*/ + +%{ +#include +#include +#include + +#include "ast.h" +#include "symtable.h" + +int level = 0; // the level of the scope we are in. +int offset = 0; // Keeps track of fielddecl offset values +int goffset = 0; // keeps track of +int maxoffset; + +int yylex(); + +extern int yylineno; // import the yylineno variable +void yyerror (s) /* Called by yyparse on error */ + char *s; +{ + // changed these to output to stderr + fprintf(stderr, "%s ", s); + + // print out the line number of the syntax error. + fprintf(stderr, "Error on line: %d \n", yylineno); +} + +struct ASTnodetype *PROGRAM; + +%} +/* defines the start symbol, what values come back +from LEX and how the operators are associated */ +/* changed to P */ +%start Program + +/* Defines possible types */ +%union +{ + int value; + char* string; + struct ASTnodetype *astnode; + enum AST_Decaf_Types asttype; + enum AST_Operators operator; +} + + +// I commented out the tokens that aren't being used. + +// I also removed the token for T_LT because idk why one was a token and the +// other was a char?? + + +// Added a token for each of the lex tokens +%token T_AND +%token T_ASSIGN +%token T_BOOLTYPE +%token T_BREAK +/* %token T_CHARCONSTANT */ +%token T_CONTINUE +/* %token T_DOT */ +%token T_ELSE +%token T_EQ +%token T_EXTERN +%token T_FALSE +/* %token T_FOR */ +%token T_FUNC +%token T_GEQ +/* %token T_GT */ +%token T_ID +%token T_IF +%token T_INTCONSTANT +%token T_INTTYPE +%token T_LEFTSHIFT +%token T_LEQ +%token T_NEQ +/* %token T_NULL */ +%token T_OR +%token T_PACKAGE +%token T_RETURN +%token T_RIGHTSHIFT +%token T_STRINGCONSTANT +%token T_STRINGTYPE +%token T_TRUE +%token T_VAR +%token T_VOID +%token T_WHILE + +/* %token T_STRING_LIT +%token T_INT_LIT */ + +%type Externs ExternDefn FullExternParmList ExternParmList FieldDecl +%type FieldDecls ArrayType MethodDecl MethodDecls Block VarDecl +%type IdTypeList IdTypeList1 VarDecls Statement Statements ReturnStmt +%type Constant BoolConstant BreakStmt Additiveexpression Term +%type Factor Simpleexpression Expr Assign Lvalue IfStmt WhileStmt +%type MethodCall MethodArgs FullMethodArgs MethodArg ContinueStmt +%type MethodType Type ExternType +%type Multop Addop Relop + + +/* added all the rules from DECAF and reformatted them to work with Bison */ +/* for each of the rules with a list of tokens I created a recursive rule +that allows for one or more of the token. +*/ + +/* Replaced any instance of '=' with T_ASSIGN */ + +%% /* end specs, begin rules */ +Program: + // uhh I noticed package name was in the output but cooper literally said + // we don't wanna do that in the video so I just didn't lol. + Externs T_PACKAGE T_ID '{' FieldDecls MethodDecls '}' { + PROGRAM = ASTCreateNode(A_PROGRAM); + PROGRAM->S1 = $1; + PROGRAM->S2 = ASTCreateNode(A_PACKAGE); + PROGRAM->S2->name = $3; + PROGRAM->S2->S1 = $5; + PROGRAM->S2->S2 = $6; + }; + +Externs: + /* empty */ { $$ = NULL; } + | ExternDefn Externs { $1->next = $2; }; + +ExternDefn: + T_EXTERN T_FUNC T_ID '(' ExternParmList ')' MethodType ';' { + // we need to see if $3 has already been defined. + // if so => BARF + if (Search($3, level, 0) != NULL) { + yyerror("Symbol already deafined"); + yyerror($3); + exit(1); + } + $$ = ASTCreateNode(A_EXTERN); + $$->name = $3; + $$->A_Declared_Type = $7; + $$->size = 0; + $$->S1 = $5; // set the S1 to the list of params node + + // set our symbol to the return value of Insert() + $$->symbol = Insert($3,$7,ID_Sub_Type_Extern_Method, level, 0, 0, $5); + // offset++; + + // moved to main + Display(); // Display the table for debugging + }; + +ExternParmList: + /* empty */ { $$ = NULL; } + | FullExternParmList {$$ = $1;} ; + +FullExternParmList: + ExternType { + $$ = ASTCreateNode(A_ExternType); + $$->A_Declared_Type = $1; + } + | ExternType ',' ExternParmList { + $$ = ASTCreateNode(A_ExternType); + $$->A_Declared_Type = $1; + $$->next = $3; + }; + +FieldDecls: + /* empty */ {$$ = NULL;} + | FieldDecl FieldDecls { + $$ = $1; + $$->next = $2; + }; + +FieldDecl: + T_VAR T_ID Type ';' { + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; + $$->A_Declared_Type = $3; + $$->size = 1; // scalars are size 1 + + // insert the variable into the symtable + $$->symbol = Insert($2,$3,ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + } + | T_VAR T_ID ArrayType ';' { + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; + $$->S1 = $3; // set S1 to the ArrayType + $$->A_Declared_Type = $3->A_Declared_Type; // duplicate the type in the array + $$->size = $3->size; // Arrays are based on the ArrayType value + // insert the variable into the symtable + $$->symbol = Insert($2,$3->A_Declared_Type,ID_Sub_Type_Array, level, $$->size, offset, NULL); + offset += $3->size; // increment the offset by the size of the array. + } + | T_VAR T_ID Type T_ASSIGN Constant ';' { + // we do the same thing in here that we did for the one without the T_ASSIGN + + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; + $$->A_Declared_Type = $3; // set type to the Type output node + $$->size = 1; // this is still a scalar so we set size to 1. + $$->symbol = Insert($2,$3,ID_Sub_Type_Scalar, level,$$->size, offset, NULL); + offset++; // increment offset by 1 because it's a scalar. + $$->S2 = $5; // set S2 to the Constant node + + }; + +MethodDecls: + /* empty */ {$$ = NULL;} + | MethodDecl MethodDecls { + $$ = $1; + $$->next = $2; // set the next to the right recursive value + }; + +MethodDecl: + // set global offset to offset them reset our offset + // this way we resume global offsets and our offset is ready for next block + T_FUNC T_ID { goffset = offset; offset = 2; maxoffset = offset; } + '(' IdTypeList ')' MethodType + { Insert($2,$7,ID_Sub_Type_Method, level, 0, 0, $5); } Block { + + // increment anything greater than $2 by 1 for the new component + $$ = ASTCreateNode(A_METHODDEC); + $$->name = $2; + $$->A_Declared_Type = $7; + // $$->size = 1; changed to offset + $$->S1 = $5; // $5; + $$->S2 = $9; // $9; + $$->symbol = Search($2, level, 0); + $$->size = maxoffset; + $$->symbol->mysize = maxoffset; // max size needed to run program + offset = goffset; + }; + +IdTypeList: + /* empty */ { $$ = NULL; } + | IdTypeList1 { $$ = $1; }; + +IdTypeList1: + T_ID Type { + // Before we create the node let's check if the T_ID is used + if(Search ($1, level + 1, 0)!= NULL) { + yyerror("Duplicate method arg name"); + yyerror($1); + } + + $$ = ASTCreateNode(A_METHODID); + $$->name = $1; + $$->A_Declared_Type = $2; + $$->size = 1; + + $$->symbol=Insert($1,$2,ID_Sub_Type_Scalar, level+1, 1, offset, NULL); + offset++; // increment offset by 1 as per instructions + } + | T_ID Type ',' IdTypeList { + // Before we create the node let's check if the T_ID is used + + // check if there are duplicate args + if(Search ($1, level + 1, 0)!= NULL) { + yyerror("Duplicate method arg name"); + yyerror($1); + } + $$ = ASTCreateNode(A_METHODID); + $$->name = $1; + $$->A_Declared_Type = $2; + $$->size = 1; + + // we do level + 1 because the args are part of the block created by the method. + $$->symbol=Insert($1,$2,ID_Sub_Type_Scalar, level+1, 1, offset, NULL); + offset++; // increment offset by 1 as per instructions + $$->next = $4; + }; + +Block: + // increment level as soon as we open a block + '{' { level++; } VarDecls Statements '}' { + $$ = ASTCreateNode(A_BLOCK); + + // incremented these because added in-rule action + $$->S1 = $3; // set S1 to the VarDecls + $$->S2 = $4; // set S2 to the Statements + Display(); // Display here so we can see the symtab at each level + // if the offset is greater than the maxoffset of the method + // then we set the maxoffset to the offset to fix it's max value + if (offset > maxoffset) { + maxoffset = offset; + } + + // We delete all the symbols at the current level before leaving. + // this way they don't conflict with levels lower. + offset -= Delete(level); + + // decrement level since we finished the block + level--; + + }; + +VarDecls: + /* empty */ { $$ = NULL; } + | VarDecl VarDecls { + $$ = $1; + $$->next = $2; + }; + +VarDecl: + T_VAR T_ID Type ';' { + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + + // Create an A_VARDEC node + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; // set it's name to T_ID + $$->A_Declared_Type = $3; // set it's type to outpit of Type + + // insert the variable into the symtable + $$->symbol = Insert($2,$3,ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + // Display(); // debugging only + } + | T_VAR T_ID ArrayType ';' { + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; + $$->S1 = $3; // set S1 to the ArrayType node + $$->A_Declared_Type = $3->A_Declared_Type; + $$->size = $3->size; // set the size to the size of the ArrayType node + + // insert the variable into the symtable + $$->symbol = Insert($2,$3->A_Declared_Type, ID_Sub_Type_Array, level, $$->size, offset, NULL); + offset += $3->size; // increment offset by the size of the array. + }; + +Statements: + /* empty */ { $$ = NULL; } + | Statement Statements { + $$ = $1; + $$->next = $2; + }; + +/* Moved all of the Statement into one rule and moved each item into it's own +separate rule. + */ + /* Connected these all */ +Statement: + Block { $$ = $1; } + | Assign ';' { $$ = $1; } + | MethodCall ';' { $$ = $1; } + | IfStmt { $$ = $1; } + | WhileStmt { $$ = $1; } + | ReturnStmt { $$ = $1; } + | BreakStmt { $$ = $1; } + | ContinueStmt { $$ = $1; } + ; + +/* Created a continue statement idk if this was needed */ +ContinueStmt: T_CONTINUE ';' {$$ = ASTCreateNode(A_CONTINUE);}; + +WhileStmt: + T_WHILE '(' Expr ')' Block { + $$ = ASTCreateNode(A_WHILESTMT); + $$->S1 = $3; // set S1 to thje Expr + $$->S2 = $5; // Set S2 to the Block + }; + +BreakStmt: T_BREAK ';' { $$ = ASTCreateNode(A_BREAK); }; + +IfStmt: + T_IF '(' Expr ')' Block T_ELSE Block { + $$ = ASTCreateNode(A_IF); + $$->S1 = $3; // set S1 to the Expression node + $$->S2 = ASTCreateNode(A_IFBODY); // create a separate node for the body in S2 + $$->S2->S1 = $5; // set the S1 of the body to the block of the IF + $$->S2->S2 = ASTCreateNode(A_ELSE); // create a new node for the else statement after the body + + // set the S1 of the Else to the Else's Block + $$->S2->S2->S1 = $7; + } + | T_IF '(' Expr ')' Block { + $$ = ASTCreateNode(A_IF); + + // Set S1 to the Expression node + $$->S1 = $3; + $$->S2 = ASTCreateNode(A_IFBODY); // create a separate node for the body in S2 + $$->S2->S1 = $5; // set the S1 of the body to the block + $$->S2->S2 = NULL; // since we have no Else we set it's node to NULL this time + }; + +ReturnStmt: + T_RETURN ';' { $$ = ASTCreateNode(A_RETURN);} + | T_RETURN '(' ')' ';' { $$ = ASTCreateNode(A_RETURN);} + | T_RETURN '(' Expr ')' ';' { + $$ = ASTCreateNode(A_RETURN); + $$->S1 = $3; // set the S1 to the expression we returned + }; + +Assign: + Lvalue T_ASSIGN Expr { + + // make sure the left and right hand types are matching + if ( $1->A_Declared_Type != $3->A_Declared_Type) { + yyerror("Type mismatch on assignment"); + exit(1); + } + $$ = ASTCreateNode(A_ASSIGN); + $$->S1 = $1; // set the S1 to the left hand side + $$->S2 = $3; // set the S2 to the right hand side + }; + +/* Assigns: Assign + | Assign ',' Assigns + + ; */ + +Lvalue: + T_ID { + /* I am using A_VAR_RVALUE for both the LVALUE and RVALUE + Mostly because the node serves the same purpose. + */ + + /* well apparently that was wrong so I changed to a new + node type LVALUE which now has it's own case and enum + */ + + // grab the symbol from the table corresponding the T_ID + struct SymbTab *p; + p = Search($1, level, 1); + + // if we didn't find one lets barf because it wasnt defined + if(p == NULL) { + yyerror("Symbol on LVALUE not defined"); + yyerror($1); + exit(1); + } + + // Make sure the type is a scalar and not an array/method + if (p->SubType != ID_Sub_Type_Scalar){ + yyerror($1); + yyerror("needs to be a scalar, wrong subtype"); + exit(1); + } + + $$ = ASTCreateNode(A_VAR_LVALUE); + $$->name = $1; + $$->symbol = p; + $$->A_Declared_Type = p->Type; + } + | T_ID '[' Expr ']' { + struct SymbTab *p; + p = Search($1, level, 1); + + // if we didn't find one lets barf because it wasnt defined + if(p == NULL) { + yyerror("Symbol on LVALUE not defined"); + yyerror($1); + exit(1); + } + + // Make sure it's an array and not a Scalar/Method + if (p->SubType != ID_Sub_Type_Array){ + yyerror($1); + yyerror("needs to be an array, wrong subtype"); + exit(1); + } + $$ = ASTCreateNode(A_VAR_LVALUE); + $$->name = $1; + $$->S1 = $3; + $$->symbol = p; + $$->A_Declared_Type = p->Type; // the type is the same as the symbol we got it from + }; + + +MethodCall: + T_ID '(' MethodArgs ')' { + struct SymbTab *p; + p = Search($1, level, 1); + + // if we didn't find one lets barf because it wasnt defined + if(p == NULL) { + yyerror("Symbol on LVALUE not defined"); + yyerror($1); + exit(1); + } + + // Make sure it's a Method or Extern Method and not an Array/Scalar + if ((p->SubType != ID_Sub_Type_Method) && (p->SubType != ID_Sub_Type_Extern_Method)){ + yyerror($1); + yyerror("needs to be a method, wrong subtype"); + exit(1); + } + + // check that the formal params match the params of the method + // definition + + if (check_parameters(p->fparms, $3) == 0) { + yyerror("Formal and actual params do not match"); + yyerror($1); + exit(1); + } + + $$ = ASTCreateNode(A_METHODCALL); + $$->name = $1; + $$->S1 = $3; + $$->symbol = p; + $$->A_Declared_Type = p->Type; // type matches it's formal type + }; + +MethodArg: Expr { $$ = $1; }; + +MethodArgs: + /* empty */ { + $$ = NULL; + } + | FullMethodArgs { + $$ = $1; + }; + +FullMethodArgs: + MethodArg { + $$ = $1; + } + | MethodArg ',' MethodArgs { + $$ = $1; + $$->next = $3; + } + ; + + + + +/* Statement: T_FOR '(' Assigns ';' Expr ';' Assigns ')' Block + ; */ + + + + + +Expr: Simpleexpression { $$ = $1; }; + +Simpleexpression: + Additiveexpression { $$ = $1; } + | Simpleexpression Relop Additiveexpression { + + // make type of left is type of right + if (($1->A_Declared_Type != $3->A_Declared_Type)) { + yyerror("both sides need to be the same type"); + exit(1); + } + $$ = ASTCreateNode(A_EXPR); + $$->S1 = $1; // set S1 to left hand side + $$->operator = $2; // set the operator to return of Relop + $$->S2 = $3; // set S2 to the right hand side + $$->A_Declared_Type = $1->A_Declared_Type; // duplicate the type from one of the left or right (left) + $$->name = TEMP_CREATE(); // create a temporary symbol to hold value + $$->symbol = Insert($$->name,$$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // increment offset by 1 because of the temporary value being stored + offset++; + + }; + +Relop: + '<' { $$ = A_LT; } + | '>' { $$ = A_GT; } + | T_EQ { $$ = A_EQ; } + | T_LEQ { $$ = A_LEQ; } + | T_GEQ { $$ = A_GEQ; } + | T_NEQ { $$ = A_NEQ; }; + +Additiveexpression: + Term { $$ = $1; } + | Additiveexpression Addop Term { + if (($1->A_Declared_Type != $3->A_Declared_Type) || + (check_operators($2, $1->A_Declared_Type) == 0)) { + yyerror("addition and subtraction need INTs only"); + exit(1); + } + $$ = ASTCreateNode(A_EXPR); + $$->S1 = $1; + $$->operator = $2; + $$->S2 = $3; + $$->A_Declared_Type = A_Decaf_INT; + $$->name = TEMP_CREATE(); + $$->symbol = Insert($$->name,$$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + }; + +Addop: + '+' { $$ = A_PLUS; } + | '-' { $$ = A_MINUS; }; + +Term: + Factor { $$ = $1; } + | Term Multop Factor { + // check that left is equal to right + if ($1->A_Declared_Type != $3->A_Declared_Type) { + yyerror("type mismatch"); + exit(1); + } + + // use my check_operators() function to make sure the operator + // is compatible with the types + if (check_operators($2, $1->A_Declared_Type) == 0) { + if($1->A_Declared_Type == A_Decaf_BOOL) { + yyerror("Cannot use BOOL in INT operation"); + } else { + yyerror("Cannot use INT in BOOL operation"); + } + exit(1); + } + + $$ = ASTCreateNode(A_EXPR); + $$->S1 = $1; + $$->operator = $2; + $$->S2 = $3; + $$->name = TEMP_CREATE(); + $$->symbol = Insert($$->name,$$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + }; +/* added modulus as a multi operator */ +Multop: + '*' { $$ = A_TIMES; } + | '/' { $$ = A_DIVIDE; } + | '%' { $$ = A_MOD; } + | T_AND { $$ = A_AND; } + | T_OR { $$ = A_OR; } + | T_LEFTSHIFT { $$ = A_LEFTSHIFT; } + | T_RIGHTSHIFT { $$ = A_RIGHTSHIFT; }; + +Factor: + T_ID { + struct SymbTab *p; + p = Search($1, level, 1); + + if(p == NULL) { + yyerror("Symbol on LVALUE not defined"); + yyerror($1); + exit(1); + } + + if (p->SubType != ID_Sub_Type_Scalar){ + yyerror($1); + yyerror("needs to be an scalar, wrong subtype"); + exit(1); + } + $$ = ASTCreateNode(A_VAR_RVALUE); + $$->name = $1; + $$->symbol = p; + $$->A_Declared_Type = p->Type; + + } + | MethodCall { $$ = $1; } + | T_ID '[' Expr ']' { + struct SymbTab *p; + p = Search($1, level, 1); + if(p == NULL) { + yyerror("Symbol on RVALUE not defined"); + yyerror($1); + exit(1); + } + + if (p->SubType != ID_Sub_Type_Array){ + yyerror($1); + yyerror("needs to be an array, wrong subtype"); + exit(1); + } + + $$ = ASTCreateNode(A_VAR_RVALUE); + $$->name = $1; + $$->S1 = $3; + $$->symbol = p; + $$->A_Declared_Type = p->Type; + } + | Constant { $$ = $1; } + | '(' Expr ')' { $$ = $2; } + | '!' Factor { + + // check if our right is a bool + if ($2->A_Declared_Type != A_Decaf_BOOL) { + yyerror("Type mismatch, expected boolean"); + exit(1); + } + + $$ = ASTCreateNode(A_EXPR); + $$->operator = A_NOT; + $$->S1 = $2; + + // set type to boolean because !bool is a bool + $$->A_Declared_Type = A_Decaf_BOOL; + + $$->name = TEMP_CREATE(); + $$->symbol = Insert($$->name,A_Decaf_BOOL, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + } + + /* moved this around a lot until I got it working in here */ + | T_STRINGCONSTANT { + $$ = ASTCreateNode(A_CONSTANT_STRING); + $$->name = $1; + $$->A_Declared_Type = A_Decaf_STRING; + } + | '-' Factor { + // check if our right is an int + if ($2->A_Declared_Type != A_Decaf_INT) { + yyerror("Type mismatch, expected integer"); + exit(1); + } + $$ = ASTCreateNode(A_EXPR); + $$->operator = A_UMINUS; + $$->S1 = $2; + // set type to boolean because UMINUS is for numbers + $$->A_Declared_Type = A_Decaf_INT; + $$->name = TEMP_CREATE(); + $$->symbol = Insert($$->name,A_Decaf_BOOL, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + }; + + + + +ExternType: + T_STRINGTYPE { $$ = A_Decaf_STRING; } + | Type + ; + +Type: + T_INTTYPE { $$ = A_Decaf_INT; } + | T_BOOLTYPE{ $$ = A_Decaf_BOOL; }; + +MethodType: + T_VOID { $$ = A_Decaf_VOID; } + | Type { $$ = $1; }; + +BoolConstant: + T_TRUE { + $$ = ASTCreateNode(A_CONSTANT_BOOL); + $$->value = 1; + $$->A_Declared_Type = A_Decaf_BOOL; + } + | T_FALSE { + $$ = ASTCreateNode(A_CONSTANT_BOOL); + $$->value = 0; + $$->A_Declared_Type = A_Decaf_BOOL; + }; + +ArrayType: + '[' T_INTCONSTANT ']' Type { + $$ = ASTCreateNode(A_ARRAYTYPE); + $$->value = $2; + $$->A_Declared_Type = $4; + $$->size = $2; + // printf("THE SIZE IS %d %d", $2, $$->size);// debug + }; +/* added String and Char as constants */ +Constant: + T_INTCONSTANT { + $$ = ASTCreateNode(A_CONSTANT_INT); + $$->value = $1; + $$->A_Declared_Type = A_Decaf_INT; + } + + | BoolConstant { + $$ = $1; + }; +%% /* end of rules, start of program */ + +int main(){ + yyparse(); + printf("Parsing completed\n"); + Display(); // I noticed in cooper's output he Displays after the printf + // We know PROGRAM points to our AST + ASTprint(0, PROGRAM); + printf("Finished printing AST "); +} \ No newline at end of file diff --git a/7LAB/symtable.c b/7LAB/symtable.c index 08aaf58..6c9c5a7 100644 --- a/7LAB/symtable.c +++ b/7LAB/symtable.c @@ -13,96 +13,132 @@ We add a routine to remove variables at our level and above. */ +/* +Ziad Arafat - Apr 11 2021 +Lab 7 +*/ - #include #include "ast.h" #include "symtable.h" -struct SymbTab * first=NULL; - - +int GTEMP = 0; // one up number for creating temps +char *TEMP_CREATE() +{ + char s[100]; + sprintf(s, "_T%d", GTEMP); + GTEMP++; + return(strdup(s)); +} +struct SymbTab *first = NULL; /* Simple Insert into the symbol table with the size, type level that the name is being inserted into */ -struct SymbTab * Insert(char *name, enum AST_Decaf_Types Type, enum ID_Sub_Type subtype , int level, int mysize, int offset , ASTnode * fparms) +struct SymbTab *Insert(char *name, enum AST_Decaf_Types Type, + enum ID_Sub_Type subtype, int level, int mysize, + int offset, ASTnode *fparms) { - struct SymbTab * n; - n=Search(name,level, 0); - if(n!=NULL) - { - printf("\n\tThe name %s exists at level %d already in the symbol table\n\tDuplicate can.t be inserted",name, level); - return (NULL); - } - else - { - struct SymbTab *p; - p=malloc(sizeof(struct SymbTab)); - p->name=name; - p->offset=offset; /* assign the offset */ - p->level=level; /* assign the level */ - p->mysize=mysize; /* assign the size */ - p->Type=Type; /* assign the Type */ - p->SubType=subtype; /* assign the Function */ - p->fparms=fparms; /* assign the Method parameter list */ - p->next=NULL; + struct SymbTab *n; + n = Search(name, level, 0); + if (n != NULL) { + printf("\n\tThe name %s exists at level %d already in the symbol table\n\tDuplicate can.t be inserted", + name, level); + return (NULL); + } else { + struct SymbTab *p; + p = malloc(sizeof(struct SymbTab)); + p->name = name; + p->offset = offset; /* assign the offset */ + p->level = level; /* assign the level */ + p->mysize = mysize; /* assign the size */ + p->Type = Type; /* assign the Type */ + p->SubType = subtype; /* assign the Function */ + p->fparms = fparms; /* assign the Method parameter list */ + p->next = NULL; - /* Check on how many elements we have in the symbol table */ - if(first==NULL) - { - first=p; - } - else - { - p->next=first; - first=p; - } - return (p); - - } - - printf("\n\tLabel inserted\n"); + /* Check on how many elements we have in the symbol table */ + if (first == NULL) { + first = p; + } else { + p->next = first; + first = p; + } + return (p); + } + + printf("\n\tLabel inserted\n"); } /* print out a single symbol table entry -- for debugging */ void PrintSym(struct SymbTab *s) { - char *string,*display_type; - switch(s->SubType) { - case ID_Sub_Type_Scalar: string = "Scalar " ; break; - //MISSING - default: string ="Unknown subtype in print symbol"; - } - switch(s->Type) { - case A_Decaf_INT: display_type = "INT " ; break; - //MISSING - default: string ="Unknown Declared TYPE in print symbol"; - } - - printf("\t%s\t\t%d\t%d\t%s\t%s\n",s->name,s->offset, s->level,display_type,string); + char *string, *display_type; + display_type = " "; + switch (s->SubType) { + case ID_Sub_Type_Scalar: + string = "Scalar "; + break; + case ID_Sub_Type_Method: + string = "Method "; + break; + case ID_Sub_Type_Extern_Method: + string = "Extern Method "; + break; + case ID_Sub_Type_Array: + string = "Array "; + break; + // case ID_Sub_Type_Void: + // string = "Void "; // OOps this is not a thing + // break; + default: + string = "Unknown subtype in print symbol"; + } + switch (s->Type) { + case A_Decaf_INT: + display_type = "INT "; + break; + case A_Decaf_BOOL: + display_type = "BOOL "; + break; + case A_Decaf_VOID: + display_type = "VOID "; + break; + default: + string = "Unknown Declared TYPE in print symbol"; + } + // changed this to use the c space formatting so it always looks pretty. + printf("%-12s%-7d%-7d%-7d%-10s%-10s\n", s->name, s->offset, s->mysize, + s->level, display_type, string); + // printf("%-12s%-7d%-7d%-10s%-10s\n", s->name, s->offset, + // s->level, display_type, string); } - /* General display to see what is our symbol table */ - void Display() { - int i; - struct SymbTab *p; - p=first; - printf("\n\tLABEL\t\tOffset\tLEVEL\ttype\tsubtype\n"); - while (p!=NULL) - { - PrintSym(p); - p=p->next; - } + int i; + struct SymbTab *p; + p = first; + // printf("\n\tLABEL\t\tOffset\tLEVEL\ttype\tsubtype\n"); + // changed this to use the c space formatting so it always looks pretty. + printf("%-12s%-7s%-7s%-7s%-10s%-10s\n", "LABEL", "OFFSET", "SIZE", + "LEVEL", "TYPE", "SUBTYPE"); + + // printf("%-12s%-7s%-7s%-10s%-10s\n", "LABEL", "OFFSET", + // "LEVEL", "TYPE", "SUBTYPE"); + + while (p != NULL) { + PrintSym(p); + p = p->next; + } + printf("\n"); } /* Search for a symbol name at level or below. We have to do multiple passes into the symbol table because we have to find @@ -112,67 +148,56 @@ void Display() If recur is non-zero, then we look through all of the levels, otherwise, only our level We return a pointer to a SymbolTab structure so that we can use other functions/methods to get the attributes */ - - - -struct SymbTab * Search(char name[], int level, int recur) +struct SymbTab *Search(char name[], int level, int recur) { - int i,flag=0; - struct SymbTab *p; + int i, flag = 0; + struct SymbTab *p; - /* for each level, try to find our symbol */ - while (level >= 0) - { - p=first; - while (p!=NULL) - { - if((strcmp(p->name,name)==0) && (p->level == level)) - return p; - p=p->next; - } - if (recur == 0) return (NULL); /* we did not find it at our level */ - level--; /* check the next level up */ - } + /* for each level, try to find our symbol */ + while (level >= 0) { + p = first; + while (p != NULL) { + if ((strcmp(p->name, name) == 0) && (p->level == level)) + return p; + p = p->next; + } + if (recur == 0) + return (NULL); /* we did not find it at our level */ + level--; /* check the next level up */ + } - - return NULL; /* did not find it, return 0 */ + return NULL; /* did not find it, return 0 */ } /* Remove all enteries that have the indicated level We need to take care about updating first pointer into the linked list when we are deleting edge elements */ - int Delete(int level) { - struct SymbTab *p,*f=NULL; /* we follow with pointer f */ - int SIZE=0; - p=first; + struct SymbTab *p, *f = NULL; /* we follow with pointer f */ + int SIZE = 0; + p = first; - - - /* cruise through the list */ + /* cruise through the list */ - while (p != NULL) - { - /* do we match? */ - if (p->level>= level ) - { /* if it is the first in the list we have to update first, we know this by f being NULL */ - SIZE+=p->mysize; - if ( f==NULL) first=p->next; - else /* not the first element */ - {f->next=p->next; - } - p=p->next; - - } - else - { - /* update follow pointer, move the p pointer */ - f=p; - p=p->next; - } + while (p != NULL) { + /* do we match? */ + if (p->level >= + level) { /* if it is the first in the list we have to update first, we know this by f being NULL */ + SIZE += p->mysize; + if (f == NULL) + first = p->next; + else /* not the first element */ + { + f->next = p->next; + } + p = p->next; - } - return(SIZE); + } else { + /* update follow pointer, move the p pointer */ + f = p; + p = p->next; + } + } + return (SIZE); } - diff --git a/7LAB/symtable.h b/7LAB/symtable.h index 6b8e632..1c32cad 100644 --- a/7LAB/symtable.h +++ b/7LAB/symtable.h @@ -1,53 +1,67 @@ /* Symbol Table --linked list headers Used for Compilers class - Modified Spring 2015 to allow for name to pointed to by symtable, instead of copied, since the name is copied - into the heap + Modified Spring 2015 to allow for name to pointed to by symtable, instead + of copied, since the name is copied into the heap - Modified to have levels. A level 0 means global variable, other levels means in range of the function. We - start out our offsets at 0 (from stack pointer) for level 1,,,when we enter a functional declaration. - We increment offset each time we insert a new variable. A variable is considered to be valid if it is found in - the symbol table at our level or lesser level. If at 0, then it is global. + Modified to have levels. A level 0 means global variable, other levels + means in range of the function. We start out our + offsets at 0 (from stack pointer) for level 1,,,when we enter a functional + declaration. - We return a pointer to the symbol table when a variable matches our creteria. + We increment offset each time we insert a new variable. A variable is + considered to be valid if it is found in the symbol table at our level or + lesser level. If at 0, then it is global. + + We return a pointer to the symbol table + when a variable matches our creteria. We add a routine to remove variables at our level and above. */ - +/* +Ziad Arafat - Apr 11 2021 +Lab 7 +*/ #include "ast.h" -#ifndef _SYMTAB +#ifndef _SYMTAB #define _SYMTAB + +char *TEMP_CREATE(); + void Display(); int Delete(int level); -int FetchAddr (char *lab); +int FetchAddr(char *lab); // The types an ID can have enum ID_Sub_Type { - ID_Sub_Type_Scalar - // missing + ID_Sub_Type_Scalar, + ID_Sub_Type_Method, + ID_Sub_Type_Extern_Method, + ID_Sub_Type_Array, + // ID_Sub_Type_Void // OOps this is not a thing }; -struct SymbTab -{ - char *name; - int offset; /* from activation record boundary */ - int mysize; /* number of words this item is 1 or more */ - int level; /* the level where we found the variable */ - enum AST_Decaf_Types Type; /* the type of the symbol */ - enum ID_Sub_Type SubType; /* the element is a function */ - ASTnode * fparms; /* pointer to parameters of the function in the AST */ +struct SymbTab { + char *name; + int offset; /* from activation record boundary */ + int mysize; /* number of words this item is 1 or more */ + int level; /* the level where we found the variable */ + enum AST_Decaf_Types Type; /* the type of the symbol */ + enum ID_Sub_Type SubType; /* the element is a function */ + ASTnode *fparms; /* pointer to parameters of the function in the AST */ - struct SymbTab *next; + struct SymbTab *next; }; +struct SymbTab *Insert(char *name, enum AST_Decaf_Types Type, + enum ID_Sub_Type subtype, int level, int mysize, + int offset, ASTnode *fparms); -struct SymbTab * Insert(char *name, enum AST_Decaf_Types Type, enum ID_Sub_Type subtype, int level, int mysize, int offset, ASTnode * fparms ); - -struct SymbTab * Search(char name[], int level, int recur); +struct SymbTab *Search(char name[], int level, int recur); #endif diff --git a/7LAB/testinput.decaf b/7LAB/testinput.decaf index dc3547c..b1b44de 100644 --- a/7LAB/testinput.decaf +++ b/7LAB/testinput.decaf @@ -1,29 +1,59 @@ -extern func print_int (int) int; +// extern func print_int (int) void; +// extern func print_string (string) void; + +// package foo { +// var y int =7; +// var Z[100] int; +// var Y[100] bool; +// var z int = 10; + +// func f(b int) int +// { +// var y int; +// { var x[10] int; +// x[2+3-5]=b + f(5+x[2]*b); +// } +// { var x[10] int; +// x[2+3-5]=b + f(5+x[2]*b); +// } +// } + + +// func main(arg1 int, arg2 int) int +// { +// print_int( f(arg1 + arg2 -z + y)); +// print_int( f(arg1 + arg2 -z + y)); +// print_string("hello world\n"); + +// } +// } // of package foo + +extern func print_int (int) void; +extern func print_string (string) void; package foo { - var x int = 3; - var Y bool = true; - var A [100] int; - func foo (x int, y bool) int { - var x int ; - var A[100] bool; - break; - x = y + z[A]; - x = true; - y = false; - if ( x> y) { x = 3+ 4;} - else - { x = y;} - return; - return(); - return( x << y >> z); - while (true != false) - { x = 3 && 2; - print_string("hello world"); - x = f( g ( ! (x && y || z))); - } + var y int =7; + var Z[100] int; + var Y[100] bool; + var z int = 10; + + func f(b int) int + { + var y int; + { var x[10] int; + x[2+3-5]=b + f(5+x[2]*b); + } + { var x[10] int; + x[2+3-5]=b + f(5+x[2]*b); + } + } - } + func main(arg1 int, arg2 int) int + { + print_int( f(arg1 + arg2 -z + y)); + print_int( f(arg1 + arg2 -z + y)); + print_string("hello world\n"); -} // end of foo \ No newline at end of file + } +} // of package foo \ No newline at end of file diff --git a/7LAB/y.output b/7LAB/y.output index a80db20..d829ded 100644 --- a/7LAB/y.output +++ b/7LAB/y.output @@ -25,166 +25,172 @@ Grammar 14 MethodDecls: %empty 15 | MethodDecl MethodDecls - 16 MethodDecl: T_FUNC T_ID '(' IdTypeList ')' MethodType Block + 16 $@1: %empty - 17 IdTypeList: %empty - 18 | IdTypeList1 + 17 $@2: %empty - 19 IdTypeList1: T_ID Type - 20 | T_ID Type ',' IdTypeList + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' MethodType $@2 Block - 21 Block: '{' VarDecls Statements '}' + 19 IdTypeList: %empty + 20 | IdTypeList1 - 22 VarDecls: %empty - 23 | VarDecl VarDecls + 21 IdTypeList1: T_ID Type + 22 | T_ID Type ',' IdTypeList - 24 VarDecl: T_VAR T_ID Type ';' - 25 | T_VAR T_ID ArrayType ';' + 23 $@3: %empty - 26 Statements: %empty - 27 | Statement Statements + 24 Block: '{' $@3 VarDecls Statements '}' - 28 Statement: Block - 29 | Assign ';' - 30 | MethodCall ';' - 31 | IfStmt - 32 | WhileStmt - 33 | ReturnStmt - 34 | BreakStmt - 35 | ContinueStmt + 25 VarDecls: %empty + 26 | VarDecl VarDecls - 36 ContinueStmt: T_CONTINUE ';' + 27 VarDecl: T_VAR T_ID Type ';' + 28 | T_VAR T_ID ArrayType ';' - 37 WhileStmt: T_WHILE '(' Expr ')' Block + 29 Statements: %empty + 30 | Statement Statements - 38 BreakStmt: T_BREAK ';' + 31 Statement: Block + 32 | Assign ';' + 33 | MethodCall ';' + 34 | IfStmt + 35 | WhileStmt + 36 | ReturnStmt + 37 | BreakStmt + 38 | ContinueStmt - 39 IfStmt: T_IF '(' Expr ')' Block T_ELSE Block - 40 | T_IF '(' Expr ')' Block + 39 ContinueStmt: T_CONTINUE ';' - 41 ReturnStmt: T_RETURN ';' - 42 | T_RETURN '(' ')' ';' - 43 | T_RETURN '(' Expr ')' ';' + 40 WhileStmt: T_WHILE '(' Expr ')' Block - 44 Assign: Lvalue T_ASSIGN Expr + 41 BreakStmt: T_BREAK ';' - 45 Lvalue: T_ID - 46 | T_ID '[' Expr ']' + 42 IfStmt: T_IF '(' Expr ')' Block T_ELSE Block + 43 | T_IF '(' Expr ')' Block - 47 MethodCall: T_ID '(' MethodArgs ')' + 44 ReturnStmt: T_RETURN ';' + 45 | T_RETURN '(' ')' ';' + 46 | T_RETURN '(' Expr ')' ';' - 48 MethodArg: Expr + 47 Assign: Lvalue T_ASSIGN Expr - 49 MethodArgs: %empty - 50 | FullMethodArgs + 48 Lvalue: T_ID + 49 | T_ID '[' Expr ']' - 51 FullMethodArgs: MethodArg - 52 | MethodArg ',' MethodArgs + 50 MethodCall: T_ID '(' MethodArgs ')' - 53 Expr: Simpleexpression + 51 MethodArg: Expr - 54 Simpleexpression: Additiveexpression - 55 | Simpleexpression Relop Additiveexpression + 52 MethodArgs: %empty + 53 | FullMethodArgs - 56 Relop: '<' - 57 | '>' - 58 | T_EQ - 59 | T_LEQ - 60 | T_GEQ - 61 | T_NEQ + 54 FullMethodArgs: MethodArg + 55 | MethodArg ',' MethodArgs - 62 Additiveexpression: Term - 63 | Additiveexpression Addop Term + 56 Expr: Simpleexpression - 64 Addop: '+' - 65 | '-' + 57 Simpleexpression: Additiveexpression + 58 | Simpleexpression Relop Additiveexpression - 66 Term: Factor - 67 | Term Multop Factor + 59 Relop: '<' + 60 | '>' + 61 | T_EQ + 62 | T_LEQ + 63 | T_GEQ + 64 | T_NEQ - 68 Multop: '*' - 69 | '/' - 70 | '%' - 71 | T_AND - 72 | T_OR - 73 | T_LEFTSHIFT - 74 | T_RIGHTSHIFT + 65 Additiveexpression: Term + 66 | Additiveexpression Addop Term - 75 Factor: T_ID - 76 | MethodCall - 77 | T_ID '[' Expr ']' - 78 | Constant - 79 | '(' Expr ')' - 80 | '!' Factor - 81 | T_STRINGCONSTANT - 82 | '-' Factor + 67 Addop: '+' + 68 | '-' - 83 ExternType: T_STRINGTYPE - 84 | Type + 69 Term: Factor + 70 | Term Multop Factor - 85 Type: T_INTTYPE - 86 | T_BOOLTYPE + 71 Multop: '*' + 72 | '/' + 73 | '%' + 74 | T_AND + 75 | T_OR + 76 | T_LEFTSHIFT + 77 | T_RIGHTSHIFT - 87 MethodType: T_VOID - 88 | Type + 78 Factor: T_ID + 79 | MethodCall + 80 | T_ID '[' Expr ']' + 81 | Constant + 82 | '(' Expr ')' + 83 | '!' Factor + 84 | T_STRINGCONSTANT + 85 | '-' Factor - 89 BoolConstant: T_TRUE - 90 | T_FALSE + 86 ExternType: T_STRINGTYPE + 87 | Type - 91 ArrayType: '[' T_INTCONSTANT ']' Type + 88 Type: T_INTTYPE + 89 | T_BOOLTYPE - 92 Constant: T_INTCONSTANT - 93 | BoolConstant + 90 MethodType: T_VOID + 91 | Type + + 92 BoolConstant: T_TRUE + 93 | T_FALSE + + 94 ArrayType: '[' T_INTCONSTANT ']' Type + + 95 Constant: T_INTCONSTANT + 96 | BoolConstant Terminals, with rules where they appear $end (0) 0 -'!' (33) 80 -'%' (37) 70 -'(' (40) 4 16 37 39 40 42 43 47 79 -')' (41) 4 16 37 39 40 42 43 47 79 -'*' (42) 68 -'+' (43) 64 -',' (44) 8 20 52 -'-' (45) 65 82 -'/' (47) 69 -';' (59) 4 11 12 13 24 25 29 30 36 38 41 42 43 -'<' (60) 56 -'>' (62) 57 -'[' (91) 46 77 91 -']' (93) 46 77 91 -'{' (123) 1 21 -'}' (125) 1 21 +'!' (33) 83 +'%' (37) 73 +'(' (40) 4 18 40 42 43 45 46 50 82 +')' (41) 4 18 40 42 43 45 46 50 82 +'*' (42) 71 +'+' (43) 67 +',' (44) 8 22 55 +'-' (45) 68 85 +'/' (47) 72 +';' (59) 4 11 12 13 27 28 32 33 39 41 44 45 46 +'<' (60) 59 +'>' (62) 60 +'[' (91) 49 80 94 +']' (93) 49 80 94 +'{' (123) 1 24 +'}' (125) 1 24 error (256) -T_AND (258) 71 -T_ASSIGN (259) 13 44 -T_BOOLTYPE (260) 86 -T_BREAK (261) 38 -T_CONTINUE (262) 36 -T_ELSE (263) 39 -T_EQ (264) 58 +T_AND (258) 74 +T_ASSIGN (259) 13 47 +T_BOOLTYPE (260) 89 +T_BREAK (261) 41 +T_CONTINUE (262) 39 +T_ELSE (263) 42 +T_EQ (264) 61 T_EXTERN (265) 4 -T_FALSE (266) 90 -T_FUNC (267) 4 16 -T_GEQ (268) 60 -T_ID (269) 1 4 11 12 13 16 19 20 24 25 45 46 47 75 77 -T_IF (270) 39 40 -T_INTCONSTANT (271) 91 92 -T_INTTYPE (272) 85 -T_LEFTSHIFT (273) 73 -T_LEQ (274) 59 -T_NEQ (275) 61 -T_OR (276) 72 +T_FALSE (266) 93 +T_FUNC (267) 4 18 +T_GEQ (268) 63 +T_ID (269) 1 4 11 12 13 18 21 22 27 28 48 49 50 78 80 +T_IF (270) 42 43 +T_INTCONSTANT (271) 94 95 +T_INTTYPE (272) 88 +T_LEFTSHIFT (273) 76 +T_LEQ (274) 62 +T_NEQ (275) 64 +T_OR (276) 75 T_PACKAGE (277) 1 -T_RETURN (278) 41 42 43 -T_RIGHTSHIFT (279) 74 -T_STRINGCONSTANT (280) 81 -T_STRINGTYPE (281) 83 -T_TRUE (282) 89 -T_VAR (283) 11 12 13 24 25 -T_VOID (284) 87 -T_WHILE (285) 37 +T_RETURN (278) 44 45 46 +T_RIGHTSHIFT (279) 77 +T_STRINGCONSTANT (280) 84 +T_STRINGTYPE (281) 86 +T_TRUE (282) 92 +T_VAR (283) 11 12 13 27 28 +T_VOID (284) 90 +T_WHILE (285) 40 Nonterminals, with rules where they appear @@ -208,71 +214,77 @@ FieldDecl (54) MethodDecls (55) on left: 14 15, on right: 1 15 MethodDecl (56) - on left: 16, on right: 15 -IdTypeList (57) - on left: 17 18, on right: 16 20 -IdTypeList1 (58) - on left: 19 20, on right: 18 -Block (59) - on left: 21, on right: 16 28 37 39 40 -VarDecls (60) - on left: 22 23, on right: 21 23 -VarDecl (61) - on left: 24 25, on right: 23 -Statements (62) - on left: 26 27, on right: 21 27 -Statement (63) - on left: 28 29 30 31 32 33 34 35, on right: 27 -ContinueStmt (64) - on left: 36, on right: 35 -WhileStmt (65) - on left: 37, on right: 32 -BreakStmt (66) - on left: 38, on right: 34 -IfStmt (67) - on left: 39 40, on right: 31 -ReturnStmt (68) - on left: 41 42 43, on right: 33 -Assign (69) - on left: 44, on right: 29 -Lvalue (70) - on left: 45 46, on right: 44 -MethodCall (71) - on left: 47, on right: 30 76 -MethodArg (72) - on left: 48, on right: 51 52 -MethodArgs (73) - on left: 49 50, on right: 47 52 -FullMethodArgs (74) - on left: 51 52, on right: 50 -Expr (75) - on left: 53, on right: 37 39 40 43 44 46 48 77 79 -Simpleexpression (76) - on left: 54 55, on right: 53 55 -Relop (77) - on left: 56 57 58 59 60 61, on right: 55 -Additiveexpression (78) - on left: 62 63, on right: 54 55 63 -Addop (79) - on left: 64 65, on right: 63 -Term (80) - on left: 66 67, on right: 62 63 67 -Multop (81) - on left: 68 69 70 71 72 73 74, on right: 67 -Factor (82) - on left: 75 76 77 78 79 80 81 82, on right: 66 67 80 82 -ExternType (83) - on left: 83 84, on right: 7 8 -Type (84) - on left: 85 86, on right: 11 13 19 20 24 84 88 91 -MethodType (85) - on left: 87 88, on right: 4 16 -BoolConstant (86) - on left: 89 90, on right: 93 -ArrayType (87) - on left: 91, on right: 12 25 -Constant (88) - on left: 92 93, on right: 13 78 + on left: 18, on right: 15 +$@1 (57) + on left: 16, on right: 18 +$@2 (58) + on left: 17, on right: 18 +IdTypeList (59) + on left: 19 20, on right: 18 22 +IdTypeList1 (60) + on left: 21 22, on right: 20 +Block (61) + on left: 24, on right: 18 31 40 42 43 +$@3 (62) + on left: 23, on right: 24 +VarDecls (63) + on left: 25 26, on right: 24 26 +VarDecl (64) + on left: 27 28, on right: 26 +Statements (65) + on left: 29 30, on right: 24 30 +Statement (66) + on left: 31 32 33 34 35 36 37 38, on right: 30 +ContinueStmt (67) + on left: 39, on right: 38 +WhileStmt (68) + on left: 40, on right: 35 +BreakStmt (69) + on left: 41, on right: 37 +IfStmt (70) + on left: 42 43, on right: 34 +ReturnStmt (71) + on left: 44 45 46, on right: 36 +Assign (72) + on left: 47, on right: 32 +Lvalue (73) + on left: 48 49, on right: 47 +MethodCall (74) + on left: 50, on right: 33 79 +MethodArg (75) + on left: 51, on right: 54 55 +MethodArgs (76) + on left: 52 53, on right: 50 55 +FullMethodArgs (77) + on left: 54 55, on right: 53 +Expr (78) + on left: 56, on right: 40 42 43 46 47 49 51 80 82 +Simpleexpression (79) + on left: 57 58, on right: 56 58 +Relop (80) + on left: 59 60 61 62 63 64, on right: 58 +Additiveexpression (81) + on left: 65 66, on right: 57 58 66 +Addop (82) + on left: 67 68, on right: 66 +Term (83) + on left: 69 70, on right: 65 66 70 +Multop (84) + on left: 71 72 73 74 75 76 77, on right: 70 +Factor (85) + on left: 78 79 80 81 82 83 84 85, on right: 69 70 83 85 +ExternType (86) + on left: 86 87, on right: 7 8 +Type (87) + on left: 88 89, on right: 11 13 21 22 27 87 91 94 +MethodType (88) + on left: 90 91, on right: 4 18 +BoolConstant (89) + on left: 92 93, on right: 96 +ArrayType (90) + on left: 94, on right: 12 28 +Constant (91) + on left: 95 96, on right: 13 81 State 0 @@ -393,23 +405,23 @@ State 12 State 13 - 86 Type: T_BOOLTYPE . + 89 Type: T_BOOLTYPE . - $default reduce using rule 86 (Type) + $default reduce using rule 89 (Type) State 14 - 85 Type: T_INTTYPE . + 88 Type: T_INTTYPE . - $default reduce using rule 85 (Type) + $default reduce using rule 88 (Type) State 15 - 83 ExternType: T_STRINGTYPE . + 86 ExternType: T_STRINGTYPE . - $default reduce using rule 83 (ExternType) + $default reduce using rule 86 (ExternType) State 16 @@ -438,9 +450,9 @@ State 18 State 19 - 84 ExternType: Type . + 87 ExternType: Type . - $default reduce using rule 84 (ExternType) + $default reduce using rule 87 (ExternType) State 20 @@ -520,7 +532,7 @@ State 25 State 26 - 16 MethodDecl: T_FUNC . T_ID '(' IdTypeList ')' MethodType Block + 18 MethodDecl: T_FUNC . T_ID $@1 '(' IdTypeList ')' MethodType $@2 Block T_ID shift, and go to state 37 @@ -553,16 +565,16 @@ State 29 State 30 - 87 MethodType: T_VOID . + 90 MethodType: T_VOID . - $default reduce using rule 87 (MethodType) + $default reduce using rule 90 (MethodType) State 31 - 88 MethodType: Type . + 91 MethodType: Type . - $default reduce using rule 88 (MethodType) + $default reduce using rule 91 (MethodType) State 32 @@ -581,7 +593,7 @@ State 33 State 34 - 91 ArrayType: '[' . T_INTCONSTANT ']' Type + 94 ArrayType: '[' . T_INTCONSTANT ']' Type T_INTCONSTANT shift, and go to state 41 @@ -604,9 +616,11 @@ State 36 State 37 - 16 MethodDecl: T_FUNC T_ID . '(' IdTypeList ')' MethodType Block + 18 MethodDecl: T_FUNC T_ID . $@1 '(' IdTypeList ')' MethodType $@2 Block - '(' shift, and go to state 45 + $default reduce using rule 16 ($@1) + + $@1 go to state 45 State 38 @@ -632,7 +646,7 @@ State 40 State 41 - 91 ArrayType: '[' T_INTCONSTANT . ']' Type + 94 ArrayType: '[' T_INTCONSTANT . ']' Type ']' shift, and go to state 46 @@ -665,1215 +679,1240 @@ State 44 State 45 - 16 MethodDecl: T_FUNC T_ID '(' . IdTypeList ')' MethodType Block + 18 MethodDecl: T_FUNC T_ID $@1 . '(' IdTypeList ')' MethodType $@2 Block - T_ID shift, and go to state 52 - - $default reduce using rule 17 (IdTypeList) - - IdTypeList go to state 53 - IdTypeList1 go to state 54 + '(' shift, and go to state 52 State 46 - 91 ArrayType: '[' T_INTCONSTANT ']' . Type + 94 ArrayType: '[' T_INTCONSTANT ']' . Type T_BOOLTYPE shift, and go to state 13 T_INTTYPE shift, and go to state 14 - Type go to state 55 + Type go to state 53 State 47 - 90 BoolConstant: T_FALSE . + 93 BoolConstant: T_FALSE . - $default reduce using rule 90 (BoolConstant) + $default reduce using rule 93 (BoolConstant) State 48 - 92 Constant: T_INTCONSTANT . + 95 Constant: T_INTCONSTANT . - $default reduce using rule 92 (Constant) + $default reduce using rule 95 (Constant) State 49 - 89 BoolConstant: T_TRUE . + 92 BoolConstant: T_TRUE . - $default reduce using rule 89 (BoolConstant) + $default reduce using rule 92 (BoolConstant) State 50 - 93 Constant: BoolConstant . + 96 Constant: BoolConstant . - $default reduce using rule 93 (Constant) + $default reduce using rule 96 (Constant) State 51 13 FieldDecl: T_VAR T_ID Type T_ASSIGN Constant . ';' - ';' shift, and go to state 56 + ';' shift, and go to state 54 State 52 - 19 IdTypeList1: T_ID . Type - 20 | T_ID . Type ',' IdTypeList + 18 MethodDecl: T_FUNC T_ID $@1 '(' . IdTypeList ')' MethodType $@2 Block - T_BOOLTYPE shift, and go to state 13 - T_INTTYPE shift, and go to state 14 + T_ID shift, and go to state 55 - Type go to state 57 + $default reduce using rule 19 (IdTypeList) + + IdTypeList go to state 56 + IdTypeList1 go to state 57 State 53 - 16 MethodDecl: T_FUNC T_ID '(' IdTypeList . ')' MethodType Block + 94 ArrayType: '[' T_INTCONSTANT ']' Type . - ')' shift, and go to state 58 + $default reduce using rule 94 (ArrayType) State 54 - 18 IdTypeList: IdTypeList1 . - - $default reduce using rule 18 (IdTypeList) - - -State 55 - - 91 ArrayType: '[' T_INTCONSTANT ']' Type . - - $default reduce using rule 91 (ArrayType) - - -State 56 - 13 FieldDecl: T_VAR T_ID Type T_ASSIGN Constant ';' . $default reduce using rule 13 (FieldDecl) +State 55 + + 21 IdTypeList1: T_ID . Type + 22 | T_ID . Type ',' IdTypeList + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + + Type go to state 58 + + +State 56 + + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList . ')' MethodType $@2 Block + + ')' shift, and go to state 59 + + State 57 - 19 IdTypeList1: T_ID Type . - 20 | T_ID Type . ',' IdTypeList + 20 IdTypeList: IdTypeList1 . - ',' shift, and go to state 59 - - $default reduce using rule 19 (IdTypeList1) + $default reduce using rule 20 (IdTypeList) State 58 - 16 MethodDecl: T_FUNC T_ID '(' IdTypeList ')' . MethodType Block + 21 IdTypeList1: T_ID Type . + 22 | T_ID Type . ',' IdTypeList + + ',' shift, and go to state 60 + + $default reduce using rule 21 (IdTypeList1) + + +State 59 + + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' . MethodType $@2 Block T_BOOLTYPE shift, and go to state 13 T_INTTYPE shift, and go to state 14 T_VOID shift, and go to state 30 Type go to state 31 - MethodType go to state 60 - - -State 59 - - 20 IdTypeList1: T_ID Type ',' . IdTypeList - - T_ID shift, and go to state 52 - - $default reduce using rule 17 (IdTypeList) - - IdTypeList go to state 61 - IdTypeList1 go to state 54 + MethodType go to state 61 State 60 - 16 MethodDecl: T_FUNC T_ID '(' IdTypeList ')' MethodType . Block + 22 IdTypeList1: T_ID Type ',' . IdTypeList - '{' shift, and go to state 62 + T_ID shift, and go to state 55 - Block go to state 63 + $default reduce using rule 19 (IdTypeList) + + IdTypeList go to state 62 + IdTypeList1 go to state 57 State 61 - 20 IdTypeList1: T_ID Type ',' IdTypeList . + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' MethodType . $@2 Block - $default reduce using rule 20 (IdTypeList1) + $default reduce using rule 17 ($@2) + + $@2 go to state 63 State 62 - 21 Block: '{' . VarDecls Statements '}' + 22 IdTypeList1: T_ID Type ',' IdTypeList . - T_VAR shift, and go to state 64 - - $default reduce using rule 22 (VarDecls) - - VarDecls go to state 65 - VarDecl go to state 66 + $default reduce using rule 22 (IdTypeList1) State 63 - 16 MethodDecl: T_FUNC T_ID '(' IdTypeList ')' MethodType Block . + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' MethodType $@2 . Block - $default reduce using rule 16 (MethodDecl) + '{' shift, and go to state 64 + + Block go to state 65 State 64 - 24 VarDecl: T_VAR . T_ID Type ';' - 25 | T_VAR . T_ID ArrayType ';' + 24 Block: '{' . $@3 VarDecls Statements '}' - T_ID shift, and go to state 67 + $default reduce using rule 23 ($@3) + + $@3 go to state 66 State 65 - 21 Block: '{' VarDecls . Statements '}' + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' MethodType $@2 Block . - T_BREAK shift, and go to state 68 - T_CONTINUE shift, and go to state 69 - T_ID shift, and go to state 70 - T_IF shift, and go to state 71 - T_RETURN shift, and go to state 72 - T_WHILE shift, and go to state 73 - '{' shift, and go to state 62 - - $default reduce using rule 26 (Statements) - - Block go to state 74 - Statements go to state 75 - Statement go to state 76 - ContinueStmt go to state 77 - WhileStmt go to state 78 - BreakStmt go to state 79 - IfStmt go to state 80 - ReturnStmt go to state 81 - Assign go to state 82 - Lvalue go to state 83 - MethodCall go to state 84 + $default reduce using rule 18 (MethodDecl) State 66 - 23 VarDecls: VarDecl . VarDecls + 24 Block: '{' $@3 . VarDecls Statements '}' - T_VAR shift, and go to state 64 + T_VAR shift, and go to state 67 - $default reduce using rule 22 (VarDecls) + $default reduce using rule 25 (VarDecls) - VarDecls go to state 85 - VarDecl go to state 66 + VarDecls go to state 68 + VarDecl go to state 69 State 67 - 24 VarDecl: T_VAR T_ID . Type ';' - 25 | T_VAR T_ID . ArrayType ';' + 27 VarDecl: T_VAR . T_ID Type ';' + 28 | T_VAR . T_ID ArrayType ';' + + T_ID shift, and go to state 70 + + +State 68 + + 24 Block: '{' $@3 VarDecls . Statements '}' + + T_BREAK shift, and go to state 71 + T_CONTINUE shift, and go to state 72 + T_ID shift, and go to state 73 + T_IF shift, and go to state 74 + T_RETURN shift, and go to state 75 + T_WHILE shift, and go to state 76 + '{' shift, and go to state 64 + + $default reduce using rule 29 (Statements) + + Block go to state 77 + Statements go to state 78 + Statement go to state 79 + ContinueStmt go to state 80 + WhileStmt go to state 81 + BreakStmt go to state 82 + IfStmt go to state 83 + ReturnStmt go to state 84 + Assign go to state 85 + Lvalue go to state 86 + MethodCall go to state 87 + + +State 69 + + 26 VarDecls: VarDecl . VarDecls + + T_VAR shift, and go to state 67 + + $default reduce using rule 25 (VarDecls) + + VarDecls go to state 88 + VarDecl go to state 69 + + +State 70 + + 27 VarDecl: T_VAR T_ID . Type ';' + 28 | T_VAR T_ID . ArrayType ';' T_BOOLTYPE shift, and go to state 13 T_INTTYPE shift, and go to state 14 '[' shift, and go to state 34 - Type go to state 86 - ArrayType go to state 87 - - -State 68 - - 38 BreakStmt: T_BREAK . ';' - - ';' shift, and go to state 88 - - -State 69 - - 36 ContinueStmt: T_CONTINUE . ';' - - ';' shift, and go to state 89 - - -State 70 - - 45 Lvalue: T_ID . - 46 | T_ID . '[' Expr ']' - 47 MethodCall: T_ID . '(' MethodArgs ')' - - '(' shift, and go to state 90 - '[' shift, and go to state 91 - - $default reduce using rule 45 (Lvalue) + Type go to state 89 + ArrayType go to state 90 State 71 - 39 IfStmt: T_IF . '(' Expr ')' Block T_ELSE Block - 40 | T_IF . '(' Expr ')' Block + 41 BreakStmt: T_BREAK . ';' - '(' shift, and go to state 92 + ';' shift, and go to state 91 State 72 - 41 ReturnStmt: T_RETURN . ';' - 42 | T_RETURN . '(' ')' ';' - 43 | T_RETURN . '(' Expr ')' ';' + 39 ContinueStmt: T_CONTINUE . ';' - '(' shift, and go to state 93 - ';' shift, and go to state 94 + ';' shift, and go to state 92 State 73 - 37 WhileStmt: T_WHILE . '(' Expr ')' Block + 48 Lvalue: T_ID . + 49 | T_ID . '[' Expr ']' + 50 MethodCall: T_ID . '(' MethodArgs ')' - '(' shift, and go to state 95 + '(' shift, and go to state 93 + '[' shift, and go to state 94 + + $default reduce using rule 48 (Lvalue) State 74 - 28 Statement: Block . + 42 IfStmt: T_IF . '(' Expr ')' Block T_ELSE Block + 43 | T_IF . '(' Expr ')' Block - $default reduce using rule 28 (Statement) + '(' shift, and go to state 95 State 75 - 21 Block: '{' VarDecls Statements . '}' + 44 ReturnStmt: T_RETURN . ';' + 45 | T_RETURN . '(' ')' ';' + 46 | T_RETURN . '(' Expr ')' ';' - '}' shift, and go to state 96 + '(' shift, and go to state 96 + ';' shift, and go to state 97 State 76 - 27 Statements: Statement . Statements + 40 WhileStmt: T_WHILE . '(' Expr ')' Block - T_BREAK shift, and go to state 68 - T_CONTINUE shift, and go to state 69 - T_ID shift, and go to state 70 - T_IF shift, and go to state 71 - T_RETURN shift, and go to state 72 - T_WHILE shift, and go to state 73 - '{' shift, and go to state 62 - - $default reduce using rule 26 (Statements) - - Block go to state 74 - Statements go to state 97 - Statement go to state 76 - ContinueStmt go to state 77 - WhileStmt go to state 78 - BreakStmt go to state 79 - IfStmt go to state 80 - ReturnStmt go to state 81 - Assign go to state 82 - Lvalue go to state 83 - MethodCall go to state 84 + '(' shift, and go to state 98 State 77 - 35 Statement: ContinueStmt . - - $default reduce using rule 35 (Statement) - - -State 78 - - 32 Statement: WhileStmt . - - $default reduce using rule 32 (Statement) - - -State 79 - - 34 Statement: BreakStmt . - - $default reduce using rule 34 (Statement) - - -State 80 - - 31 Statement: IfStmt . + 31 Statement: Block . $default reduce using rule 31 (Statement) +State 78 + + 24 Block: '{' $@3 VarDecls Statements . '}' + + '}' shift, and go to state 99 + + +State 79 + + 30 Statements: Statement . Statements + + T_BREAK shift, and go to state 71 + T_CONTINUE shift, and go to state 72 + T_ID shift, and go to state 73 + T_IF shift, and go to state 74 + T_RETURN shift, and go to state 75 + T_WHILE shift, and go to state 76 + '{' shift, and go to state 64 + + $default reduce using rule 29 (Statements) + + Block go to state 77 + Statements go to state 100 + Statement go to state 79 + ContinueStmt go to state 80 + WhileStmt go to state 81 + BreakStmt go to state 82 + IfStmt go to state 83 + ReturnStmt go to state 84 + Assign go to state 85 + Lvalue go to state 86 + MethodCall go to state 87 + + +State 80 + + 38 Statement: ContinueStmt . + + $default reduce using rule 38 (Statement) + + State 81 - 33 Statement: ReturnStmt . + 35 Statement: WhileStmt . - $default reduce using rule 33 (Statement) + $default reduce using rule 35 (Statement) State 82 - 29 Statement: Assign . ';' + 37 Statement: BreakStmt . - ';' shift, and go to state 98 + $default reduce using rule 37 (Statement) State 83 - 44 Assign: Lvalue . T_ASSIGN Expr + 34 Statement: IfStmt . - T_ASSIGN shift, and go to state 99 + $default reduce using rule 34 (Statement) State 84 - 30 Statement: MethodCall . ';' + 36 Statement: ReturnStmt . - ';' shift, and go to state 100 + $default reduce using rule 36 (Statement) State 85 - 23 VarDecls: VarDecl VarDecls . - - $default reduce using rule 23 (VarDecls) - - -State 86 - - 24 VarDecl: T_VAR T_ID Type . ';' + 32 Statement: Assign . ';' ';' shift, and go to state 101 +State 86 + + 47 Assign: Lvalue . T_ASSIGN Expr + + T_ASSIGN shift, and go to state 102 + + State 87 - 25 VarDecl: T_VAR T_ID ArrayType . ';' + 33 Statement: MethodCall . ';' - ';' shift, and go to state 102 + ';' shift, and go to state 103 State 88 - 38 BreakStmt: T_BREAK ';' . + 26 VarDecls: VarDecl VarDecls . - $default reduce using rule 38 (BreakStmt) + $default reduce using rule 26 (VarDecls) State 89 - 36 ContinueStmt: T_CONTINUE ';' . + 27 VarDecl: T_VAR T_ID Type . ';' - $default reduce using rule 36 (ContinueStmt) + ';' shift, and go to state 104 State 90 - 47 MethodCall: T_ID '(' . MethodArgs ')' + 28 VarDecl: T_VAR T_ID ArrayType . ';' - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - $default reduce using rule 49 (MethodArgs) - - MethodCall go to state 108 - MethodArg go to state 109 - MethodArgs go to state 110 - FullMethodArgs go to state 111 - Expr go to state 112 - Simpleexpression go to state 113 - Additiveexpression go to state 114 - Term go to state 115 - Factor go to state 116 - BoolConstant go to state 50 - Constant go to state 117 + ';' shift, and go to state 105 State 91 - 46 Lvalue: T_ID '[' . Expr ']' + 41 BreakStmt: T_BREAK ';' . - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - MethodCall go to state 108 - Expr go to state 118 - Simpleexpression go to state 113 - Additiveexpression go to state 114 - Term go to state 115 - Factor go to state 116 - BoolConstant go to state 50 - Constant go to state 117 + $default reduce using rule 41 (BreakStmt) State 92 - 39 IfStmt: T_IF '(' . Expr ')' Block T_ELSE Block - 40 | T_IF '(' . Expr ')' Block + 39 ContinueStmt: T_CONTINUE ';' . - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - MethodCall go to state 108 - Expr go to state 119 - Simpleexpression go to state 113 - Additiveexpression go to state 114 - Term go to state 115 - Factor go to state 116 - BoolConstant go to state 50 - Constant go to state 117 + $default reduce using rule 39 (ContinueStmt) State 93 - 42 ReturnStmt: T_RETURN '(' . ')' ';' - 43 | T_RETURN '(' . Expr ')' ';' + 50 MethodCall: T_ID '(' . MethodArgs ')' T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 + T_ID shift, and go to state 106 T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 + T_STRINGCONSTANT shift, and go to state 107 T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - ')' shift, and go to state 120 - '-' shift, and go to state 106 - '!' shift, and go to state 107 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 - MethodCall go to state 108 - Expr go to state 121 - Simpleexpression go to state 113 - Additiveexpression go to state 114 - Term go to state 115 - Factor go to state 116 + $default reduce using rule 52 (MethodArgs) + + MethodCall go to state 111 + MethodArg go to state 112 + MethodArgs go to state 113 + FullMethodArgs go to state 114 + Expr go to state 115 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 BoolConstant go to state 50 - Constant go to state 117 + Constant go to state 120 State 94 - 41 ReturnStmt: T_RETURN ';' . + 49 Lvalue: T_ID '[' . Expr ']' - $default reduce using rule 41 (ReturnStmt) + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 121 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 State 95 - 37 WhileStmt: T_WHILE '(' . Expr ')' Block + 42 IfStmt: T_IF '(' . Expr ')' Block T_ELSE Block + 43 | T_IF '(' . Expr ')' Block T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 + T_ID shift, and go to state 106 T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 + T_STRINGCONSTANT shift, and go to state 107 T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 - MethodCall go to state 108 + MethodCall go to state 111 Expr go to state 122 - Simpleexpression go to state 113 - Additiveexpression go to state 114 - Term go to state 115 - Factor go to state 116 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 BoolConstant go to state 50 - Constant go to state 117 + Constant go to state 120 State 96 - 21 Block: '{' VarDecls Statements '}' . + 45 ReturnStmt: T_RETURN '(' . ')' ';' + 46 | T_RETURN '(' . Expr ')' ';' - $default reduce using rule 21 (Block) + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + ')' shift, and go to state 123 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 124 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 State 97 - 27 Statements: Statement Statements . + 44 ReturnStmt: T_RETURN ';' . - $default reduce using rule 27 (Statements) + $default reduce using rule 44 (ReturnStmt) State 98 - 29 Statement: Assign ';' . + 40 WhileStmt: T_WHILE '(' . Expr ')' Block - $default reduce using rule 29 (Statement) + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 125 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 State 99 - 44 Assign: Lvalue T_ASSIGN . Expr + 24 Block: '{' $@3 VarDecls Statements '}' . - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - MethodCall go to state 108 - Expr go to state 123 - Simpleexpression go to state 113 - Additiveexpression go to state 114 - Term go to state 115 - Factor go to state 116 - BoolConstant go to state 50 - Constant go to state 117 + $default reduce using rule 24 (Block) State 100 - 30 Statement: MethodCall ';' . + 30 Statements: Statement Statements . - $default reduce using rule 30 (Statement) + $default reduce using rule 30 (Statements) State 101 - 24 VarDecl: T_VAR T_ID Type ';' . + 32 Statement: Assign ';' . - $default reduce using rule 24 (VarDecl) + $default reduce using rule 32 (Statement) State 102 - 25 VarDecl: T_VAR T_ID ArrayType ';' . + 47 Assign: Lvalue T_ASSIGN . Expr - $default reduce using rule 25 (VarDecl) + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 126 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 State 103 - 47 MethodCall: T_ID . '(' MethodArgs ')' - 75 Factor: T_ID . - 77 | T_ID . '[' Expr ']' + 33 Statement: MethodCall ';' . - '(' shift, and go to state 90 - '[' shift, and go to state 124 - - $default reduce using rule 75 (Factor) + $default reduce using rule 33 (Statement) State 104 - 81 Factor: T_STRINGCONSTANT . + 27 VarDecl: T_VAR T_ID Type ';' . - $default reduce using rule 81 (Factor) + $default reduce using rule 27 (VarDecl) State 105 - 79 Factor: '(' . Expr ')' + 28 VarDecl: T_VAR T_ID ArrayType ';' . - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - MethodCall go to state 108 - Expr go to state 125 - Simpleexpression go to state 113 - Additiveexpression go to state 114 - Term go to state 115 - Factor go to state 116 - BoolConstant go to state 50 - Constant go to state 117 + $default reduce using rule 28 (VarDecl) State 106 - 82 Factor: '-' . Factor + 50 MethodCall: T_ID . '(' MethodArgs ')' + 78 Factor: T_ID . + 80 | T_ID . '[' Expr ']' - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - MethodCall go to state 108 - Factor go to state 126 - BoolConstant go to state 50 - Constant go to state 117 - - -State 107 - - 80 Factor: '!' . Factor - - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - MethodCall go to state 108 - Factor go to state 127 - BoolConstant go to state 50 - Constant go to state 117 - - -State 108 - - 76 Factor: MethodCall . - - $default reduce using rule 76 (Factor) - - -State 109 - - 51 FullMethodArgs: MethodArg . - 52 | MethodArg . ',' MethodArgs - - ',' shift, and go to state 128 - - $default reduce using rule 51 (FullMethodArgs) - - -State 110 - - 47 MethodCall: T_ID '(' MethodArgs . ')' - - ')' shift, and go to state 129 - - -State 111 - - 50 MethodArgs: FullMethodArgs . - - $default reduce using rule 50 (MethodArgs) - - -State 112 - - 48 MethodArg: Expr . - - $default reduce using rule 48 (MethodArg) - - -State 113 - - 53 Expr: Simpleexpression . - 55 Simpleexpression: Simpleexpression . Relop Additiveexpression - - T_EQ shift, and go to state 130 - T_GEQ shift, and go to state 131 - T_LEQ shift, and go to state 132 - T_NEQ shift, and go to state 133 - '<' shift, and go to state 134 - '>' shift, and go to state 135 - - $default reduce using rule 53 (Expr) - - Relop go to state 136 - - -State 114 - - 54 Simpleexpression: Additiveexpression . - 63 Additiveexpression: Additiveexpression . Addop Term - - '+' shift, and go to state 137 - '-' shift, and go to state 138 - - $default reduce using rule 54 (Simpleexpression) - - Addop go to state 139 - - -State 115 - - 62 Additiveexpression: Term . - 67 Term: Term . Multop Factor - - T_AND shift, and go to state 140 - T_LEFTSHIFT shift, and go to state 141 - T_OR shift, and go to state 142 - T_RIGHTSHIFT shift, and go to state 143 - '*' shift, and go to state 144 - '/' shift, and go to state 145 - '%' shift, and go to state 146 - - $default reduce using rule 62 (Additiveexpression) - - Multop go to state 147 - - -State 116 - - 66 Term: Factor . - - $default reduce using rule 66 (Term) - - -State 117 - - 78 Factor: Constant . + '(' shift, and go to state 93 + '[' shift, and go to state 127 $default reduce using rule 78 (Factor) +State 107 + + 84 Factor: T_STRINGCONSTANT . + + $default reduce using rule 84 (Factor) + + +State 108 + + 82 Factor: '(' . Expr ')' + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 128 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 109 + + 85 Factor: '-' . Factor + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Factor go to state 129 + BoolConstant go to state 50 + Constant go to state 120 + + +State 110 + + 83 Factor: '!' . Factor + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Factor go to state 130 + BoolConstant go to state 50 + Constant go to state 120 + + +State 111 + + 79 Factor: MethodCall . + + $default reduce using rule 79 (Factor) + + +State 112 + + 54 FullMethodArgs: MethodArg . + 55 | MethodArg . ',' MethodArgs + + ',' shift, and go to state 131 + + $default reduce using rule 54 (FullMethodArgs) + + +State 113 + + 50 MethodCall: T_ID '(' MethodArgs . ')' + + ')' shift, and go to state 132 + + +State 114 + + 53 MethodArgs: FullMethodArgs . + + $default reduce using rule 53 (MethodArgs) + + +State 115 + + 51 MethodArg: Expr . + + $default reduce using rule 51 (MethodArg) + + +State 116 + + 56 Expr: Simpleexpression . + 58 Simpleexpression: Simpleexpression . Relop Additiveexpression + + T_EQ shift, and go to state 133 + T_GEQ shift, and go to state 134 + T_LEQ shift, and go to state 135 + T_NEQ shift, and go to state 136 + '<' shift, and go to state 137 + '>' shift, and go to state 138 + + $default reduce using rule 56 (Expr) + + Relop go to state 139 + + +State 117 + + 57 Simpleexpression: Additiveexpression . + 66 Additiveexpression: Additiveexpression . Addop Term + + '+' shift, and go to state 140 + '-' shift, and go to state 141 + + $default reduce using rule 57 (Simpleexpression) + + Addop go to state 142 + + State 118 - 46 Lvalue: T_ID '[' Expr . ']' + 65 Additiveexpression: Term . + 70 Term: Term . Multop Factor - ']' shift, and go to state 148 + T_AND shift, and go to state 143 + T_LEFTSHIFT shift, and go to state 144 + T_OR shift, and go to state 145 + T_RIGHTSHIFT shift, and go to state 146 + '*' shift, and go to state 147 + '/' shift, and go to state 148 + '%' shift, and go to state 149 + + $default reduce using rule 65 (Additiveexpression) + + Multop go to state 150 State 119 - 39 IfStmt: T_IF '(' Expr . ')' Block T_ELSE Block - 40 | T_IF '(' Expr . ')' Block + 69 Term: Factor . - ')' shift, and go to state 149 + $default reduce using rule 69 (Term) State 120 - 42 ReturnStmt: T_RETURN '(' ')' . ';' + 81 Factor: Constant . - ';' shift, and go to state 150 + $default reduce using rule 81 (Factor) State 121 - 43 ReturnStmt: T_RETURN '(' Expr . ')' ';' + 49 Lvalue: T_ID '[' Expr . ']' - ')' shift, and go to state 151 + ']' shift, and go to state 151 State 122 - 37 WhileStmt: T_WHILE '(' Expr . ')' Block + 42 IfStmt: T_IF '(' Expr . ')' Block T_ELSE Block + 43 | T_IF '(' Expr . ')' Block ')' shift, and go to state 152 State 123 - 44 Assign: Lvalue T_ASSIGN Expr . + 45 ReturnStmt: T_RETURN '(' ')' . ';' - $default reduce using rule 44 (Assign) + ';' shift, and go to state 153 State 124 - 77 Factor: T_ID '[' . Expr ']' - - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - MethodCall go to state 108 - Expr go to state 153 - Simpleexpression go to state 113 - Additiveexpression go to state 114 - Term go to state 115 - Factor go to state 116 - BoolConstant go to state 50 - Constant go to state 117 - - -State 125 - - 79 Factor: '(' Expr . ')' + 46 ReturnStmt: T_RETURN '(' Expr . ')' ';' ')' shift, and go to state 154 +State 125 + + 40 WhileStmt: T_WHILE '(' Expr . ')' Block + + ')' shift, and go to state 155 + + State 126 - 82 Factor: '-' Factor . + 47 Assign: Lvalue T_ASSIGN Expr . - $default reduce using rule 82 (Factor) + $default reduce using rule 47 (Assign) State 127 - 80 Factor: '!' Factor . + 80 Factor: T_ID '[' . Expr ']' - $default reduce using rule 80 (Factor) + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 156 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 State 128 - 52 FullMethodArgs: MethodArg ',' . MethodArgs + 82 Factor: '(' Expr . ')' - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - $default reduce using rule 49 (MethodArgs) - - MethodCall go to state 108 - MethodArg go to state 109 - MethodArgs go to state 155 - FullMethodArgs go to state 111 - Expr go to state 112 - Simpleexpression go to state 113 - Additiveexpression go to state 114 - Term go to state 115 - Factor go to state 116 - BoolConstant go to state 50 - Constant go to state 117 + ')' shift, and go to state 157 State 129 - 47 MethodCall: T_ID '(' MethodArgs ')' . + 85 Factor: '-' Factor . - $default reduce using rule 47 (MethodCall) + $default reduce using rule 85 (Factor) State 130 - 58 Relop: T_EQ . + 83 Factor: '!' Factor . - $default reduce using rule 58 (Relop) + $default reduce using rule 83 (Factor) State 131 - 60 Relop: T_GEQ . + 55 FullMethodArgs: MethodArg ',' . MethodArgs - $default reduce using rule 60 (Relop) + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + $default reduce using rule 52 (MethodArgs) + + MethodCall go to state 111 + MethodArg go to state 112 + MethodArgs go to state 158 + FullMethodArgs go to state 114 + Expr go to state 115 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 State 132 - 59 Relop: T_LEQ . + 50 MethodCall: T_ID '(' MethodArgs ')' . - $default reduce using rule 59 (Relop) + $default reduce using rule 50 (MethodCall) State 133 - 61 Relop: T_NEQ . + 61 Relop: T_EQ . $default reduce using rule 61 (Relop) State 134 - 56 Relop: '<' . + 63 Relop: T_GEQ . - $default reduce using rule 56 (Relop) + $default reduce using rule 63 (Relop) State 135 - 57 Relop: '>' . + 62 Relop: T_LEQ . - $default reduce using rule 57 (Relop) + $default reduce using rule 62 (Relop) State 136 - 55 Simpleexpression: Simpleexpression Relop . Additiveexpression + 64 Relop: T_NEQ . - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - MethodCall go to state 108 - Additiveexpression go to state 156 - Term go to state 115 - Factor go to state 116 - BoolConstant go to state 50 - Constant go to state 117 + $default reduce using rule 64 (Relop) State 137 - 64 Addop: '+' . + 59 Relop: '<' . - $default reduce using rule 64 (Addop) + $default reduce using rule 59 (Relop) State 138 - 65 Addop: '-' . + 60 Relop: '>' . - $default reduce using rule 65 (Addop) + $default reduce using rule 60 (Relop) State 139 - 63 Additiveexpression: Additiveexpression Addop . Term + 58 Simpleexpression: Simpleexpression Relop . Additiveexpression T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 + T_ID shift, and go to state 106 T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 + T_STRINGCONSTANT shift, and go to state 107 T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 - MethodCall go to state 108 - Term go to state 157 - Factor go to state 116 - BoolConstant go to state 50 - Constant go to state 117 + MethodCall go to state 111 + Additiveexpression go to state 159 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 State 140 - 71 Multop: T_AND . + 67 Addop: '+' . - $default reduce using rule 71 (Multop) + $default reduce using rule 67 (Addop) State 141 - 73 Multop: T_LEFTSHIFT . + 68 Addop: '-' . - $default reduce using rule 73 (Multop) + $default reduce using rule 68 (Addop) State 142 - 72 Multop: T_OR . + 66 Additiveexpression: Additiveexpression Addop . Term - $default reduce using rule 72 (Multop) + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Term go to state 160 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 State 143 - 74 Multop: T_RIGHTSHIFT . + 74 Multop: T_AND . $default reduce using rule 74 (Multop) State 144 - 68 Multop: '*' . + 76 Multop: T_LEFTSHIFT . - $default reduce using rule 68 (Multop) + $default reduce using rule 76 (Multop) State 145 - 69 Multop: '/' . + 75 Multop: T_OR . - $default reduce using rule 69 (Multop) + $default reduce using rule 75 (Multop) State 146 - 70 Multop: '%' . + 77 Multop: T_RIGHTSHIFT . - $default reduce using rule 70 (Multop) + $default reduce using rule 77 (Multop) State 147 - 67 Term: Term Multop . Factor + 71 Multop: '*' . - T_FALSE shift, and go to state 47 - T_ID shift, and go to state 103 - T_INTCONSTANT shift, and go to state 48 - T_STRINGCONSTANT shift, and go to state 104 - T_TRUE shift, and go to state 49 - '(' shift, and go to state 105 - '-' shift, and go to state 106 - '!' shift, and go to state 107 - - MethodCall go to state 108 - Factor go to state 158 - BoolConstant go to state 50 - Constant go to state 117 + $default reduce using rule 71 (Multop) State 148 - 46 Lvalue: T_ID '[' Expr ']' . + 72 Multop: '/' . - $default reduce using rule 46 (Lvalue) + $default reduce using rule 72 (Multop) State 149 - 39 IfStmt: T_IF '(' Expr ')' . Block T_ELSE Block - 40 | T_IF '(' Expr ')' . Block + 73 Multop: '%' . - '{' shift, and go to state 62 - - Block go to state 159 + $default reduce using rule 73 (Multop) State 150 - 42 ReturnStmt: T_RETURN '(' ')' ';' . + 70 Term: Term Multop . Factor - $default reduce using rule 42 (ReturnStmt) + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Factor go to state 161 + BoolConstant go to state 50 + Constant go to state 120 State 151 - 43 ReturnStmt: T_RETURN '(' Expr ')' . ';' + 49 Lvalue: T_ID '[' Expr ']' . - ';' shift, and go to state 160 + $default reduce using rule 49 (Lvalue) State 152 - 37 WhileStmt: T_WHILE '(' Expr ')' . Block + 42 IfStmt: T_IF '(' Expr ')' . Block T_ELSE Block + 43 | T_IF '(' Expr ')' . Block - '{' shift, and go to state 62 + '{' shift, and go to state 64 - Block go to state 161 + Block go to state 162 State 153 - 77 Factor: T_ID '[' Expr . ']' + 45 ReturnStmt: T_RETURN '(' ')' ';' . - ']' shift, and go to state 162 + $default reduce using rule 45 (ReturnStmt) State 154 - 79 Factor: '(' Expr ')' . + 46 ReturnStmt: T_RETURN '(' Expr ')' . ';' - $default reduce using rule 79 (Factor) + ';' shift, and go to state 163 State 155 - 52 FullMethodArgs: MethodArg ',' MethodArgs . + 40 WhileStmt: T_WHILE '(' Expr ')' . Block - $default reduce using rule 52 (FullMethodArgs) - - -State 156 - - 55 Simpleexpression: Simpleexpression Relop Additiveexpression . - 63 Additiveexpression: Additiveexpression . Addop Term - - '+' shift, and go to state 137 - '-' shift, and go to state 138 - - $default reduce using rule 55 (Simpleexpression) - - Addop go to state 139 - - -State 157 - - 63 Additiveexpression: Additiveexpression Addop Term . - 67 Term: Term . Multop Factor - - T_AND shift, and go to state 140 - T_LEFTSHIFT shift, and go to state 141 - T_OR shift, and go to state 142 - T_RIGHTSHIFT shift, and go to state 143 - '*' shift, and go to state 144 - '/' shift, and go to state 145 - '%' shift, and go to state 146 - - $default reduce using rule 63 (Additiveexpression) - - Multop go to state 147 - - -State 158 - - 67 Term: Term Multop Factor . - - $default reduce using rule 67 (Term) - - -State 159 - - 39 IfStmt: T_IF '(' Expr ')' Block . T_ELSE Block - 40 | T_IF '(' Expr ')' Block . - - T_ELSE shift, and go to state 163 - - $default reduce using rule 40 (IfStmt) - - -State 160 - - 43 ReturnStmt: T_RETURN '(' Expr ')' ';' . - - $default reduce using rule 43 (ReturnStmt) - - -State 161 - - 37 WhileStmt: T_WHILE '(' Expr ')' Block . - - $default reduce using rule 37 (WhileStmt) - - -State 162 - - 77 Factor: T_ID '[' Expr ']' . - - $default reduce using rule 77 (Factor) - - -State 163 - - 39 IfStmt: T_IF '(' Expr ')' Block T_ELSE . Block - - '{' shift, and go to state 62 + '{' shift, and go to state 64 Block go to state 164 +State 156 + + 80 Factor: T_ID '[' Expr . ']' + + ']' shift, and go to state 165 + + +State 157 + + 82 Factor: '(' Expr ')' . + + $default reduce using rule 82 (Factor) + + +State 158 + + 55 FullMethodArgs: MethodArg ',' MethodArgs . + + $default reduce using rule 55 (FullMethodArgs) + + +State 159 + + 58 Simpleexpression: Simpleexpression Relop Additiveexpression . + 66 Additiveexpression: Additiveexpression . Addop Term + + '+' shift, and go to state 140 + '-' shift, and go to state 141 + + $default reduce using rule 58 (Simpleexpression) + + Addop go to state 142 + + +State 160 + + 66 Additiveexpression: Additiveexpression Addop Term . + 70 Term: Term . Multop Factor + + T_AND shift, and go to state 143 + T_LEFTSHIFT shift, and go to state 144 + T_OR shift, and go to state 145 + T_RIGHTSHIFT shift, and go to state 146 + '*' shift, and go to state 147 + '/' shift, and go to state 148 + '%' shift, and go to state 149 + + $default reduce using rule 66 (Additiveexpression) + + Multop go to state 150 + + +State 161 + + 70 Term: Term Multop Factor . + + $default reduce using rule 70 (Term) + + +State 162 + + 42 IfStmt: T_IF '(' Expr ')' Block . T_ELSE Block + 43 | T_IF '(' Expr ')' Block . + + T_ELSE shift, and go to state 166 + + $default reduce using rule 43 (IfStmt) + + +State 163 + + 46 ReturnStmt: T_RETURN '(' Expr ')' ';' . + + $default reduce using rule 46 (ReturnStmt) + + State 164 - 39 IfStmt: T_IF '(' Expr ')' Block T_ELSE Block . + 40 WhileStmt: T_WHILE '(' Expr ')' Block . - $default reduce using rule 39 (IfStmt) + $default reduce using rule 40 (WhileStmt) + + +State 165 + + 80 Factor: T_ID '[' Expr ']' . + + $default reduce using rule 80 (Factor) + + +State 166 + + 42 IfStmt: T_IF '(' Expr ')' Block T_ELSE . Block + + '{' shift, and go to state 64 + + Block go to state 167 + + +State 167 + + 42 IfStmt: T_IF '(' Expr ')' Block T_ELSE Block . + + $default reduce using rule 42 (IfStmt) diff --git a/7LAB/ziadoutput.txt b/7LAB/ziadoutput.txt new file mode 100644 index 0000000..4066c6d --- /dev/null +++ b/7LAB/ziadoutput.txt @@ -0,0 +1,191 @@ +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +print_int 0 0 0 VOID Extern Method + +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +_T4 18 1 2 INT Scalar +_T3 17 1 2 INT Scalar +_T2 16 1 2 INT Scalar +_T1 15 1 2 INT Scalar +_T0 14 1 2 INT Scalar +x 4 10 2 INT Array +y 3 1 1 INT Scalar +f 0 0 0 INT Method +b 2 1 1 INT Scalar +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +_T9 18 1 2 INT Scalar +_T8 17 1 2 INT Scalar +_T7 16 1 2 INT Scalar +_T6 15 1 2 INT Scalar +_T5 14 1 2 INT Scalar +x 4 10 2 INT Array +y 3 1 1 INT Scalar +f 0 0 0 INT Method +b 2 1 1 INT Scalar +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +y 3 1 1 INT Scalar +f 0 0 0 INT Method +b 2 1 1 INT Scalar +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +_T15 9 1 1 INT Scalar +_T14 8 1 1 INT Scalar +_T13 7 1 1 INT Scalar +_T12 6 1 1 INT Scalar +_T11 5 1 1 INT Scalar +_T10 4 1 1 INT Scalar +main 0 0 0 INT Method +arg1 3 1 1 INT Scalar +arg2 2 1 1 INT Scalar +f 0 19 0 INT Method +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + +Parsing completed +LABEL OFFSET SIZE LEVEL TYPE SUBTYPE +main 0 10 0 INT Method +f 0 19 0 INT Method +z 201 1 0 INT Scalar +Y 101 100 0 BOOL Array +Z 1 100 0 INT Array +y 0 1 0 INT Scalar +print_string0 0 0 VOID Extern Method +print_int 0 0 0 VOID Extern Method + + EXTERN FUNC print_int + EXTERN Type INT +END EXTERN with Type: + VOID EXTERN FUNC print_string + EXTERN Type STRING +END EXTERN with Type: + VOID Package : foo + Variable y with type INT = 7 + Variable Z[100] with type INT + Variable Y[100] with type BOOLEAN + Variable z with type INT = 10 + METHOD FUNCTION 'f' with type INT + ( + Method ARGb INT + ) + BLOCK STATEMENT + Variable y with type INT + BLOCK STATEMENT + Variable x[10] with type INT + ASSIGNMENT STATEMENT + Variable Left x + [ + EXPR - + EXPR + + CONSTANT INTEGER 2 + CONSTANT INTEGER 3 + CONSTANT INTEGER 5 + ] + EXPR + + Variable Right b + METHOD CALL name: f + ( + METHOD ARG + EXPR + + CONSTANT INTEGER 5 + EXPR * + Variable Right x + [ + CONSTANT INTEGER 2 + ] + Variable Right b + ) + BLOCK STATEMENT + Variable x[10] with type INT + ASSIGNMENT STATEMENT + Variable Left x + [ + EXPR - + EXPR + + CONSTANT INTEGER 2 + CONSTANT INTEGER 3 + CONSTANT INTEGER 5 + ] + EXPR + + Variable Right b + METHOD CALL name: f + ( + METHOD ARG + EXPR + + CONSTANT INTEGER 5 + EXPR * + Variable Right x + [ + CONSTANT INTEGER 2 + ] + Variable Right b + ) + METHOD FUNCTION 'main' with type INT + ( + Method ARGarg1 INT + Method ARGarg2 INT + ) + BLOCK STATEMENT + METHOD CALL name: print_int + ( + METHOD ARG + METHOD CALL name: f + ( + METHOD ARG + EXPR + + EXPR - + EXPR + + Variable Right arg1 + Variable Right arg2 + Variable Right z + Variable Right y + ) + ) + METHOD CALL name: print_int + ( + METHOD ARG + METHOD CALL name: f + ( + METHOD ARG + EXPR + + EXPR - + EXPR + + Variable Right arg1 + Variable Right arg2 + Variable Right z + Variable Right y + ) + ) + METHOD CALL name: print_string + ( + METHOD ARG + CONSTANT STRING "hello world\n" + ) + +Finished printing AST \ No newline at end of file diff --git a/8LAB/readwrite.asm b/8LAB/readwrite.asm new file mode 100644 index 0000000..3fd80a6 --- /dev/null +++ b/8LAB/readwrite.asm @@ -0,0 +1,84 @@ + +# wghich reads in a number and prints it back put +# + + + + +.data +L1: .asciiz "Please enter value: " +L2: .asciiz "The number read was " +L3: .asciiz "The square is " +NL: .asciiz "\n" +.align 2 +buffer: .space 8 # we need this to read in values an then we can store them +.text + +main: # we need 3 words to store the value, and then RA and SP + + # we only need 3 values. RA, SP, and the value we are reading + subu $a0, $sp, 12 + sw $sp, ($a0) # store the SP at the 0 + sw $ra, 4($a0) # store the RA at the 4 offset + move $sp, $a0 # adjust the stack pointer to the new value + + #Prints the prompt2 string + li $v0, 4 # for syscall to print + la $a0, L1 # L1 is "Please enter value" + syscall + + #reads one integer from user and saves in t0 + li $v0, 5 # set the syscall to read input + #addu $t0, $sp, 8 #$t0 is the memory location for our variable + syscall + sw $v0 8($sp) # store the integer value we got in offset 8 + + # print it back out string + li $v0, 4 + la $a0, L2 + syscall + + # print out the number + li $v0, 1 + #addu $t0, $sp, 8 #Address of x + lw $a0,8($sp) # value of x + syscall + li $v0, 4 # these 3 lines do a new line + la $a0, NL + syscall + + + # now we show how to read into interact with buffer[0] aand buffer[1] + + la $t0, buffer + li $a0, 2 + sw $a0, ($t0) # buffer[0] = 2 + li $a0, 5 + sw $a0 4($t0) # buffer[1]=5 + + # print them back out + + li $v0, 1 + la $t0, buffer + lw $a0, ($t0) # buffer[0] + syscall + li $v0, 4 # these 3 lines do a new line + la $a0, NL + syscall + + li $v0, 1 + la $t0, buffer + lw $a0, 4($t0) # buffer[1] + syscall + li $v0, 4 # these 3 lines do a new line + la $a0, NL + syscall + + +exitProgram: + #put back RA and SP + lw $ra 4($sp) + lw $sp ($sp) + li $v0, 10 # system call to + syscall # terminate program + diff --git a/8LAB/sum100.asm b/8LAB/sum100.asm new file mode 100644 index 0000000..42c832f --- /dev/null +++ b/8LAB/sum100.asm @@ -0,0 +1,129 @@ + +# this program calculates the sum of squares up to and including 100 + +# well it used to. Now it reads an integer from the user then calculates +# the sum of squares up until that integer. +.data +L1: .asciiz "Please enter value: " +str: .asciiz "The sum from 0 ... " +str1: .asciiz " is: " + +.text # directive that we are in the code segment + +# Sets up the environment so we have something to work with. +# Sets up the activation record +# creates +main: + # We need enough memory to keep track of the + # Stack POinter, Return Address, Counting Variable i and sum variable s + # so we need 4 words of memory which translates to 4 * 4 bytes = 16 + # Therefore we carve out 16 bytes from the stack to use for our program + # EDIT: we changed it to 20 to accomodate the user input + + # a0 here is being user to temporarily store the stack pointer we want + # so that we can store the stack pointer and RA + subu $a0, $sp, 20 # We want 4 mem locations for main SP, RA, i , s + + # Store the valies of RA and the stack pointer in memory + # So we can use them later if we need to change them + sw $ra, 4($a0) # we need to store the RA in the Activation record + sw $sp, ($a0) # store SP + + # once we adjust the SP we can discard a0 and use the SP for our memory + # access + move $sp, $a0 # adjust SP + + # this variable is used to keep track of our count + # Initialize the counting variable to 0 so we can count from 0 to 100 + sw $0, 8($sp) # store 0 into memory -- counting variable + + # this is the sum variable to put in the sum of the counting numbers + # initialize the sum variable to 0 so we can add up the sum + sw $0, 12($sp) # store 0 into memory -- accumulating variable + + # prints the prompt string in L1 + li $v0, 4 + la $a0, L1 + syscall + + # Reads a user input integer + li $v0, 5 + syscall + + # stores the user's integer into the memory at 16 + sw $v0, 16($sp) + +# loops from t0 to 100 +loop: + # load the counting variable into register T6 + lw $t6, 8($sp) # + + # Multiply the count by itself and store in another register t7 + mul $t7, $t6, $t6 # i * i + + # Load the summation variable into register t8 + lw $t8, 12($sp) # s + + # add the squared count value to the sum register and store it in t9 + addu $t9, $t8, $t7 # s + i*i + + # Update the sum variable with the new value in t9 + sw $t9, 12($sp) # s= s + i*i + + # We load the original counter value back into t6 + # this way we can inrement the original value and not the squared one + lw $t6, 8($sp) # i + + # increment the value and store it in t0 + addu $t0, $t6, 1 # i+1 + + # store it back in the counter now it's incremented for next loop + sw $t0, 8($sp) # i = i + 1 + + # load the input number into a register + lw $t2, 16($sp) + + # Branch to the loop if the counter is less or equal to 100 otherwise continue + ble $t0, $t2, loop # keep doing it for 100 times + nop # + +# Prints out the result of calculation + + # load the string from the data segment that has the first part + la $a0, str + # v0 has to be 4 when you do a syscall to print for some reason? idk + li $v0 4 # print the string + # This will print to the screen what's in a0 + syscall # + nop # + + # print out the number the user entered + lw $a0, 16($sp) + li $v0 1 # Print the number + syscall + nop # + + + # print out the "is" part of the string + la $a0, str1 + li $v0 4 # print the string + syscall # + + # Now load the result of the summing and print it + lw $a0, 12($sp) + li $v0 1 # Print the number + syscall + nop # + + # Set the return address and stack pointer back + # This way we can return to where we were before calling main + lw $ra, 4($sp) + lw $sp , ($sp) # put back Ra and SP + + # loading 10 into v0 will cause syscall to exit the main function. + li $v0, 10 + syscall # exit for MAIN only + + + + \ No newline at end of file diff --git a/9LAB/Makefile b/9LAB/Makefile index 87a53f0..a6acda3 100644 --- a/9LAB/Makefile +++ b/9LAB/Makefile @@ -12,14 +12,18 @@ FLAGS = -O0 -Wextra -pedantic all: lab9 # Compile all the THINGS! -lab9: lab9.l lab9.y ast.c ast.h symtable.c symtable.h emit.c emit.h - lex lab9.l - yacc -d --verbose --debug lab9.y +lab9: ast.c ast.h symtable.c symtable.h emit.c emit.h lex.yy.c y.tab.c gcc $(FLAGS) y.tab.c lex.yy.c ast.c symtable.c emit.c -o lab9 -lm +lex.yy.c: lab9.l + lex lab9.l + +y.tab.c: lab9.y + yacc -d --verbose --debug lab9.y + # remove the binary and other generated stuff clean: - rm lab9 lex.yy.c y.tab.c y.tab.h + rm -f lab9 lex.yy.c y.tab.c y.tab.h # runs valgrind to look for any memory mistakes memcheck: @@ -27,4 +31,14 @@ memcheck: # executes our code to test it's functionality test: - ./lab9 < testinput.txt \ No newline at end of file + make clean + make + # ./lab9 -o foo < test.decaf + # ./lab9 -o bar < test1.decaf + # ./lab9 -o bar2 < test2.decaf + # ./lab9 -o bar3 < test3.decaf + ./lab9 -o bar4 < test4.decaf + # ./lab9 -o bar5 < test5.decaf + +debug: lab9 + ./lab9 -d -o bar < test.decaf \ No newline at end of file diff --git a/9LAB/bar.asm b/9LAB/bar.asm new file mode 100644 index 0000000..7a7da23 --- /dev/null +++ b/9LAB/bar.asm @@ -0,0 +1,33 @@ +# PACKAGE foo + +.data # Data section starts here, strings first + +_NL: .asciiz "\n" # NEWLINE STRING + +.align 2 # start all global variable aligned + +y: .word 7 # global var initialized +Z: .space 4 # global var uninitialized +A: .space 400 # global var uninitialized +x: .word 1 # global var initialized + + +.text # start of text segment (code) + +.globl main # Force MIPS to start at main label + + + +main: # MAIN METHOD LABEL + + subu $t0 $sp 8 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + li $v0, 10 #Main function ends + syscall #MAIN FUNCTION EXIT diff --git a/9LAB/bar2.asm b/9LAB/bar2.asm new file mode 100644 index 0000000..7a7da23 --- /dev/null +++ b/9LAB/bar2.asm @@ -0,0 +1,33 @@ +# PACKAGE foo + +.data # Data section starts here, strings first + +_NL: .asciiz "\n" # NEWLINE STRING + +.align 2 # start all global variable aligned + +y: .word 7 # global var initialized +Z: .space 4 # global var uninitialized +A: .space 400 # global var uninitialized +x: .word 1 # global var initialized + + +.text # start of text segment (code) + +.globl main # Force MIPS to start at main label + + + +main: # MAIN METHOD LABEL + + subu $t0 $sp 8 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + li $v0, 10 #Main function ends + syscall #MAIN FUNCTION EXIT diff --git a/9LAB/bar3.asm b/9LAB/bar3.asm new file mode 100644 index 0000000..b6b4e1d --- /dev/null +++ b/9LAB/bar3.asm @@ -0,0 +1,42 @@ +# PACKAGE foo + +.data # Data section starts here, strings first + +_NL: .asciiz "\n" # NEWLINE STRING + +.align 2 # start all global variable aligned + +y: .word 7 # global var initialized +Z: .space 4 # global var uninitialized +A: .space 400 # global var uninitialized +x: .word 1 # global var initialized + + +.text # start of text segment (code) + +.globl main # Force MIPS to start at main label + + + +main: # MAIN METHOD LABEL + + subu $t0 $sp 16 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + #EMIT PRINT INT HERE + li $a0, 5 #expr constant value + li $v0 1 #set up write call + syscall #print a number + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + li $v0, 10 #Main function ends + syscall #MAIN FUNCTION EXIT diff --git a/9LAB/bar4.asm b/9LAB/bar4.asm new file mode 100644 index 0000000..2a2c3e7 --- /dev/null +++ b/9LAB/bar4.asm @@ -0,0 +1,186 @@ +# PACKAGE foo + +.data # Data section starts here, strings first + +_L0: .asciiz "x is 5" +_L1: .asciiz "x is not 5" +_L2: .asciiz "hello, what is the meaning of life: " +_L3: .asciiz "The meaning of life is: " +_NL: .asciiz "\n" # NEWLINE STRING + +.align 2 # start all global variable aligned + +y: .word 7 # global var initialized +Z: .space 4 # global var uninitialized +A: .space 400 # global var uninitialized +x: .word 1 # global var initialized + + +.text # start of text segment (code) + +.globl main # Force MIPS to start at main label + + + +dothis: # MAIN METHOD LABEL + + subu $t0 $sp 24 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + li $a0, 12 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 16($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 5 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 16($sp) #get LHS from storage + seq $a0, $a0, $a1 #equal to + beq $a0 $0 _L4 #Branch to first label if expression is 0 + la $a0, _L0 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + j _L5 #And the cow jumped over the else 🐄 +_L4: #First Label for entering else + la $a0, _L1 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + +_L5: #Second Label for jumping over the else + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + + +main: # MAIN METHOD LABEL + + subu $t0 $sp 60 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + la $a0, _L2 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + li $v0, 5 #read int from user + syscall #to read a number + move $a0, $v0 #Move the number into $a0 + sw $a0 16($sp) #store RHS of assign temporarily + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a1, 16($sp) #load back RHS into $a1 + sw $a1, ($a0) #Store assign value + la $a0, _L3 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + #EMIT PRINT INT HERE + li $a0, 24 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + li $v0 1 #set up write call + syscall #print a number + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + li $a0, 0 #expr constant value + sw $a0 28($sp) #store RHS of assign temporarily + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a1, 28($sp) #load back RHS into $a1 + sw $a1, ($a0) #Store assign value +_L6: #First label to restart while loop's block + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 32($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 0 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 32($sp) #get LHS from storage + sgt $a0, $a0, $a1 #greater than + beq $a0 $0 _L7 #Branch to second label if expression is 0 + #EMIT PRINT INT HERE + li $a0, 36 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + li $v0 1 #set up write call + syscall #print a number + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 40($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 1 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 40($sp) #get LHS from storage + sub $a0, $a0, $a1 #subact + sw $a0 44($sp) #store RHS of assign temporarily + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a1, 44($sp) #load back RHS into $a1 + sw $a1, ($a0) #Store assign value + j _L6 #And the little dog laughed to see such loops +_L7: #Second label to jump to from the exit condition + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 36($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 1 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 36($sp) #get LHS from storage + add $a0, $a0, $a1 #add + sw $a0, 40($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 2 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 40($sp) #get LHS from storage + sub $a0, $a0, $a1 #subact + sw $a0, 44($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 5 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 44($sp) #get LHS from storage + add $a0, $a0, $a1 #add + sw $a0 48($sp) #store RHS of assign temporarily + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a1, 48($sp) #load back RHS into $a1 + sw $a1, ($a0) #Store assign value + li $a0, 5 #expr constant value + sw $a0, 52($sp) #Store the argument value in the stack + li $a0, 1 #expr constant value + sw $a0, 56($sp) #Store the argument value in the stack + li $a0, 5 #expr constant value + lw $a0, 52($sp) #load the argument from the stack to a0, a1, a2, a3 respectively and as necessary + li $a0, 1 #expr constant value + lw $a1, 56($sp) #load the argument from the stack to a0, a1, a2, a3 respectively and as necessary + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + li $v0, 10 #Main function ends + syscall #MAIN FUNCTION EXIT diff --git a/9LAB/bar5.asm b/9LAB/bar5.asm new file mode 100644 index 0000000..7a33c39 --- /dev/null +++ b/9LAB/bar5.asm @@ -0,0 +1,117 @@ +# PACKAGE fibinaci + +.data # Data section starts here, strings first + +_L0: .asciiz "in fib" +_L1: .asciiz "hello" +_NL: .asciiz "\n" # NEWLINE STRING + +.align 2 # start all global variable aligned + +y: .word 7 # global var initialized +Z: .space 4 # global var uninitialized +A: .space 400 # global var uninitialized +x: .word 1 # global var initialized + + +.text # start of text segment (code) + +.globl main # Force MIPS to start at main label + + + +fib: # MAIN METHOD LABEL + + subu $t0 $sp 44 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + la $a0, _L0 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 16($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 0 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 16($sp) #get LHS from storage + sle $a0, $a0, $a1 #less than or eq to + beq $a0 $0 _L2 #Branch to first label if expression is 0 + j _L3 #And the cow jumped over the else 🐄 +_L2: #First Label for entering else +_L3: #Second Label for jumping over the else + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 20($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 1 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 20($sp) #get LHS from storage + seq $a0, $a0, $a1 #equal to + beq $a0 $0 _L4 #Branch to first label if expression is 0 + j _L5 #And the cow jumped over the else 🐄 +_L4: #First Label for entering else +_L5: #Second Label for jumping over the else + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + + +main: # MAIN METHOD LABEL + + subu $t0 $sp 32 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + li $a0, 4 #expr constant value + sw $a0, 12($sp) #Store the argument value in the stack + li $a0, 4 #expr constant value + lw $a0, 12($sp) #load the argument from the stack to a0, a1, a2, a3 respectively and as necessary + sw $a0 16($sp) #store RHS of assign temporarily + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a1, 16($sp) #load back RHS into $a1 + sw $a1, ($a0) #Store assign value + #EMIT PRINT INT HERE + li $a0, 5 #expr constant value + li $v0 1 #set up write call + syscall #print a number + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + la $a0, _L1 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + #EMIT PRINT INT HERE + li $a0, 28 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + li $v0 1 #set up write call + syscall #print a number + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + li $v0, 10 #Main function ends + syscall #MAIN FUNCTION EXIT diff --git a/9LAB/emit.c b/9LAB/emit.c index d813445..6099991 100644 --- a/9LAB/emit.c +++ b/9LAB/emit.c @@ -16,8 +16,8 @@ Apr 26 2021: - emit globals comments - emit text (code) section comments May 3 2021: - - Implemented emit_strings() - - Implemented emit_global() + - Implemented emit_strings() + - Implemented emit_global() */ #include @@ -27,397 +27,79 @@ May 3 2021: #include "ast.h" #include "emit.h" +/* Function prototypes for functions only used internally */ + +// PRE: An integer indicating number of newlines +// POST: Emit x number of newlines to the asm +void emit_nl(int x); + // PRE: ptr to ASTnode // POST: all MIPS code in fp file relating to the decaf AST void emit_mips(ASTnode *p); // emits the mips code in text section -FILE *fp = NULL; +// PRE: ptr to ASTnode +// POST: MIPS code needed for a method call to work. +void emit_method_call(ASTnode *p); // handles emiting method calls -char *CURRENT_FUNC; // need to know Current Function for return on main +// PRE: ptr to ASTnode +// POST: inline MIPS code that generates the print +void emit_print_string(ASTnode *p); // handles the print_string methods -void EMITAST(ASTnode *p, FILE *fp); // recursive wlka of AST produces MIPS +// PRE: ptr to METHOD_CALL that is named print_int +// POST: inline MIPS code that generates the print +void emit_print_int(ASTnode *p); // handles the print_int methods -void emit_expr(ASTnode *p, FILE *fp); // helpr function for EMITAST +// PRE: ptr to method call read_int +// POST: $a0 will be the value read +void emit_read_int(ASTnode *p); // handles the print_int methods -// A data structure linked list which allows to keep track of current -// labels for break and cotinue +// PRE: ptr to an expression +// POST: MIPS code such that $a0 has the value of the expr in p +void emit_expr(ASTnode *p); -struct LabelList { - char *s; - struct LabelList *next; -}; +// PRE: ptr to an identifier. (LVALUE or RVALUE) +// POST: $a0 is thje memory address of the identifier +void emit_ident(ASTnode *p); -// global variables to maintain break and continue targets +// PRE: PTR to an enture AST +// POST: output to ASMS file that prints labels and the strings associated +// Each ASTnode that is a string will have p->label updated +// be that generated label +// We need that assignment later so that we can access the string +// via the label +void emit_strings(ASTnode *p); + +// PRE: ptr to an ASTnode +// POST: output to the data section for those nodes +// as A_VARDEC with level 0 +// produce different output for assigned values to scalars. // +void emit_global(ASTnode *p); // emits the global/static variables -struct LabelList *BreakList, *ContinueList; +// PRE: P is ptr to A_ASSIGN +// POST: MIPS code in fp that assigns a value +void emit_assign(ASTnode *p); -// used to maintain the containeing FOR/WHILE labels -void PushLabelBreakList(char *S) -{ - struct LabelList *myNode; - // Missing -} // of PushLabelBreakList +// PRE: ptr to an ASTnode for A_IF +// POST: emit the MIPS code needed for an if/else statement to fp +void emit_if(ASTnode *p); -// used to maintain the containeing FOR/WHILE labels -void PushLabelContinueList(char *S) -{ - struct LabelList *myNode; - // missing -} // of PushLabelContinueList +// PRE: ptr to an A_WHILE ASTnode +// POST: emit the MIPS assembly needed to do a while loop to fp +void emit_while(ASTnode *p); -// remove inner most Break label -void PopLabelBreakList() -{ - BreakList = BreakList->next; -} +// PRE: ptr to an ASTnode of an A_VAR_LVALUE or A_VAR_RVALUE of an array +// POST: emit the proper evaluation of the array index to MIPS code in fp +void emit_array(ASTnode *p); -// remove inner most continue lable -void PopLabelContinueList() -{ // missing -} +// PRE: ptr to an ASTnode of type A_RETURN +// POST: emit mips code that will return the current function +void emit_return(ASTnode *p); + +FILE *fp = NULL; // Pointer to the assembly file we want to emit to static int GLABEL = 0; // global label counter -// creates one_up labels of the form _L%d -// PRE: none -// POST: new copy of strring of the form _L% and GLABEL is incremented -char *genlabel() -{ - char s[100]; - char *S1; - // missing -} - -// Emit the HEADERS, etcs -// - -// PRE none -// Post requred header for MIPS in FILE fp -// -void Emit_Global_headers(FILE *fp, ASTnode *program) -{ - fprintf(fp, "\n\n#\tPackage %s \n\n", program->name); - fprintf(fp, ".data # start of the DATA section, strings first\n\n"); - Emit_Write_Global_Strings(fp, program); - fprintf(fp, "_NL: .asciiz \"\\n \"# New line\n"); - fprintf(fp, ".align 2 # start all of global variable aligned\n\n"); - Emit_Global(program); - - fprintf(fp, "\n.text\n "); - fprintf(fp, "\n.globl main\n\n "); - // emit_default_extern_methods(fp); -} // of Emit_Global_headers - -// this function outputs through global "fp" all of the global variables -// // defined in the source code - -// PRE ptr to AST -// POST output to fp with every GLOBAL variable at level 0 -// declared and if needed, initialize -// Recursive -// INPUT -// package foo { -// var y int =7; -// var Z int ; -// var A[100] int ; -// var x bool = true; -// } -// -// -// -// Creates -// y: .word 7 # define a global variable with initial value -// Z: .space 4 # define a global variable -// A: .space 400 # define a global variable -// x: .word 1 # define a global variable with initial value -// -void Emit_Global(ASTnode *p) -{ - if (p == NULL) - return; - // missing -} - -// program to write out the label, string pair -// NB: T_STRING_LIT needs a label in the SDSA in YACC file -// PRE Ptr to AST -// POST all strings are printed with a one up label -// -// print_string("hello"); -// -// would generate tin the .data section -// _L0: .asciiz "hello" # global string -// -// Each string has unique label via genlabel(). You will need to assign a -// label to the string AST node for T_STRING_LIT -// -void Emit_Write_Global_Strings(FILE *fp, ASTnode *program) -{ - if (program == NULL) - return; - // missing includes recrusive calls - -} // of Emit_Write_Global_Strings - -// helper routine which outputs label, command,and comment lines -void emit(FILE *fp, char *label, char *command, char *comment) -{ - char s[100]; - - fprintf(fp, "%s\t%s\t\t%s\n", label, command, comment); -} - -/* Routine to set the specific memory address of an IDENTifier in $a0. - The calling routine will need to get value if needed - PRE : PTR to indent - POST: $a0 has the mem location of ident -*/ - -void emit_ident(ASTnode *p, FILE *fp) -{ - char s[100]; - - /* the IDENT is either a straight ID , or array reference - - For straight ID, we get the offset, multiply by wordsize - - For array reference, we have to see if the expression is a NUMBER - or an expression. - If a number we do immediate i - If an expression we fetch from memory using the result of the expression - and then load in the result of the expression - */ - - /* we assume the node is IDENT and is properly conected */ - - // $t3 is the holder of offset into the IDENTIFIER - // $t2 first holds the offset of the IDENT from stack and then - // is the direct reference into the stack - - if (p->S1 == NULL) { // we have a straight identifier - } else { // this is an array - // missing - } - - /* we always get to the starting point of the identifier*/ - /* If the Identifier is a GLOBAL, we load that address, otherwise, we need to - find the offset of the identifier - - */ - - // figure out if it is static (data segment) or stack - // missing - - // if we have an ARRAY then add on offset - if (p->S1 != NULL) { - printf(""); - } - // missing - -} // of function emit_ident - -// Given a PTR to a function call, handle it -// -void handle_function_call(ASTnode *p, FILE *fp) -{ - char s[100]; - ASTnode *fparm, *arglist; - // we are handed a pointer to perform a function/subroutine call - // we need to take our parameters and place in the correct new Activation - // record, and then call the function - - // take care of the three special external function as inline - - fparm = p->symbol->fparms; - arglist = p->S1; - - if (strcmp(p->name, "print_string") == 0) { - // assume $a0 is the label address - sprintf(s, "la $a0 %s", arglist->S1->label); - emit(fp, "", "", ""); - emit(fp, "", s, "#get string address for print"); - emit(fp, "", "li $v0, 4", "#print a string"); - emit(fp, "", "syscall", ""); - emit(fp, "", "", ""); - emit(fp, "", "li $v0, 4", "#print NEWLINE"); - sprintf(s, "la $a0, _NL"); - emit(fp, "", s, "#print NEWLINE string location"); - emit(fp, "", "syscall", ""); - return; - } - - // $a0 is the value to print - if (strcmp(p->name, "print_int") == 0) { - printf("it is a print int\n"); - emit_expr(arglist->S1, fp); - printf("it is a print int\n"); - emit(fp, "", "", "#print an INT"); - emit(fp, "", "li $v0 1", "#set up write call"); - emit(fp, "", "syscall", ""); - emit(fp, "", "", ""); - emit(fp, "", "li $v0, 4", "#print NEWLINE"); - sprintf(s, "la $a0, _NL"); - emit(fp, "", s, "#print NEWLINE string location"); - emit(fp, "", "syscall", ""); - emit(fp, "", "", ""); - return; - } - // - // $v0 will be the value read in - if (strcmp(p->name, "read_int") == 0) { - emit(fp, "", "", ""); - emit(fp, "", "", "# read Int $v0 has return value"); - emit(fp, "", "li $v0 5", "#read in a number "); - emit(fp, "", "syscall", "#now read "); - emit(fp, "", "move $a0, $v0", "#copy $v0 to $a0 "); - emit(fp, "", "", ""); - return; - } - // all other method calls handled below - - // evaluate the args, and place them in $a0-$a3 - - // missing - - // now call the function - - emit(fp, "", "", - "# about to call a function, set up each parameter in the new " - "activation record"); - - sprintf(s, "jal %s", p->name); - emit(fp, "", s, "#jump and link to function"); -} - -/* Routine to create the Function startup processes */ - -void emit_func_start(ASTnode *p, FILE *fp) -{ - printf("working on FUNCTION %s\n", p->name); - char s[100]; - sprintf(s, "%s:", p->name); - emit(fp, "", "", ""); /* blank line */ - emit(fp, "", "", ""); /* blank line */ - emit(fp, s, "", "#Start of Function "); - - CURRENT_FUNC = p->name; // so we know what it is in return statement - - // if this is the main program output the needed header to carve out stack - // space for the global variables - - // figure out how much stack we need , we will use $t0 to store this value - // missing - - // we now copy the $a0 - $a3 registers to their respective locations - // missing - // - emit(fp, "", "", ""); /* blank line */ - emit(fp, "", "", ""); /* blank line */ -} - -// Produce code for end of function and returns . -// Basically, we need to assign $a0 a value from the return or 0 if it is void -// Then set the $ra from the top of stack -// and then set the stack to old stack -// and then jump register - -void emit_func_return(ASTnode *p, FILE *fp) -{ - char s[100]; - /* figure out what return value to send */ - - // implicit return - if (p == NULL) { - // missing - - } else // explicit return - { /* we have a number or an expression */ - printf("return statement not null\n"); - emit_expr(p, fp); - } - - /* set ra and sp */ - - // missing needs to be special for MAIN -} - -/* The basic algorithm - * pre condition p is derived from expression - * we will set $a0 to the value of emit expression - */ - -void emit_expr(ASTnode *p, FILE *fp) -{ - char s[100]; - - /* base cases */ - switch (p->type) { // missing - break; - - } // of switch for base cases - - // we have an expression - - // recursive case LHS - - // recusive case RHS - // Put things together - - // now execute the desired operation - switch (p->operator) { - case A_PLUS: - emit(fp, "", "add $a0, $a0, $a1", "#EXPR ADD"); - break; - // missing - } - - // store the result in memory -} - -// routine to do an assignment statement -// PRE: PTR to assignment -// POST: MIPS code for assignment - -void emit_assign(ASTnode *p, FILE *fp) -{ -} - -// Given an IF Statement, generate the mips code to do the jumping we need to -// do - -void emit_if(ASTnode *p, FILE *fp) -{ -} - -// handle the WHILE statement -void emit_while(ASTnode *p, FILE *fp) -{ -} - -/* EMIT the Abstract syntax tree */ -// PRE: PTR to AST -// POST: MIPS code in fp for each AST instruction -void EMITAST(ASTnode *p, FILE *fp) -{ - char s[100]; - int i; - if (p == NULL) - return; - - switch (p->type) { - case A_PACKAGE: - EMITAST(p->S1, fp); // externs - EMITAST(p->S2, fp); // PACKAGE_SUB - break; - // missing - - default: - printf("%d: unknown type in EMITAST\n", p->type); - } - EMITAST(p->next, fp); // always do the next -} - // PRE: no input // POST: char i* to a one up string of the form "_L%d" char *GEN_LABEL() @@ -431,6 +113,7 @@ char *GEN_LABEL() // increment GLABEL for next time we get called GLABEL++; + return strdup(label_num); } @@ -483,40 +166,99 @@ void emit_strings(ASTnode *p) // void emit_global(ASTnode *p) { + // make sure node is not null if (p == NULL) { return; } - if ((p->type == A_VARDEC) && (p->symbol->level == 0)) { + + // if it's a vardec and the level is 0 that means its a global variable + if ((p->type == A_VARDEC) && + (p->symbol->level == + 0)) { // if there's an assignment set it to a word if (p->S2 != NULL) { fprintf(fp, "%s:\t.word %d\t # global var initialized\n", p->name, p->S2->value); } else { + // else if there is no assignment allocate empty space of the + // true size of the variable. fprintf(fp, "%s:\t.space %d\t # global var uninitialized\n", p->name, p->size * WS); } } + // call again on S1, S2, and next emit_global(p->S1); emit_global(p->S2); emit_global(p->next); } +// PRE label, code, comment +// POST: output to file with ASM formatted output +// +// This is a general command to emit code to the asm with labels and comments +// L: the label (string) +// I: The instruction (string) +// C: The comment (string) +// to omit any of them pass an empty string +void emit(char *L, char *I, char *C) +{ + if (L != "") { + fprintf(fp, "%s:\t%s\t\t #%s\n", L, I, C); + } else { + fprintf(fp, "\t%s\t\t #%s\n", I, C); + } +} + // PRE: ptr to a method decl // POST: MIPS code for the method void emit_method_dec(ASTnode *p) { + char s[100]; fprintf(fp, "\n\n%s:\t\t# MAIN METHOD LABEL\n\n", p->name); + + // set up activation record + + sprintf(s, "subu $t0 $sp %d", + p->symbol->mysize * WS); // makes the subu size dynamic + emit("", s, "set up $t0 to be the new spot for SP"); + emit("", "sw $ra ($t0)", "Store the return address in offset 0"); + emit("", "sw $sp 4($t0)", "Store the old stack pointer in offset 4"); + emit("", "move $sp $t0", "set the stack pointer to the new value"); + emit_nl(2); + + // hand shake for entry into a method. + + // p->S1 is the parameter for the method stored in the activation record + // p->S2 is the block of code of the function + emit_mips(p->S2); // emit the block of the function + + // deal with the return to other method or return to system + + emit("", "li $v0 0", "return NULL zero (0)"); + emit("", "lw $ra ($sp) ", "reset return address "); + emit("", "lw $ra 4($sp)", "reset stack pointer "); + + // Special MIPS stop which has code 10 -- Only done in end of MAIN function + // syscall will stop when v0 is 10 + if (strcmp(p->name, "main") == 0) { + emit("", "li $v0, 10", "Main function ends "); + emit("", "syscall", "MAIN FUNCTION EXIT "); + } } // PRE: ptr to ASTnode // POST: all MIPS code in fp file relating to the decaf AST +// This is the main hub for selecting the correct method to +// emit nodes void emit_mips(ASTnode *p) { // emits the mips code in text section - if (p == NULL) + if (p == NULL) { return; + } + // Change print method depending on the Node type switch (p->type) { case A_PROGRAM: emit_mips(p->S2); @@ -528,9 +270,481 @@ void emit_mips(ASTnode *p) case A_METHODDEC: // call the helper for printing methods emit_method_dec(p); break; + case A_BLOCK: // handle blocks + // p->S1 are local variables, handled by activation rec. + emit_mips(p->S2); + break; + + case A_METHODCALL: // handle method calls + emit_method_call(p); + break; + case A_ASSIGN: + emit_assign(p); // emit the assign mips code + break; + case A_IF: + emit_if(p); // emit the if statement logic mips code + break; + case A_WHILESTMT: + emit_while(p); // emit the while statement mips code. + break; + // case A_RETURN: + // emit_return(p); // emit the while statement mips code. + // break; default: + // if none of the cases match print a warning. printf("emit_mips UNKNOWN AST type\n"); } emit_mips(p->next); -} \ No newline at end of file +} + +// PRE: ptr to ASTnode +// POST: MIPS code needed for a method call to work. +// +// Note: for print_int(), print_string(), and read_int(), we will +// inline code these methods all others are handled with evaluating +// the params, placing them in appropriate registers and calling +// the method named +void emit_method_call(ASTnode *p) // handles emiting method calls +{ // Pre defined function call routines + // picked based on the method call's name. + if (strcmp(p->name, "print_int") == 0) { + emit_print_int(p); + } else if (strcmp(p->name, "print_string") == 0) { + emit_print_string(p); + } else if (strcmp(p->name, "read_int") == 0) { + emit_read_int(p); + } else { + // printf("NO METHOD CALL IMPLEMENTED for %s YET\n", p->name); + char s[100]; + + // use a cursor for traversing linked lists. + // this way we can traverse all the arguments efficiently + ASTnode *cursor = p->S1; + + while (cursor != NULL) { + emit_expr(cursor); // evaluate the argument + + // store the argument in the stack pointer in it's offset + sprintf(s, "sw $a0, %d($sp)", + cursor->symbol->offset * WS); + emit("", s, "Store the argument value in the stack"); + + // go to next argument + cursor = cursor->next; + } + + int num = 0; // keep track of which register $a0-$a3 + + cursor = p->S1; + while (cursor != NULL) { + // We only have 4 registers to use for this. + // make sure we only use 4 + if (num >= 4) { + printf("Too many arguments in function %s \n", + p->name); + exit(1); + } + + emit_expr( + cursor); // evaluate the argument and store in $a0 + + // load the arguments from the stack pointers into + // their $a0-$a3 registers + sprintf(s, "lw $a%d, %d($sp)", num, + cursor->symbol->offset * WS); + emit("", s, + "load the argument from the stack to a0, a1, a2, a3 respectively and as necessary"); + + // go to the next argument. + cursor = cursor->next; + + // go to the next register + num++; + } + } +} + +// PRE: ptr to METHOD_CALL that is named print_string +// POST: inline MIPS code that generates the print +void emit_print_string(ASTnode *p) // handles the print_string methods +{ + emit_expr(p->S1); // $a0 will be the value in print_int + emit("", "li $v0 4", "set up write call"); + emit("", "syscall", "print a string"); + + emit("", "li $v0, 4", "print NEWLINE"); + emit("", "la $a0, _NL", "print NEWLINE string location"); + emit("", "syscall", "call print a NEWLINE"); + emit_nl(2); +} + +// PRE: ptr to METHOD_CALL that is named print_int +// POST: inline MIPS code that generates the print +void emit_print_int(ASTnode *p) // handles the print_int methods +{ + emit("", "", "EMIT PRINT INT HERE"); + emit_expr(p->S1); // $a0 will be the value in print_int + emit("", "li $v0 1", "set up write call"); + emit("", "syscall", "print a number"); + + emit("", "li $v0, 4", "print NEWLINE"); + emit("", "la $a0, _NL", "print NEWLINE string location"); + emit("", "syscall", "call print a NEWLINE"); + emit_nl(2); +} + +// PRE: ptr to an expression +// POST: MIPS code such that $a0 has the value of the expr in p +void emit_expr(ASTnode *p) +{ + char s[100]; + + if (p == NULL) { + printf("Illegal use of emit_expr NULL input"); + exit(1); + } + + // handle bas e cases + // no default case because that will be the recursive call + switch (p->type) { + case A_CONSTANT_INT: + case A_CONSTANT_BOOL: + sprintf(s, "li $a0, %d", p->value); + emit("", s, "expr constant value"); + return; + break; + case A_CONSTANT_STRING: + sprintf(s, "la $a0, %s", p->label); + emit("", s, "expr constant is a string"); + return; + break; + case A_METHODCALL: + emit_method_call(p); // $a0 will be the result value + return; + break; + case A_VAR_RVALUE: + case A_VAR_LVALUE: + emit_ident(p); // $a0 now contains the memory address + emit("", "lw $a0 ($a0)", + "load from the memory address a value"); + return; + break; + } + + // In our A_EXPR we need to eval S1 and perhaps S2 + // if there is an RHS + emit_expr(p->S1); // $a0 will now contain the LHS + + // check if there is a RHS. + // + // if there is an RHS store the LHS then eval the RHS + + if (p->S2 != NULL) { + // Store LHS in stack temporarily to make space for LHS + sprintf(s, "sw $a0, %d($sp)", p->symbol->offset * WS); + emit("", s, "store $a0 (LHS) temporarily so we can eval RHS"); + + emit_expr(p->S2); // Now $a0 has the RHS + + // PUT RHS in $a1 + emit("", "move $a1, $a0", "move RHS to $a1"); + + // Load LHS into $a0 + sprintf(s, "lw $a0, %d($sp)", p->symbol->offset * WS); + emit("", s, "get LHS from storage"); + // List of operators + switch (p->operator) { + case A_PLUS: + emit("", "add $a0, $a0, $a1", "add"); + break; + + case A_MINUS: + emit("", "sub $a0, $a0, $a1", "subact"); + break; + + case A_LT: + emit("", "slt $a0, $a0, $a1", "less than"); + break; + + case A_GT: + emit("", "sgt $a0, $a0, $a1", "greater than"); + break; + + case A_LEQ: + emit("", "sle $a0, $a0, $a1", "less than or eq to"); + break; + + case A_GEQ: + emit("", "sge $a0, $a0, $a1", "greater than or eq to"); + break; + + case A_EQ: + emit("", "seq $a0, $a0, $a1", "equal to"); + break; + + case A_NEQ: + emit("", "sne $a0, $a0, $a1", "Not equal"); + break; + + case A_TIMES: + break; + + case A_DIVIDE: + break; + + case A_MOD: + break; + + case A_OR: + emit("", "or $a0, $a0, $a1", "OR"); + break; + + case A_AND: + emit("", "and $a0, $a0, $a1", "AND"); + break; + + case A_LEFTSHIFT: + emit("", "sllv $a0, $a0, $a1", "LEFTSHIFT"); + break; + + case A_RIGHTSHIFT: + emit("", "srlv $a0, $a0, $a1", "RIGHTSHIFT"); + break; + + case A_UMINUS: + emit("", "neg $a0, $a0", " UNARY MINUS"); + break; + + default: + printf("Exist EXPR operator unknown"); + } + } +} + +// PRE: An integer indicating number of newlines +// POST: Emit x number of newlines to the asm +void emit_nl(int x) +{ + for (int i = 0; i < x; i++) { + fprintf(fp, "\n"); + } +} + +// PRE: ptr to an identifier. (LVALUE or RVALUE) +// POST: $a0 is thje memory address of the identifier +void emit_ident(ASTnode *p) +{ + // If it's an array we have a separate method for it + if (p->symbol->SubType == ID_Sub_Type_Array) { + emit_array(p); + return; + } + char s[100]; + + // check if it's being used incorrectly + // Can only be used on a LHS or RHS node + if (p->type != A_VAR_LVALUE && p->type != A_VAR_RVALUE) { + printf("Illegal use of emit_ident\n"); + exit(1); + } + + // Check if it's a global variable + if (p->symbol->level == 0) { + // load in the address using the name from the symtable + sprintf(s, "la $a0, %s", p->name); + emit("", s, "load global address of variable"); + } else { // else if it's a local variable + + // load the true offset into $a0 + sprintf(s, "li $a0, %d", p->symbol->offset * WS); + emit("", s, "offset for variable address"); + + // add the true offset to the stack pointer value + emit("", "add $a0, $a0, $sp", + "exact location for stack variable"); + } +} + +// PRE: P is ptr to A_ASSIGN +// POST: MIPS code in fp that assigns a value. +void emit_assign(ASTnode *p) +{ + char s[100]; + // make sure node is type A_ASSIGN + if (p->type != A_ASSIGN) { + printf("Illegal use of emit_assign"); + exit(1); + } + + // get value for RVALUE + // Store it temporarily so that LHS doesn't overwrite $a0 + // get the address of LHS + // retrieve value from memory + // store ther value at the address of LHS + emit_expr(p->S2); // expression of the assign + + // store it into the holding spot in memory + // + sprintf(s, "sw $a0 %d($sp)", p->symbol->offset * WS); + emit("", s, "store RHS of assign temporarily"); + + emit_ident(p->S1); // get address of LHS + + sprintf(s, "lw $a1, %d($sp)", p->symbol->offset * WS); + + emit("", s, "load back RHS into $a1"); + + emit("", "sw $a1, ($a0)", "Store assign value"); +} + +// PRE: ptr to method call read_int +// POST: $a0 will be the value read +void emit_read_int(ASTnode *p) // handles the print_int methods +{ + emit("", "li $v0, 5", "read int from user"); + emit("", "syscall", "to read a number"); + emit("", "move $a0, $v0", "Move the number into $a0"); +} + +// PRE: ptr to an ASTnode for A_IF +// POST: emit the code needed for an if/else statement +// Two labels, a branch, and jump are used to navigate +// the logic of an if else statemtent. +void emit_if(ASTnode *p) +{ + char s[100]; + + // Generate the two labels + char *label_one = GEN_LABEL(); + char *label_two = GEN_LABEL(); + + // $a0 will now contain the evaluated expression + emit_expr(p->S1); + + // Branch when the expression is equal to 0 + // to the first label in order to skip over the if block + // and execute the else block + sprintf(s, "beq $a0 $0 %s", label_one); + emit("", s, "Branch to first label if expression is 0"); + + emit_mips(p->S2->S1); // emit the if's main block + + sprintf(s, "j %s", + label_two); // Jump to the second label to skip else + emit("", s, "And the cow jumped over the else 🐄"); + + // sandwich the else between the first and second label + // This allows us to either enter the else or skip to after it. + emit(label_one, "", "First Label for entering else"); + + // Let's only emit the else if the else block is there. + if (p->S2->S2 != NULL) { + emit_mips(p->S2->S2); // emit else block + } // if there is no else block it will just be an empty label sandwich + + emit(label_two, "", "Second Label for jumping over the else"); +} + +// PRE: ptr to an A_WHILE ASTnode +// POST: emit the MIPS assembly needed to do a while loop to fp +void emit_while(ASTnode *p) +{ + char s[100]; + + // Generate the two labels + char *label_one = GEN_LABEL(); + char *label_two = GEN_LABEL(); + + emit(label_one, "", "First label to restart while loop's block"); + + // now the expression is evaluated in $a0 + emit_expr(p->S1); + + // Branch equal to 0 to the second label this is the exit condition + sprintf(s, "beq $a0 $0 %s", label_two); + emit("", s, "Branch to second label if expression is 0"); + + // emit the body of the while loop + emit_mips(p->S2); + + // jump back up to the start of the loop using first label + sprintf(s, "j %s", + label_one); // Jump to the first label to repeat + emit("", s, "And the little dog laughed to see such loops"); + + // emit the second label used to skip over the while body + emit(label_two, "", "Second label to jump to from the exit condition"); +} + +// PRE: ptr to an ASTnode of an A_VAR_LVALUE or A_VAR_RVALUE of an array +// POST: emit the proper evaluation of the array index to MIPS code in fp +// at the end of this function $a0 will have the true address of the +// item indexed in the array +void emit_array(ASTnode *p) +{ + // Copied the code from emit_ident + // 1. Evaluate the expression in the array index argument + // 2. multiply it by WS and store it in a new register $t3 + // 3. load the starting address of the array + // 4. add the product result to the address to the get the offset + // of the index in the argument + + char s[100]; + + // check if it's being used incorrectly + // Can only be used on a LHS or RHS node + if (p->type != A_VAR_LVALUE && p->type != A_VAR_RVALUE) { + printf("Illegal use of emit_ident\n"); + exit(1); + } + + emit_expr(p->S1); // Expression is evaluated in $a0 + + // Check if it's a global variable + if (p->symbol->level == 0) { + // Multiply the index evaluated by 4 to get the real offset + // Stored in a secondary register + emit("", "sll $a1, $a0, 2", "Multiply by 4"); + + // load in the starting offset of the array + sprintf(s, "la $a0, %s", p->name); + emit("", s, "load global address of array"); + + // add the relative offset of the index to the starting offset + // of the array store in $a0 + emit("", "add $a0, $a0, $a1", ""); + + } else { // else if it's a local variable + // Multiply the index evaluated by 4 to get the real offset + // Stored in a secondary register + emit("", "sll $a1, $a0, 2", "Multiply by 4"); + + sprintf(s, "li $a0, %d", p->symbol->offset * WS); + emit("", s, "offset for variable address"); + emit("", "add $a0, $a1, $sp", + "exact location for stack variable"); + } +} + +// PRE: ptr to an ASTnode of type A_RETURN +// POST: emit mips code that will return the current function +void emit_return(ASTnode *p) +{ + /* + li $v0 0 # return NULL zero (0) + lw $ra ($sp) # reset return address + lw $sp 4($sp) # reset stack pointer + jr $ra # return to our caller + */ + if (p->S1 != NULL) { + char s[100]; + emit_expr(p->S1); + emit("", "move $v0, $a0", "emit the expression in $a0"); + } else { + emit("", "li $v0 0", "return null "); + } + emit("", "lw $ra ($sp)", " reset return address "); + emit("", "lw $sp 4($sp)", "reset stack pointer "); + emit("", "jr $ra ", "return to our caller"); +} diff --git a/9LAB/emit.h b/9LAB/emit.h index ab4b80d..463d97c 100644 --- a/9LAB/emit.h +++ b/9LAB/emit.h @@ -48,42 +48,6 @@ void emit_all(ASTnode *p); // via the label void emit_strings(ASTnode *p); -char *genlabel(); // needed in YACC for T_STRING_LIT - -void Emit_Global_headers(FILE *fp, ASTnode *program); - -void EMITAST(ASTnode *p, FILE *fp); -void emit_expr(ASTnode *p, FILE *fp); - -void emit(FILE *fp, char *label, char *command, char *comment); - -void emit_default_extern_methods(FILE *fp); - -void Emit_Write_Global_Strings(FILE *fp, ASTnode *program); - -char *ER(char *S, int offset, char *r); -char *ES(char *s, int offset); - -void emit_ident(ASTnode *p, FILE *fp); - -void emit_header(FILE *fp, int NUM, int offset); - -void handle_function_call(ASTnode *p, FILE *fp); - -void emit_func_start(ASTnode *p, FILE *fp); - -void emit_func_return(ASTnode *p, FILE *fp); - -void emit_expr(ASTnode *p, FILE *fp); - -void emit_assign(ASTnode *p, FILE *fp); - -void emit_if(ASTnode *p, FILE *fp); -void emit_while(ASTnode *p, FILE *fp); - -void Emit_Global(ASTnode *p); -void EMITAST(ASTnode *p, FILE *fp); - // PRE: ptr to an ASTnode // POST: output to the data section for those nodes // as A_VARDEC with level 0 diff --git a/9LAB/foo.asm b/9LAB/foo.asm index 10aff89..7a7da23 100644 --- a/9LAB/foo.asm +++ b/9LAB/foo.asm @@ -6,6 +6,10 @@ _NL: .asciiz "\n" # NEWLINE STRING .align 2 # start all global variable aligned +y: .word 7 # global var initialized +Z: .space 4 # global var uninitialized +A: .space 400 # global var uninitialized +x: .word 1 # global var initialized .text # start of text segment (code) @@ -16,3 +20,14 @@ _NL: .asciiz "\n" # NEWLINE STRING main: # MAIN METHOD LABEL + subu $t0 $sp 8 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + li $v0, 10 #Main function ends + syscall #MAIN FUNCTION EXIT diff --git a/9LAB/lab9 b/9LAB/lab9 index 4a9146df66b16e9e86e8bf36ee437cb74c24f303..29734c30a8d10c61b9a81b1a64b48bba062caf4f 100755 GIT binary patch literal 63536 zcmc${31C#!^#^=sk{3cC3y`oQ4-z2kVUqv?6JTJF5F#Y3A_-&yk!&Ut7Au8vetuzoCsMFA6uw}Vp%ij)bP zq-qmJOTGv|l1sM>M7rI<6DI5_(9DFUg#WWKGDJ&JiR>wqB6*3oqqy zyb0TrL3pL72x!WYc_hb-lc zk*9#t1qXQ+(7_WX+%5H)(3HCda@ zp~Xd|RqKYXOTTjHm7|AMmJJ)p>zxSwp&$Mf|cj)&Xf9Z`01+NYjh_+ZFF5yxZeVeDvypcQ3q2Uw6Da;vJ8-89zu~ z_L5D`?X?oy$c$-=>DM^m+v430?^wJ$;T?lF)wMI;UGVOPxA~$ty+UTFEYm)&&!)4@ zwgfxjOrC+gcJ?gH%}*Hjh0&_n{{lbNt@$ezh?ek+Tfrx{f9m5 z1wXG9{4ZL;|FIQ(Lo4{ht>7tMbiA9tRs+$JKex1kzrPjyj#ltAoV27rtra}QNlW~{ zY6X9LD|qTRE$N|t))M|eEBHyR;61>1pk8n+4=K@K38v#s_=INoT8Y=2;n}ifD@)2s zmsNW5D?H1VG55M6534M%C@S?7vcj@*cPT5c@>J5tidFd)tiqjNTwJz-ReB1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ky{OT4@?W#iX z^^Fc-aA9(2v{d$Z-6SGpyl6f^b+VtE!#r$iLg;xTN z@^{Wkk-~gC`Crr&)@n1v-)22r&T6FI!#5vZe_t;%i1#OQ_`Y2$@XkTBMtU;oYIUr9Ruu4gCtD-=RAeqV3YMt+%J&mQxb@bJ4xXZij8*#W*d zeS9d(E$_PW$M+(BUypY4^+q=*Pp-PoLc5TV@?HP_{&W}l7oCx%PLj5KlIu*G{JtLQ z+1*C?GZ#$0Sbt9d&zA4&rnddS7+jBJZ?vDM_aZVEKkqI+KRWfaQFwb>s@eXIOaGR4 zFV64lu-^Y4`CkLC*pBlz)@%J7AdV@yI2`N_jrw~#zKJ{`aeiOdHT8^eO>b|nw})?o zCd=Pg|Fu`R;YZVg#@YEi{5x{8{62qiaIdkP(BQO)^Ev!aLD#nC! z-?PSldz2X^lQUcJcmKlp{}M4o$z&P%WBpz5yz#%HZ@JC$9NzdYc0y)F z$)u|Vf6q(Cu&pUlW3m24UZi5BJ3#*D7np!W2uAU9`*XXH@h!SUW!U*A4U*+}ADKPk V`X7hPnfPBhWL&<^#bw0&{{>dw94!C< diff --git a/9LAB/lab9.y b/9LAB/lab9.y index d998781..315de48 100644 --- a/9LAB/lab9.y +++ b/9LAB/lab9.y @@ -1,10 +1,10 @@ /* -Ziad Arafat - Mar 8 2021 -Lab 5 +Ziad Arafat - May 7 2021 +Lab 9 */ /* -TODO: Add debug flag to args +Add debug flag to args */ /* April 26 2021: @@ -439,10 +439,13 @@ IfStmt: $$->S1 = $3; // set S1 to the Expression node $$->S2 = ASTCreateNode(A_IFBODY); // create a separate node for the body in S2 $$->S2->S1 = $5; // set the S1 of the body to the block of the IF - $$->S2->S2 = ASTCreateNode(A_ELSE); // create a new node for the else statement after the body + $$->S2->S2 = $7; // create a new node for the else statement after the body + + /*I modified my original implementation to + not have an A_ELSE node. Instead we just store the blocks + directly in the S1 and S2 of the A_IFBODY respectively. + This makes the logic on the emit.c side much simpler*/ - // set the S1 of the Else to the Else's Block - $$->S2->S2->S1 = $7; } | T_IF '(' Expr ')' Block { $$ = ASTCreateNode(A_IF); @@ -473,8 +476,19 @@ Assign: $$ = ASTCreateNode(A_ASSIGN); $$->S1 = $1; // set the S1 to the left hand side $$->S2 = $3; // set the S2 to the right hand side + $$->name = TEMP_CREATE(); + // create a temporary symbol to hold value + $$->symbol = Insert($$->name, $$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // Determine if we need to increment offset + // Yes we do because the assignments need temporary values + // in the function's space + offset++; }; + +// in case we wanna do for loops I guess +// TODO: Implement for loops /* Assigns: Assign | Assign ',' Assigns @@ -545,7 +559,7 @@ MethodCall: // if we didn't find one lets barf because it wasnt defined if(p == NULL) { - yyerror("Symbol on LVALUE not defined"); + yyerror("Method symbol not defined"); yyerror($1); exit(1); } @@ -573,7 +587,14 @@ MethodCall: $$->A_Declared_Type = p->Type; // type matches it's formal type }; -MethodArg: Expr { $$ = $1; }; +MethodArg: Expr { + $$ = $1; + // create a temporary symbol to hold value + $$->symbol = Insert(TEMP_CREATE(),$$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // increment offset by 1 because of the temporary value being stored + offset++; + }; MethodArgs: /* empty */ { @@ -701,7 +722,7 @@ Factor: p = Search($1, level, 1); if(p == NULL) { - yyerror("Symbol on LVALUE not defined"); + yyerror("Symbol on RVALUE not defined"); yyerror($1); exit(1); } @@ -835,7 +856,7 @@ Constant: int main(int argc, char ** argv){ for (int i = 1; i 0) { + print_int(x); + x = x - 1; + } + + x = x + 1 - 2 + 5; + + dothis(5, true); + + + + } // of main + +} // of foo + diff --git a/9LAB/test5.asm b/9LAB/test5.asm new file mode 100644 index 0000000..000fe26 --- /dev/null +++ b/9LAB/test5.asm @@ -0,0 +1,178 @@ + + +# Package fibinaci + +.data # start of the DATA section, strings first + +_L0: .asciiz "in fib" # global string +_L1: .asciiz "hello" # global string +_NL: .asciiz "\n "# New line +.align 2 # start all of global variable aligned + +y: .word 7 # define a global variable with initial value +Z: .space 4 # define a global variable +A: .space 400 # define a global variable +x: .word 1 # define a global variable with initial value + +.text + +.globl main + + + +fib: #Start of Function + subu $t0 $sp 44 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address + sw $sp 4($t0) #Store the old stack pointer + move $sp $t0 # set the stack pointer to the new value + + sw $a0 8($sp) #copy function register to formal + + + + la $a0 _L0 #get string address for print + li $v0, 4 #print a string + syscall + + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall + + li $a0 8 #get Identifier offset + add $a0,$a0,$sp # we have direct reference to memory + lw $a0 ($a0) #expression is identifier + sw $a0 16($sp) #store LHS of expression in memory + li $a0 0 # expresion a number + move $a1, $a0 #right hand side needs to be a1 + lw $a0 16($sp) #fetch LHS of expression from memory + add $a1 ,$a1, 1 #EXPR LE add one to do compare + slt $a0 ,$a0, $a1 #EXPR LE + sw $a0 16($sp) #store RHS of expression in memory + beq $a0 $0 _L2 #IF branch to else part + li $a0 0 # expresion a number + lw $ra ($sp) # reset return address + lw $sp 4($sp) # reset stack pointer + jr $ra # return to our caller + j _L3 #IF S1 end +_L2: # ELSE target +_L3: # End of IF + + li $a0 8 #get Identifier offset + add $a0,$a0,$sp # we have direct reference to memory + lw $a0 ($a0) #expression is identifier + sw $a0 20($sp) #store LHS of expression in memory + li $a0 1 # expresion a number + move $a1, $a0 #right hand side needs to be a1 + lw $a0 20($sp) #fetch LHS of expression from memory + slt $t2 ,$a0, $a1 #EXPR EQUAL + slt $t3 ,$a1, $a0 #EXPR EQUAL + nor $a0 ,$t2, $t3 #EXPR EQUAL + andi $a0 , 1 #EXPR EQUAL + sw $a0 20($sp) #store RHS of expression in memory + beq $a0 $0 _L4 #IF branch to else part + li $a0 1 # expresion a number + lw $ra ($sp) # reset return address + lw $sp 4($sp) # reset stack pointer + jr $ra # return to our caller + j _L5 #IF S1 end +_L4: # ELSE target +_L5: # End of IF + + li $a0 8 #get Identifier offset + add $a0,$a0,$sp # we have direct reference to memory + lw $a0 ($a0) #expression is identifier + sw $a0 24($sp) #store LHS of expression in memory + li $a0 1 # expresion a number + move $a1, $a0 #right hand side needs to be a1 + lw $a0 24($sp) #fetch LHS of expression from memory + sub $a0, $a0, $a1 #EXPR SUB + sw $a0 24($sp) #store RHS of expression in memory + sw $a0 28($sp) # stor arg value in our runtime stack + #set up the A0 - A3 registers to call function + lw $a0 28($sp) # load parameter value from stack into hand shake register + # about to call a function, set up each parameter in the new activation record + jal fib #jump and link to function + sw $a0 40($sp) #store LHS of expression in memory + li $a0 8 #get Identifier offset + add $a0,$a0,$sp # we have direct reference to memory + lw $a0 ($a0) #expression is identifier + sw $a0 32($sp) #store LHS of expression in memory + li $a0 2 # expresion a number + move $a1, $a0 #right hand side needs to be a1 + lw $a0 32($sp) #fetch LHS of expression from memory + sub $a0, $a0, $a1 #EXPR SUB + sw $a0 32($sp) #store RHS of expression in memory + sw $a0 36($sp) # stor arg value in our runtime stack + #set up the A0 - A3 registers to call function + lw $a0 36($sp) # load parameter value from stack into hand shake register + # about to call a function, set up each parameter in the new activation record + jal fib #jump and link to function + move $a1, $a0 #right hand side needs to be a1 + lw $a0 40($sp) #fetch LHS of expression from memory + add $a0, $a0, $a1 #EXPR ADD + sw $a0 40($sp) #store RHS of expression in memory + lw $ra ($sp) # reset return address + lw $sp 4($sp) # reset stack pointer + jr $ra # return to our caller + li $v0 0 # return NULL zero (0) + lw $ra ($sp) # reset return address + lw $sp 4($sp) # reset stack pointer + jr $ra # return to our caller + + +main: #Start of Function + subu $t0 $sp 32 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address + sw $sp 4($t0) #Store the old stack pointer + move $sp $t0 # set the stack pointer to the new value + + + + li $a0 4 # expresion a number + sw $a0 12($sp) # stor arg value in our runtime stack + #set up the A0 - A3 registers to call function + lw $a0 12($sp) # load parameter value from stack into hand shake register + # about to call a function, set up each parameter in the new activation record + jal fib #jump and link to function + sw $a0, 16($sp) #store RHS value in memory + li $a0 8 #get Identifier offset + add $a0,$a0,$sp # we have direct reference to memory + lw $a1, 16($sp) # Get RHS stored value + sw $a1 ($a0) # ASSIGN final store + + li $a0 5 # expresion a number + #print an INT + li $v0 1 #set up write call + syscall + + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall + + + + la $a0 _L1 #get string address for print + li $v0, 4 #print a string + syscall + + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall + + li $a0 8 #get Identifier offset + add $a0,$a0,$sp # we have direct reference to memory + lw $a0 ($a0) #expression is identifier + #print an INT + li $v0 1 #set up write call + syscall + + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall + + + li $v0 0 # return NULL zero (0) + lw $ra ($sp) # reset return address + lw $sp 4($sp) # reset stack pointer + li $v0, 10 #Main function ends + syscall #MAIN FUNCTION EXITS diff --git a/9LAB/test5.decaf b/9LAB/test5.decaf new file mode 100644 index 0000000..2519c10 --- /dev/null +++ b/9LAB/test5.decaf @@ -0,0 +1,31 @@ +extern func print_int (int) void; +extern func print_string (string) void; +extern func read_int () int; + +package fibinaci { + var y int =7; + var Z int ; + var A[100] int ; + var x bool = true; + + func fib ( n int) int + { + print_string("in fib"); + if ( n <= 0) {return (0) ;} + if ( n == 1) {return (1) ;} + return( fib(n-1) + fib(n-2)); + + } // of fib + + func main () int + { + var x int; + x=fib(4); + print_int(5); + print_string("hello"); + print_int(x); + + } // of main + +} // of foo + diff --git a/9LAB/testy/Makefile b/9LAB/testy/Makefile new file mode 100644 index 0000000..a6acda3 --- /dev/null +++ b/9LAB/testy/Makefile @@ -0,0 +1,44 @@ +# Ziad Arafat +# Lab9 MIPS Code Generation from AST.c +# April 2021 + +# FLAGS = -O0 -Wall -Wextra -pedantic + +# the gcc options so I don't have to copy paste them everywhere +# any time I make changes to them. +FLAGS = -O0 -Wextra -pedantic + +# Entry point target +all: lab9 + +# Compile all the THINGS! +lab9: ast.c ast.h symtable.c symtable.h emit.c emit.h lex.yy.c y.tab.c + gcc $(FLAGS) y.tab.c lex.yy.c ast.c symtable.c emit.c -o lab9 -lm + +lex.yy.c: lab9.l + lex lab9.l + +y.tab.c: lab9.y + yacc -d --verbose --debug lab9.y + +# remove the binary and other generated stuff +clean: + rm -f lab9 lex.yy.c y.tab.c y.tab.h + +# runs valgrind to look for any memory mistakes +memcheck: + valgrind ./lab9 -s + +# executes our code to test it's functionality +test: + make clean + make + # ./lab9 -o foo < test.decaf + # ./lab9 -o bar < test1.decaf + # ./lab9 -o bar2 < test2.decaf + # ./lab9 -o bar3 < test3.decaf + ./lab9 -o bar4 < test4.decaf + # ./lab9 -o bar5 < test5.decaf + +debug: lab9 + ./lab9 -d -o bar < test.decaf \ No newline at end of file diff --git a/9LAB/testy/Screenshot from 2021-05-07 23-26-28.png b/9LAB/testy/Screenshot from 2021-05-07 23-26-28.png new file mode 100644 index 0000000000000000000000000000000000000000..dd4338a3f1e5a667b3106c1126efd36309a3079b GIT binary patch literal 15463 zcmeIZcT`i)*Ds7Bp!6ag0YO2e_b#GTX#yfG5CQ3g4xyu>^dh|zkuJTL(3D<7?+|+L zfsjyd@cVn#`;^~W@49Q z-DSbTx+8fX7gMwNZF?1SyXW#s`Q3fY<#YdIFs4lFDzE3N?O@>wHgPt`vb1*qnRC0C zIh&i?yI4869$>e;z`|n2QkIi_=aIHI?+JK!dfjz2*R8 zuRERENe@0rH{S)*1TLuxPK589OIOzRn7yE3A;V6Pz444;{%Z zTyw6aqi8tc>twq!N$Yl_8$5a1S-CgZ*r}E((bCv@6n5k_yA#gdBH^~L%T56iDzTNE zMs=9b1PXTOopcW3>z{-f1xE`_+%~a~Tbq`JV=~#XlQpH7?nE#H>UK+m7;%(4$VB zE@6>$>TMaE9 zho7I@n;rJoM&xBl6>4uJCa&%azwm$DS@(i#=sqEIVe{}0b>{-0jgO&)epCVoaz!8h zSQ29B{7h>UUMQ&{=m)OTFA2Y$x~Kn4U52k6E&q})_J@wSf<_TvGFyrStizc_zg%24 z4ybXOn9fEbD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dV#_mK{}PLaeMB8kTToA05|3attc9P9|63o7i8x4emnq8`kCEwu4lFvj zwlm3;;}6>>q($S}-rzHLTQ53(GQq+XdxT3I^o>&@%5;;$>D|?uuY&Z$u1|S^f-Y+& zHf}9p^u@TuDz6&|eLi*SUd#Vc0S|91ET|gP1!+@P#kLq7Tqbokr#?l1zdJvVPls@? zMJaIS?+7T|{d-mePhQiS;&?{{tSt|3pHz}`;M%UyhUgd6>T3Q69Ke-8rixDtl~GUfn9ULkO6mXbAl(}@$+nK^jeZq9>C z_mxL^K_Iy|p@Xu~eHl@_@8h)w4%p~)8QOkG0@;ccxL^?xnLp1va-M84JgncXf54J> z{*BW7YiV;^n^s2ZK0WO6q7hydta$qp-Ncpg>Rwl@@ouiT|Sn7`mZl< z@QGNy&HsFU`-J-`ng|mW-9`le@iE%}9tzj|f6e|6#WVkR&15HR_ik^>*w{PF{%~;r zOR?U&&BZWrCo@;}@Ti-9idkm>flEJCoxEV(98A*aXAHCY^fl)A0CQPiQgNfkcIhw? o-Ku~&KjFWsIsWzGB-%edBmpl4srMW6r7)JVyt-V;s}EoP7gITb0ssI2 literal 0 HcmV?d00001 diff --git a/9LAB/testy/Test.zip b/9LAB/testy/Test.zip new file mode 100644 index 0000000000000000000000000000000000000000..1c3cd39dd50a9e075620262f870c2f45270033d5 GIT binary patch literal 39660 zcmZ6RQTvf8%ar|)h}c4=xl zo`^UKDe&vdZ^~sB?;2RZyt+_f4Y@ppFp?1|R4E9bYk?`iuR5dZ4foEzx)@XuC@#Cb z7i?eH+$1o*>H~0Qh$P<30xhHwQX5aGEPy4#D%l=0wA38%v=D#Ff`)vrOHWn~luAXY zPI1GAK#t02PC`=8sOd8RhP-VN7NhGbVI{@%@!D2=tU(A zf>4AdyQ}vuJ^n7S1R~(Fs2hoIU*4EGB|H*Qj1~FA0T~Pydmsfbyg@*&Y_x1Ntijy` zOWb>;Pj_E{5)D=535X{eN$y7yi&9KJX5U-vBm8nxFDCA@oMaRp!933?pZfxL4SX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P?GPuRU32m0kOxV%jj7H~veA5pkB+ z(lB4yL1k@5%l@g6BU$t>1`y$zZujHlTeiE=yS1;S58>S7pBEV8p3(Ai1c}LrEVoTf zNPm({+p83>Ykp}6=K7#ztNaw+6)NeKMt%NAHgz7Fya1yC0N0mZRS6B997v8LGQtKp zqrwuT6M`P=^uq!tR2qm0S_5lWi^N%JQK(_d#vM2J$Xc;P6__rl5MkKYkF z3iY@D8&p>m>P?lgYc`(WRvqw`3;-~*f&KpSYADR#{%OO&nAdM6K;4{CiNQGe`qBRZPOw1R literal 0 HcmV?d00001 diff --git a/9LAB/testy/ast.c b/9LAB/testy/ast.c new file mode 100644 index 0000000..a6aa17e --- /dev/null +++ b/9LAB/testy/ast.c @@ -0,0 +1,378 @@ +/* Abstract syntax tree code + + This code is used to define an AST node, + routine for printing out the AST + defining an enumerated type so we can figure out what we need to + do with this. The ENUM is basically going to be every non-terminal + and terminal in our language. + + Shaun Cooper February 2020 + +*/ + +/* +Ziad Arafat - Apr 26 2021 +Lab 9 +*/ + +#include +#include +#include "ast.h" +// #include "symtable.h" + +/* uses malloc to create an ASTnode and passes back the heap address of the newley created node */ +ASTnode *ASTCreateNode(enum AST_Tree_Element_Type mytype) +{ + ASTnode *p; + if (mydebug) + fprintf(stderr, "Creating AST Node \n"); + p = (ASTnode *)malloc(sizeof(ASTnode)); // get head data + p->type = mytype; // set up the Element type + p->S1 = NULL; + p->S2 = NULL; // det default values + p->value = 0; + return (p); +} + +/* Helper function to print tabbing */ + +void PT(int howmany) +{ + for (int i = 0; i < howmany; i++) { + printf(" "); + } +} + +void AST_Print_Type(enum AST_Decaf_Types t) +{ + switch (t) { + case A_Decaf_INT: + printf(" INT "); + break; + case A_Decaf_BOOL: + printf(" BOOLEAN "); + break; + case A_Decaf_STRING: + printf(" STRING "); + break; + case A_Decaf_VOID: + printf(" VOID "); + break; + default: + fprintf(stderr, "Unknown AST DECAF TYPE !!!\n"); + } // of switch + +} // of AST_Print_Type + +/* Print out the abstract syntax tree */ +void ASTprint(int level, ASTnode *p) +{ + int i; + if (p == NULL) + return; + else { + PT(level); /* indent */ + switch (p->type) { + case A_VAR_RVALUE: + printf("Variable Right %s \n", p->name); + if (p->S1 != NULL) { + PT(level + 2); + printf("[\n"); + ASTprint(level + 2, p->S1); + PT(level + 2); + printf("]\n"); + } + break; + case A_VAR_LVALUE: + printf("Variable Left %s \n", p->name); + if (p->S1 != NULL) { + PT(level + 2); + printf("[\n"); + ASTprint(level + 2, p->S1); + PT(level + 2); + printf("]\n"); + } + break; + case A_PROGRAM: + // printf("PROGRAM \n"); + ASTprint(level + 1, p->S1); + ASTprint(level + 1, p->S2); + break; + case A_EXTERN: + printf("EXTERN FUNC %s\n", p->name); + // printf("\n"); + ASTprint(level + 1, p->S1); + // printf("\n"); + + printf("END EXTERN with Type:\n "); + AST_Print_Type(p->A_Declared_Type); + break; + + case A_PACKAGE: + printf("Package : %s\n", p->name); + PT(level + 2); + // printf("{\n"); + ASTprint(level + 1, p->S1); + ASTprint(level + 1, p->S2); + PT(level + 2); + printf("\n"); + break; + case A_ExternType: + printf("EXTERN Type "); + AST_Print_Type(p->A_Declared_Type); + printf("\n"); + + break; + case A_VARDEC: + printf("Variable "); + printf(" %s", p->name); + + if (p->S1 != NULL) { + printf("["); + printf("%d", p->S1->value); + printf("] "); + } + printf(" with type "); + AST_Print_Type(p->A_Declared_Type); + printf(" "); + if (p->S2 != NULL) { + printf("= %d", p->S2->value); + } + printf("\n"); + // ASTprint(level, p->S1); + break; + case A_METHODDEC: + printf("METHOD FUNCTION '%s' with type ", p->name); + AST_Print_Type(p->A_Declared_Type); + /* print out the parameter list */ + if (p->S1 == NULL) { + printf("\n"); + PT(level + 2); + printf(" (NONE) "); + } else { + printf("\n"); + PT(level + 2); + printf("(\n"); + ASTprint(level + 2, p->S1); + PT(level + 2); + printf(")"); + } + printf("\n"); + ASTprint(level + 2, p->S2); // print out the block + break; + + case A_METHODID: + PT(level + 2); + printf("Method ARG"); + // fixed for indentation there was a stupid space here + printf("%s", p->name); + AST_Print_Type(p->A_Declared_Type); + printf("\n"); + + break; + case A_PARAM: + printf("PARAMETER "); + if (p->operator== A_Decaf_INT) + printf(" INT "); + if (p->operator== A_Decaf_BOOL) + printf(" VOID "); + if (p->operator== A_Decaf_VOID) + printf(" BOOLEAN "); + printf("%s ", p->name); + if (p->value == -1) + printf("[]"); + ASTprint(level + 2, p->S1); + printf("\n"); + break; + case A_EXPR: + printf("EXPR "); + switch (p->operator) { + case A_PLUS: + printf(" + "); + break; + case A_MINUS: + printf(" - "); + break; + case A_DIVIDE: + printf(" / "); + break; + case A_EQ: + printf(" == "); + break; + case A_LEQ: + printf(" <= "); + break; + case A_GEQ: + printf(" >= "); + break; + case A_GT: + printf(" > "); + break; + case A_LT: + printf(" < "); + break; + case A_LEFTSHIFT: + printf(" << "); + break; + case A_RIGHTSHIFT: + printf(" >> "); + break; + case A_MOD: + printf(" %% "); + break; + case A_AND: + printf(" && "); + break; + case A_OR: + printf(" || "); + break; + case A_NEQ: + printf(" != "); + break; + case A_TIMES: + printf(" * "); + break; + case A_NOT: + printf(" !"); + break; + case A_UMINUS: + // print words so we know it's not just minus + printf(" Unary Minus"); + break; + default: + printf("Unknown EXPR Operator"); + } + printf("\n"); + ASTprint(level + 1, p->S1); + if (p->operator!= A_NOT && p->operator!= A_UMINUS) + ASTprint(level + 1, p->S2); + break; + case A_BLOCK: + printf("BLOCK STATEMENT \n"); + ASTprint(level + 1, p->S1); + ASTprint(level + 1, p->S2); + break; + case A_WHILESTMT: + printf("WHILE STATEMENT \n"); + ASTprint(level + 1, p->S1); + ASTprint(level + 2, p->S2); + break; + + case A_CONSTANT_INT: + printf("CONSTANT INTEGER %d\n", p->value); + break; + case A_CONSTANT_STRING: + printf("CONSTANT STRING %s\n", p->name); + break; + + case A_CONSTANT_BOOL: + printf("CONSTANT BOOLEAN "); + if (p->value == 1) { + printf("true\n"); + } else { + printf("false\n"); + } + break; + case A_BREAK: + printf("BREAK STATEMENT \n"); + break; + case A_RETURN: + printf("RETURN STATEMENT \n"); + ASTprint(level + 1, p->S1); + break; + case A_ASSIGN: + printf("ASSIGNMENT STATEMENT\n"); + ASTprint(level + 1, p->S1); + ASTprint(level + 1, p->S2); + break; + case A_IF: + printf("IF STATEMENT \n"); + ASTprint(level + 1, p->S1); + ASTprint(level + 1, p->S2); + break; + case A_IFBODY: + // printf("IF BODY \n"); + ASTprint(level + 1, p->S1); + ASTprint(level + 1, p->S2); + break; + + case A_ELSE: + printf("ELSE \n"); + ASTprint(level + 1, p->S1); + break; + case A_METHODCALL: + printf(" METHOD CALL name: %s\n", p->name); + PT(level); + printf("(\n"); + PT(level); + printf("METHOD ARG \n"); + ASTprint(level + 1, p->S1); + PT(level); + printf(")\n"); + break; + + default: + printf("unknown type in ASTprint\n"); + } + ASTprint(level, p->next); + } +} + +// checks that two nodes match in type and length +int check_parameters(ASTnode *formal, ASTnode *actual) +{ + if (actual == NULL && formal == NULL) { + return (1); + } + if (actual == NULL) { + return (0); + } + if (formal == NULL) { + return (0); + } + if (actual->A_Declared_Type != formal->A_Declared_Type) { + return (0); + } + return check_parameters(formal->next, actual->next); +} + +// created this because it was starting to look messy in yacc +// takes an operator and a type and returns 1 if they are compatible 0 if not +int check_operators(enum AST_Operators op, enum AST_Decaf_Types type) +{ + switch (op) { + // I did it. I found a case where having no break statement + // in a switch is useful. + // This is the same as using a bunch of || statements but its nice + // and vertical + case A_TIMES: + case A_DIVIDE: + case A_MOD: + case A_PLUS: + case A_MINUS: + if (type == A_Decaf_BOOL) { + return (0); + } + return (1); + break; // breaks probably redundant but adding then anyway + case A_AND: + case A_OR: + case A_RIGHTSHIFT: + case A_LEFTSHIFT: + if (type == A_Decaf_INT) { + return (0); + } + return (1); + break; + default: + return (1); + break; + } +} + +/* dummy main program so I can compile for syntax error independently + */ +// void main() +// { +// } +/* */ diff --git a/9LAB/testy/ast.h b/9LAB/testy/ast.h new file mode 100644 index 0000000..39c9f68 --- /dev/null +++ b/9LAB/testy/ast.h @@ -0,0 +1,127 @@ +/* Abstract syntax tree code + + + Header file + Shaun Cooper January 2020 + +*/ + +/* +Ziad Arafat - Apr 26 2021 +Lab 9 +4/3/2021 added variable to ASTnode to handle labels for strings + +*/ + +#include +#include + +#ifndef AST_H +#define AST_H +static int mydebug; + +/* define the enumerated types for the AST. THis is used to tell us what +sort of production rule we came across */ + +/* added all the needed tree nodes */ +enum AST_Tree_Element_Type { + A_PROGRAM, + A_EXTERN, + A_PACKAGE, + A_METHODDEC, + A_NUMBER, + A_WHILESTMT, + A_BLOCK, + A_EXPR, + A_PARAM, + A_VARDEC, + A_ExternType, + A_ARRAYTYPE, + A_METHODID, + A_CONSTANT_INT, + A_CONSTANT_BOOL, + A_CONSTANT_STRING, + A_BREAK, + A_VAR_RVALUE, + A_VAR_LVALUE, // added this to fix last lab + A_RETURN, + A_ASSIGN, + A_IF, + A_IFBODY, + A_ELSE, + A_METHODCALL, + A_CONTINUE + + // missing +}; + +/* Added all the needed operators */ +enum AST_Operators { + A_PLUS, + A_MINUS, + A_UMINUS, + A_TIMES, + A_DIVIDE, + A_MOD, + A_AND, + A_OR, + A_LEFTSHIFT, + A_RIGHTSHIFT, + A_LT, + A_GT, + A_EQ, + A_LEQ, + A_GEQ, + A_NEQ, + A_NOT + // missing +}; + +enum AST_Decaf_Types { + A_Decaf_INT, + A_Decaf_BOOL, + A_Decaf_VOID, + A_Decaf_STRING, + A_Decaf_CHAR + // missing +}; + +/* define a type AST node which will hold pointers to AST structs that will + allow us to represent the parsed code +*/ +typedef struct ASTnodetype { + enum AST_Tree_Element_Type type; + enum AST_Operators operator; + char *name; + int value; + struct SymbTab *symbol; + enum AST_Decaf_Types A_Declared_Type; + int size; + ///.. missing + struct ASTnodetype *S1, *S2, *next; /* used for holding IF and WHILE + components -- not very descriptive */ + char *label; +} ASTnode; + +#include "symtable.h" + +/* uses malloc to create an ASTnode and passes back the heap address of the + * newley created node */ +ASTnode *ASTCreateNode(enum AST_Tree_Element_Type mytype); + +void PT(int howmany); // prints howmany spaces + +ASTnode *program; // Global Pointer for connection between YACC and backend + +/* Print out the abstract syntax tree */ +void ASTprint(int level, + ASTnode *p); // prints tree with level horizontal spaceing + +// checks that two nodes match in type and length +int check_parameters(ASTnode *formal, ASTnode *actual); + +// created this because it was starting to look messy in yacc +// takes an operator and a type and returns 1 if they are compatible 0 if not +int check_operators(enum AST_Operators op, enum AST_Decaf_Types type); + +#endif // of AST_H diff --git a/9LAB/testy/bar4.asm b/9LAB/testy/bar4.asm new file mode 100644 index 0000000..2a2c3e7 --- /dev/null +++ b/9LAB/testy/bar4.asm @@ -0,0 +1,186 @@ +# PACKAGE foo + +.data # Data section starts here, strings first + +_L0: .asciiz "x is 5" +_L1: .asciiz "x is not 5" +_L2: .asciiz "hello, what is the meaning of life: " +_L3: .asciiz "The meaning of life is: " +_NL: .asciiz "\n" # NEWLINE STRING + +.align 2 # start all global variable aligned + +y: .word 7 # global var initialized +Z: .space 4 # global var uninitialized +A: .space 400 # global var uninitialized +x: .word 1 # global var initialized + + +.text # start of text segment (code) + +.globl main # Force MIPS to start at main label + + + +dothis: # MAIN METHOD LABEL + + subu $t0 $sp 24 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + li $a0, 12 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 16($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 5 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 16($sp) #get LHS from storage + seq $a0, $a0, $a1 #equal to + beq $a0 $0 _L4 #Branch to first label if expression is 0 + la $a0, _L0 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + j _L5 #And the cow jumped over the else 🐄 +_L4: #First Label for entering else + la $a0, _L1 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + +_L5: #Second Label for jumping over the else + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + + +main: # MAIN METHOD LABEL + + subu $t0 $sp 60 #set up $t0 to be the new spot for SP + sw $ra ($t0) #Store the return address in offset 0 + sw $sp 4($t0) #Store the old stack pointer in offset 4 + move $sp $t0 #set the stack pointer to the new value + + + la $a0, _L2 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + li $v0, 5 #read int from user + syscall #to read a number + move $a0, $v0 #Move the number into $a0 + sw $a0 16($sp) #store RHS of assign temporarily + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a1, 16($sp) #load back RHS into $a1 + sw $a1, ($a0) #Store assign value + la $a0, _L3 #expr constant is a string + li $v0 4 #set up write call + syscall #print a string + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + #EMIT PRINT INT HERE + li $a0, 24 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + li $v0 1 #set up write call + syscall #print a number + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + li $a0, 0 #expr constant value + sw $a0 28($sp) #store RHS of assign temporarily + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a1, 28($sp) #load back RHS into $a1 + sw $a1, ($a0) #Store assign value +_L6: #First label to restart while loop's block + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 32($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 0 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 32($sp) #get LHS from storage + sgt $a0, $a0, $a1 #greater than + beq $a0 $0 _L7 #Branch to second label if expression is 0 + #EMIT PRINT INT HERE + li $a0, 36 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + li $v0 1 #set up write call + syscall #print a number + li $v0, 4 #print NEWLINE + la $a0, _NL #print NEWLINE string location + syscall #call print a NEWLINE + + + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 40($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 1 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 40($sp) #get LHS from storage + sub $a0, $a0, $a1 #subact + sw $a0 44($sp) #store RHS of assign temporarily + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a1, 44($sp) #load back RHS into $a1 + sw $a1, ($a0) #Store assign value + j _L6 #And the little dog laughed to see such loops +_L7: #Second label to jump to from the exit condition + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a0 ($a0) #load from the memory address a value + sw $a0, 36($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 1 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 36($sp) #get LHS from storage + add $a0, $a0, $a1 #add + sw $a0, 40($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 2 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 40($sp) #get LHS from storage + sub $a0, $a0, $a1 #subact + sw $a0, 44($sp) #store $a0 (LHS) temporarily so we can eval RHS + li $a0, 5 #expr constant value + move $a1, $a0 #move RHS to $a1 + lw $a0, 44($sp) #get LHS from storage + add $a0, $a0, $a1 #add + sw $a0 48($sp) #store RHS of assign temporarily + li $a0, 8 #offset for variable address + add $a0, $a0, $sp #exact location for stack variable + lw $a1, 48($sp) #load back RHS into $a1 + sw $a1, ($a0) #Store assign value + li $a0, 5 #expr constant value + sw $a0, 52($sp) #Store the argument value in the stack + li $a0, 1 #expr constant value + sw $a0, 56($sp) #Store the argument value in the stack + li $a0, 5 #expr constant value + lw $a0, 52($sp) #load the argument from the stack to a0, a1, a2, a3 respectively and as necessary + li $a0, 1 #expr constant value + lw $a1, 56($sp) #load the argument from the stack to a0, a1, a2, a3 respectively and as necessary + li $v0 0 #return NULL zero (0) + lw $ra ($sp) #reset return address + lw $ra 4($sp) #reset stack pointer + li $v0, 10 #Main function ends + syscall #MAIN FUNCTION EXIT diff --git a/9LAB/testy/emit.c b/9LAB/testy/emit.c new file mode 100644 index 0000000..6099991 --- /dev/null +++ b/9LAB/testy/emit.c @@ -0,0 +1,750 @@ + + +// Subprograms which output MIPS code. +// +// Shaun Cooper Spring 2015 +/// Updated Spring 2017 to utilize the data segement portion of MIPS instead of +/// advancing the Stack and Global pointers to accomodate global variables. +// Shaun Cooper December 2020 updated for DECAF format +/* +Ziad Arafat - Apr 26 2021 +Lab 9 +Apr 26 2021: + - Implemented emit_all() + - emit package name comment + - emit data section comments + - emit globals comments + - emit text (code) section comments +May 3 2021: + - Implemented emit_strings() + - Implemented emit_global() +*/ + +#include +#include +#include + +#include "ast.h" +#include "emit.h" + +/* Function prototypes for functions only used internally */ + +// PRE: An integer indicating number of newlines +// POST: Emit x number of newlines to the asm +void emit_nl(int x); + +// PRE: ptr to ASTnode +// POST: all MIPS code in fp file relating to the decaf AST +void emit_mips(ASTnode *p); // emits the mips code in text section + +// PRE: ptr to ASTnode +// POST: MIPS code needed for a method call to work. +void emit_method_call(ASTnode *p); // handles emiting method calls + +// PRE: ptr to ASTnode +// POST: inline MIPS code that generates the print +void emit_print_string(ASTnode *p); // handles the print_string methods + +// PRE: ptr to METHOD_CALL that is named print_int +// POST: inline MIPS code that generates the print +void emit_print_int(ASTnode *p); // handles the print_int methods + +// PRE: ptr to method call read_int +// POST: $a0 will be the value read +void emit_read_int(ASTnode *p); // handles the print_int methods + +// PRE: ptr to an expression +// POST: MIPS code such that $a0 has the value of the expr in p +void emit_expr(ASTnode *p); + +// PRE: ptr to an identifier. (LVALUE or RVALUE) +// POST: $a0 is thje memory address of the identifier +void emit_ident(ASTnode *p); + +// PRE: PTR to an enture AST +// POST: output to ASMS file that prints labels and the strings associated +// Each ASTnode that is a string will have p->label updated +// be that generated label +// We need that assignment later so that we can access the string +// via the label +void emit_strings(ASTnode *p); + +// PRE: ptr to an ASTnode +// POST: output to the data section for those nodes +// as A_VARDEC with level 0 +// produce different output for assigned values to scalars. +// +void emit_global(ASTnode *p); // emits the global/static variables + +// PRE: P is ptr to A_ASSIGN +// POST: MIPS code in fp that assigns a value +void emit_assign(ASTnode *p); + +// PRE: ptr to an ASTnode for A_IF +// POST: emit the MIPS code needed for an if/else statement to fp +void emit_if(ASTnode *p); + +// PRE: ptr to an A_WHILE ASTnode +// POST: emit the MIPS assembly needed to do a while loop to fp +void emit_while(ASTnode *p); + +// PRE: ptr to an ASTnode of an A_VAR_LVALUE or A_VAR_RVALUE of an array +// POST: emit the proper evaluation of the array index to MIPS code in fp +void emit_array(ASTnode *p); + +// PRE: ptr to an ASTnode of type A_RETURN +// POST: emit mips code that will return the current function +void emit_return(ASTnode *p); + +FILE *fp = NULL; // Pointer to the assembly file we want to emit to + +static int GLABEL = 0; // global label counter + +// PRE: no input +// POST: char i* to a one up string of the form "_L%d" +char *GEN_LABEL() +{ + char label_num[100]; + + // sprintf() is kinda like fprintf but instead of directing + // to a file it's going to a string + // Now we insert GLABEL using the formatter. + sprintf(label_num, "_L%d", GLABEL); + + // increment GLABEL for next time we get called + GLABEL++; + + return strdup(label_num); +} + +// PRE: A pointer to the top of our AST for DECAF +// POST: Mips code which implements the DECAF representation +void emit_all(ASTnode *p) +{ + fprintf(fp, "# PACKAGE %s \n\n", p->S2->name); + fprintf(fp, ".data\t# Data section starts here, strings first \n\n"); + + // print all strings + emit_strings(p); + fprintf(fp, "_NL: .asciiz \"\\n\" # NEWLINE STRING \n\n"); + fprintf(fp, ".align 2 # start all global variable aligned\n\n"); + + // print all globals + emit_global(p); + fprintf(fp, "\n\n.text # start of text segment (code)\n\n"); + fprintf(fp, ".globl main # Force MIPS to start at main label\n\n"); + // TODO: print out the text (mips) + emit_mips(p); // prints out the mips code in the text segment. +} + +// PRE: PTR to an entire AST (p is the entry point) +// POST: output to ASM file that prints labels and the strings associated +// Each ASTnode that is a string will have p->label updated +// be that generated label +// We need that assignment later so that we can access the string +// via the label + +void emit_strings(ASTnode *p) +{ + if (p == NULL) { + return; + } + if (p->type == A_CONSTANT_STRING) { + p->label = GEN_LABEL(); + fprintf(fp, "%s:\t.asciiz\t%s\n", p->label, p->name); + } + + emit_strings(p->S1); + emit_strings(p->S2); + emit_strings(p->next); +} +// emits the global/static variables +// PRE: ptr to an ASTnode +// POST: output to the data section for those nodes +// as A_VARDEC with level 0 +// produce different output for assigned values to scalars. +// +void emit_global(ASTnode *p) +{ + // make sure node is not null + if (p == NULL) { + return; + } + + // if it's a vardec and the level is 0 that means its a global variable + if ((p->type == A_VARDEC) && + (p->symbol->level == + 0)) { // if there's an assignment set it to a word + if (p->S2 != NULL) { + fprintf(fp, + "%s:\t.word %d\t # global var initialized\n", + p->name, p->S2->value); + } else { + // else if there is no assignment allocate empty space of the + // true size of the variable. + fprintf(fp, + "%s:\t.space %d\t # global var uninitialized\n", + p->name, p->size * WS); + } + } + + // call again on S1, S2, and next + emit_global(p->S1); + emit_global(p->S2); + emit_global(p->next); +} + +// PRE label, code, comment +// POST: output to file with ASM formatted output +// +// This is a general command to emit code to the asm with labels and comments +// L: the label (string) +// I: The instruction (string) +// C: The comment (string) +// to omit any of them pass an empty string +void emit(char *L, char *I, char *C) +{ + if (L != "") { + fprintf(fp, "%s:\t%s\t\t #%s\n", L, I, C); + } else { + fprintf(fp, "\t%s\t\t #%s\n", I, C); + } +} + +// PRE: ptr to a method decl +// POST: MIPS code for the method +void emit_method_dec(ASTnode *p) +{ + char s[100]; + fprintf(fp, "\n\n%s:\t\t# MAIN METHOD LABEL\n\n", p->name); + + // set up activation record + + sprintf(s, "subu $t0 $sp %d", + p->symbol->mysize * WS); // makes the subu size dynamic + emit("", s, "set up $t0 to be the new spot for SP"); + emit("", "sw $ra ($t0)", "Store the return address in offset 0"); + emit("", "sw $sp 4($t0)", "Store the old stack pointer in offset 4"); + emit("", "move $sp $t0", "set the stack pointer to the new value"); + emit_nl(2); + + // hand shake for entry into a method. + + // p->S1 is the parameter for the method stored in the activation record + // p->S2 is the block of code of the function + emit_mips(p->S2); // emit the block of the function + + // deal with the return to other method or return to system + + emit("", "li $v0 0", "return NULL zero (0)"); + emit("", "lw $ra ($sp) ", "reset return address "); + emit("", "lw $ra 4($sp)", "reset stack pointer "); + + // Special MIPS stop which has code 10 -- Only done in end of MAIN function + // syscall will stop when v0 is 10 + if (strcmp(p->name, "main") == 0) { + emit("", "li $v0, 10", "Main function ends "); + emit("", "syscall", "MAIN FUNCTION EXIT "); + } +} + +// PRE: ptr to ASTnode +// POST: all MIPS code in fp file relating to the decaf AST +// This is the main hub for selecting the correct method to +// emit nodes +void emit_mips(ASTnode *p) +{ // emits the mips code in text section + if (p == NULL) { + return; + } + + // Change print method depending on the Node type + switch (p->type) { + case A_PROGRAM: + emit_mips(p->S2); + break; + case A_PACKAGE: + // S1 is fielddecs because they have already been added in .global + emit_mips(p->S2); // print the method decls + break; + case A_METHODDEC: // call the helper for printing methods + emit_method_dec(p); + break; + case A_BLOCK: // handle blocks + // p->S1 are local variables, handled by activation rec. + emit_mips(p->S2); + break; + + case A_METHODCALL: // handle method calls + emit_method_call(p); + break; + case A_ASSIGN: + emit_assign(p); // emit the assign mips code + break; + case A_IF: + emit_if(p); // emit the if statement logic mips code + break; + case A_WHILESTMT: + emit_while(p); // emit the while statement mips code. + break; + // case A_RETURN: + // emit_return(p); // emit the while statement mips code. + // break; + default: + // if none of the cases match print a warning. + printf("emit_mips UNKNOWN AST type\n"); + } + + emit_mips(p->next); +} + +// PRE: ptr to ASTnode +// POST: MIPS code needed for a method call to work. +// +// Note: for print_int(), print_string(), and read_int(), we will +// inline code these methods all others are handled with evaluating +// the params, placing them in appropriate registers and calling +// the method named +void emit_method_call(ASTnode *p) // handles emiting method calls +{ // Pre defined function call routines + // picked based on the method call's name. + if (strcmp(p->name, "print_int") == 0) { + emit_print_int(p); + } else if (strcmp(p->name, "print_string") == 0) { + emit_print_string(p); + } else if (strcmp(p->name, "read_int") == 0) { + emit_read_int(p); + } else { + // printf("NO METHOD CALL IMPLEMENTED for %s YET\n", p->name); + char s[100]; + + // use a cursor for traversing linked lists. + // this way we can traverse all the arguments efficiently + ASTnode *cursor = p->S1; + + while (cursor != NULL) { + emit_expr(cursor); // evaluate the argument + + // store the argument in the stack pointer in it's offset + sprintf(s, "sw $a0, %d($sp)", + cursor->symbol->offset * WS); + emit("", s, "Store the argument value in the stack"); + + // go to next argument + cursor = cursor->next; + } + + int num = 0; // keep track of which register $a0-$a3 + + cursor = p->S1; + while (cursor != NULL) { + // We only have 4 registers to use for this. + // make sure we only use 4 + if (num >= 4) { + printf("Too many arguments in function %s \n", + p->name); + exit(1); + } + + emit_expr( + cursor); // evaluate the argument and store in $a0 + + // load the arguments from the stack pointers into + // their $a0-$a3 registers + sprintf(s, "lw $a%d, %d($sp)", num, + cursor->symbol->offset * WS); + emit("", s, + "load the argument from the stack to a0, a1, a2, a3 respectively and as necessary"); + + // go to the next argument. + cursor = cursor->next; + + // go to the next register + num++; + } + } +} + +// PRE: ptr to METHOD_CALL that is named print_string +// POST: inline MIPS code that generates the print +void emit_print_string(ASTnode *p) // handles the print_string methods +{ + emit_expr(p->S1); // $a0 will be the value in print_int + emit("", "li $v0 4", "set up write call"); + emit("", "syscall", "print a string"); + + emit("", "li $v0, 4", "print NEWLINE"); + emit("", "la $a0, _NL", "print NEWLINE string location"); + emit("", "syscall", "call print a NEWLINE"); + emit_nl(2); +} + +// PRE: ptr to METHOD_CALL that is named print_int +// POST: inline MIPS code that generates the print +void emit_print_int(ASTnode *p) // handles the print_int methods +{ + emit("", "", "EMIT PRINT INT HERE"); + emit_expr(p->S1); // $a0 will be the value in print_int + emit("", "li $v0 1", "set up write call"); + emit("", "syscall", "print a number"); + + emit("", "li $v0, 4", "print NEWLINE"); + emit("", "la $a0, _NL", "print NEWLINE string location"); + emit("", "syscall", "call print a NEWLINE"); + emit_nl(2); +} + +// PRE: ptr to an expression +// POST: MIPS code such that $a0 has the value of the expr in p +void emit_expr(ASTnode *p) +{ + char s[100]; + + if (p == NULL) { + printf("Illegal use of emit_expr NULL input"); + exit(1); + } + + // handle bas e cases + // no default case because that will be the recursive call + switch (p->type) { + case A_CONSTANT_INT: + case A_CONSTANT_BOOL: + sprintf(s, "li $a0, %d", p->value); + emit("", s, "expr constant value"); + return; + break; + case A_CONSTANT_STRING: + sprintf(s, "la $a0, %s", p->label); + emit("", s, "expr constant is a string"); + return; + break; + case A_METHODCALL: + emit_method_call(p); // $a0 will be the result value + return; + break; + case A_VAR_RVALUE: + case A_VAR_LVALUE: + emit_ident(p); // $a0 now contains the memory address + emit("", "lw $a0 ($a0)", + "load from the memory address a value"); + return; + break; + } + + // In our A_EXPR we need to eval S1 and perhaps S2 + // if there is an RHS + emit_expr(p->S1); // $a0 will now contain the LHS + + // check if there is a RHS. + // + // if there is an RHS store the LHS then eval the RHS + + if (p->S2 != NULL) { + // Store LHS in stack temporarily to make space for LHS + sprintf(s, "sw $a0, %d($sp)", p->symbol->offset * WS); + emit("", s, "store $a0 (LHS) temporarily so we can eval RHS"); + + emit_expr(p->S2); // Now $a0 has the RHS + + // PUT RHS in $a1 + emit("", "move $a1, $a0", "move RHS to $a1"); + + // Load LHS into $a0 + sprintf(s, "lw $a0, %d($sp)", p->symbol->offset * WS); + emit("", s, "get LHS from storage"); + // List of operators + switch (p->operator) { + case A_PLUS: + emit("", "add $a0, $a0, $a1", "add"); + break; + + case A_MINUS: + emit("", "sub $a0, $a0, $a1", "subact"); + break; + + case A_LT: + emit("", "slt $a0, $a0, $a1", "less than"); + break; + + case A_GT: + emit("", "sgt $a0, $a0, $a1", "greater than"); + break; + + case A_LEQ: + emit("", "sle $a0, $a0, $a1", "less than or eq to"); + break; + + case A_GEQ: + emit("", "sge $a0, $a0, $a1", "greater than or eq to"); + break; + + case A_EQ: + emit("", "seq $a0, $a0, $a1", "equal to"); + break; + + case A_NEQ: + emit("", "sne $a0, $a0, $a1", "Not equal"); + break; + + case A_TIMES: + break; + + case A_DIVIDE: + break; + + case A_MOD: + break; + + case A_OR: + emit("", "or $a0, $a0, $a1", "OR"); + break; + + case A_AND: + emit("", "and $a0, $a0, $a1", "AND"); + break; + + case A_LEFTSHIFT: + emit("", "sllv $a0, $a0, $a1", "LEFTSHIFT"); + break; + + case A_RIGHTSHIFT: + emit("", "srlv $a0, $a0, $a1", "RIGHTSHIFT"); + break; + + case A_UMINUS: + emit("", "neg $a0, $a0", " UNARY MINUS"); + break; + + default: + printf("Exist EXPR operator unknown"); + } + } +} + +// PRE: An integer indicating number of newlines +// POST: Emit x number of newlines to the asm +void emit_nl(int x) +{ + for (int i = 0; i < x; i++) { + fprintf(fp, "\n"); + } +} + +// PRE: ptr to an identifier. (LVALUE or RVALUE) +// POST: $a0 is thje memory address of the identifier +void emit_ident(ASTnode *p) +{ + // If it's an array we have a separate method for it + if (p->symbol->SubType == ID_Sub_Type_Array) { + emit_array(p); + return; + } + char s[100]; + + // check if it's being used incorrectly + // Can only be used on a LHS or RHS node + if (p->type != A_VAR_LVALUE && p->type != A_VAR_RVALUE) { + printf("Illegal use of emit_ident\n"); + exit(1); + } + + // Check if it's a global variable + if (p->symbol->level == 0) { + // load in the address using the name from the symtable + sprintf(s, "la $a0, %s", p->name); + emit("", s, "load global address of variable"); + } else { // else if it's a local variable + + // load the true offset into $a0 + sprintf(s, "li $a0, %d", p->symbol->offset * WS); + emit("", s, "offset for variable address"); + + // add the true offset to the stack pointer value + emit("", "add $a0, $a0, $sp", + "exact location for stack variable"); + } +} + +// PRE: P is ptr to A_ASSIGN +// POST: MIPS code in fp that assigns a value. +void emit_assign(ASTnode *p) +{ + char s[100]; + // make sure node is type A_ASSIGN + if (p->type != A_ASSIGN) { + printf("Illegal use of emit_assign"); + exit(1); + } + + // get value for RVALUE + // Store it temporarily so that LHS doesn't overwrite $a0 + // get the address of LHS + // retrieve value from memory + // store ther value at the address of LHS + emit_expr(p->S2); // expression of the assign + + // store it into the holding spot in memory + // + sprintf(s, "sw $a0 %d($sp)", p->symbol->offset * WS); + emit("", s, "store RHS of assign temporarily"); + + emit_ident(p->S1); // get address of LHS + + sprintf(s, "lw $a1, %d($sp)", p->symbol->offset * WS); + + emit("", s, "load back RHS into $a1"); + + emit("", "sw $a1, ($a0)", "Store assign value"); +} + +// PRE: ptr to method call read_int +// POST: $a0 will be the value read +void emit_read_int(ASTnode *p) // handles the print_int methods +{ + emit("", "li $v0, 5", "read int from user"); + emit("", "syscall", "to read a number"); + emit("", "move $a0, $v0", "Move the number into $a0"); +} + +// PRE: ptr to an ASTnode for A_IF +// POST: emit the code needed for an if/else statement +// Two labels, a branch, and jump are used to navigate +// the logic of an if else statemtent. +void emit_if(ASTnode *p) +{ + char s[100]; + + // Generate the two labels + char *label_one = GEN_LABEL(); + char *label_two = GEN_LABEL(); + + // $a0 will now contain the evaluated expression + emit_expr(p->S1); + + // Branch when the expression is equal to 0 + // to the first label in order to skip over the if block + // and execute the else block + sprintf(s, "beq $a0 $0 %s", label_one); + emit("", s, "Branch to first label if expression is 0"); + + emit_mips(p->S2->S1); // emit the if's main block + + sprintf(s, "j %s", + label_two); // Jump to the second label to skip else + emit("", s, "And the cow jumped over the else 🐄"); + + // sandwich the else between the first and second label + // This allows us to either enter the else or skip to after it. + emit(label_one, "", "First Label for entering else"); + + // Let's only emit the else if the else block is there. + if (p->S2->S2 != NULL) { + emit_mips(p->S2->S2); // emit else block + } // if there is no else block it will just be an empty label sandwich + + emit(label_two, "", "Second Label for jumping over the else"); +} + +// PRE: ptr to an A_WHILE ASTnode +// POST: emit the MIPS assembly needed to do a while loop to fp +void emit_while(ASTnode *p) +{ + char s[100]; + + // Generate the two labels + char *label_one = GEN_LABEL(); + char *label_two = GEN_LABEL(); + + emit(label_one, "", "First label to restart while loop's block"); + + // now the expression is evaluated in $a0 + emit_expr(p->S1); + + // Branch equal to 0 to the second label this is the exit condition + sprintf(s, "beq $a0 $0 %s", label_two); + emit("", s, "Branch to second label if expression is 0"); + + // emit the body of the while loop + emit_mips(p->S2); + + // jump back up to the start of the loop using first label + sprintf(s, "j %s", + label_one); // Jump to the first label to repeat + emit("", s, "And the little dog laughed to see such loops"); + + // emit the second label used to skip over the while body + emit(label_two, "", "Second label to jump to from the exit condition"); +} + +// PRE: ptr to an ASTnode of an A_VAR_LVALUE or A_VAR_RVALUE of an array +// POST: emit the proper evaluation of the array index to MIPS code in fp +// at the end of this function $a0 will have the true address of the +// item indexed in the array +void emit_array(ASTnode *p) +{ + // Copied the code from emit_ident + // 1. Evaluate the expression in the array index argument + // 2. multiply it by WS and store it in a new register $t3 + // 3. load the starting address of the array + // 4. add the product result to the address to the get the offset + // of the index in the argument + + char s[100]; + + // check if it's being used incorrectly + // Can only be used on a LHS or RHS node + if (p->type != A_VAR_LVALUE && p->type != A_VAR_RVALUE) { + printf("Illegal use of emit_ident\n"); + exit(1); + } + + emit_expr(p->S1); // Expression is evaluated in $a0 + + // Check if it's a global variable + if (p->symbol->level == 0) { + // Multiply the index evaluated by 4 to get the real offset + // Stored in a secondary register + emit("", "sll $a1, $a0, 2", "Multiply by 4"); + + // load in the starting offset of the array + sprintf(s, "la $a0, %s", p->name); + emit("", s, "load global address of array"); + + // add the relative offset of the index to the starting offset + // of the array store in $a0 + emit("", "add $a0, $a0, $a1", ""); + + } else { // else if it's a local variable + // Multiply the index evaluated by 4 to get the real offset + // Stored in a secondary register + emit("", "sll $a1, $a0, 2", "Multiply by 4"); + + sprintf(s, "li $a0, %d", p->symbol->offset * WS); + emit("", s, "offset for variable address"); + emit("", "add $a0, $a1, $sp", + "exact location for stack variable"); + } +} + +// PRE: ptr to an ASTnode of type A_RETURN +// POST: emit mips code that will return the current function +void emit_return(ASTnode *p) +{ + /* + li $v0 0 # return NULL zero (0) + lw $ra ($sp) # reset return address + lw $sp 4($sp) # reset stack pointer + jr $ra # return to our caller + */ + if (p->S1 != NULL) { + char s[100]; + emit_expr(p->S1); + emit("", "move $v0, $a0", "emit the expression in $a0"); + } else { + emit("", "li $v0 0", "return null "); + } + emit("", "lw $ra ($sp)", " reset return address "); + emit("", "lw $sp 4($sp)", "reset stack pointer "); + emit("", "jr $ra ", "return to our caller"); +} diff --git a/9LAB/testy/emit.h b/9LAB/testy/emit.h new file mode 100644 index 0000000..463d97c --- /dev/null +++ b/9LAB/testy/emit.h @@ -0,0 +1,61 @@ + + +// Subprograms which output NASM code. +// +// Shaun Cooper Spring 2017 +/// Updated Spring 2017 to utilize the data segement portion of NASM instead of +/// advancing the Stack and Global pointers to accomodate global variables. + +// NASM is called on linux as +// gcc foo.s +/* +Ziad Arafat - Apr 26 2021 +Lab 9 +Apr 26 2021: + - prototyped emit_all() + - prototyped GEN_LEBEL() + +*/ + +#include +#include +#include + +#ifndef EMIT_H +#define EMIT_H + +#include "ast.h" +#include "symtable.h" +#define WSIZE 4 // number of bytes in a word +#define WS 4 // number of bytes in a word +#define LOGWSIZE 2 // number of shifts to get to WSIZE +extern FILE *fp; + +// PRE: no input +// POST: char i* to a one up string of the form "_L%d" +char *GEN_LABEL(); + +// PRE: A pointer to the top of our AST for DECAF +// POST: Mips code which implements the DECAF representation + +void emit_all(ASTnode *p); + +// PRE: PTR to an enture AST +// POST: output to ASMS file that prints labels and the strings associated +// Each ASTnode that is a string will have p->label updated +// be that generated label +// We need that assignment later so that we can access the string +// via the label +void emit_strings(ASTnode *p); + +// PRE: ptr to an ASTnode +// POST: output to the data section for those nodes +// as A_VARDEC with level 0 +// produce different output for assigned values to scalars. +// +void emit_global(ASTnode *p); // emits the global/static variables + + + + +#endif // of EMIT.h diff --git a/9LAB/testy/lab9 b/9LAB/testy/lab9 new file mode 100755 index 0000000000000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;8MAfKO5=vh@W&20_>-#UA_mR7py|};D4rHH$4`wy1y$8x%+7*}Bzc(rKScDs zie4RBL`H9mJkenW7L>7`6v>kOXXL)mAIVfj1ao| z*Yp3F@b?Lw+PBOK|Fj4ueyrv+=%{1oCazuNO;p0)&!s9>RY>;Ia=uXaBdzHAweE)zzHbo?uN3W;|7 z^m5Vly}4&Cg-fq_jp_Pc5#m=nq6_bm{~UN}>}dTpd!ugwM3^JxAjsuV8-Lo5KS3Fh zD8Jez&3&7=8v9$@t??_M3G>(NmrfD4G3RYmJ1U>X|BjL{zkaVjf6B7Fr^aa$%BS#u zB0-q8U%x-Sb;?q#TVrEA#x)`FMZ{G91_xJuz0S3mXensyA)#qoVvq6Dl5+}G?@CMG zryUY5ihsvaJmHLAmzL~;T#PtRKWF(rv`Vt zzfkKKn^%5~`-R_@){jf&#&@j}N|BQ_d*|UFk`Jgy>moVj>YwB}DrUN~!oNg599|AI pkDrb|9TzmeIj6|{=U(E-e8ZUl-S&6R!+-qWEWg@m*j!^@|1ano%k}^O literal 0 HcmV?d00001 diff --git a/9LAB/testy/lab9.l b/9LAB/testy/lab9.l new file mode 100644 index 0000000..b0a425f --- /dev/null +++ b/9LAB/testy/lab9.l @@ -0,0 +1,155 @@ +/* Small LEX routine which returns two formal tokens (INTEGER and VARIABLE) + along with single string elements like '+'. + + This LEX definition is the companion to the docalc.y YACC routine which + is a simple calculator + + Shaun Cooper + January 2015 +*/ + +/* Ziad Arafat Mar 8 2021 */ + +%{ + +#include "ast.h" +#include "y.tab.h" +#include +int yylex(); +static int mydebug=0; + +int aHexToInt(char * hexstr) +{ + // I used the code we used in one of the 273 labs and adapted it to + // work on any number of chars. + + // Uses the difference of the ASCII table values of the chars to get + // the value. + + size_t len = strlen(hexstr)-1; + int mult = 1; + int val = 0; + + // since we already check to make sure it's 0-9 we don't need to + // exclude the x in 0x and obviously the 0 will make no change to the + // value. + if (*(hexstr + len) >= '0' && *(hexstr + len) <= '9') val = (*(hexstr + len) - '0') * mult; + else if (*(hexstr + len) >= 'a' && *(hexstr + len) <= 'f') val = (*(hexstr + len) - 'a' + 10) * mult; + else if (*(hexstr + len) >= 'A' && *(hexstr + len) <='F') val = (*(hexstr + len) - 'A' + 10) * mult; + + mult *= 16; + + char *hexstrptr; + for (hexstrptr = hexstr+(len-1); hexstrptr != hexstr; hexstrptr--){ + if (*hexstrptr >= '0' && *hexstrptr <= '9') val += (*hexstrptr - '0') * mult; + else if (*hexstrptr >= 'a' && *hexstrptr <= 'f') val += (*hexstrptr - 'a' + 10) * mult; + else if (*hexstrptr >= 'A' && *hexstrptr <='F') val += (*hexstrptr - 'A' + 10) * mult; + mult *= 16; + } + + // printf("The hex value is: %d\n", val); + + return val; +} + +%} + +/* +CHANGES: + - added the DECAF tokens + - Added some debug prints to the tokens + - Added square brackets to the lex directive + - Added '<' token to the directive + - Added modulus '%' + - Added directive for HEX numbers + - Created function to convert hex numbers to their int value + - Disabled the newline return token +*/ + + +%% +"&&" {return(T_AND);} + +"=" { + if (mydebug) fprintf(stderr,"T_ASSIGN found\n"); + return(T_ASSIGN); +} + +"bool" {return(T_BOOLTYPE);} +"break" {return(T_BREAK);} +"continue" {return(T_CONTINUE);} +"else" {return(T_ELSE);} +"==" {return(T_EQ);} +"extern" {return(T_EXTERN);} +"false" {return(T_FALSE);} +"func" {return(T_FUNC);} +">=" {return(T_GEQ);} + + +"if" {if (mydebug) fprintf(stderr,"T_IF found\n");return(T_IF);} + +"int" { + if (mydebug) fprintf(stderr,"T_INTTYPE found\n"); + return(T_INTTYPE); + +} + +"<<" {return(T_LEFTSHIFT);} +"<=" {return(T_LEQ);} +"!=" {return(T_NEQ);} +"||" {return(T_OR);} +"package" {return(T_PACKAGE);} +"return" {return(T_RETURN);} +">>" {return(T_RIGHTSHIFT);} +"string" {return(T_STRINGTYPE);} +"true" {return(T_TRUE);} +"var" {if (mydebug) fprintf(stderr,"T_VAR found\n");return(T_VAR);} +"void" {if (mydebug) fprintf(stderr,"T_VOID found\n");return(T_VOID);} +"while" {return(T_WHILE);} + + +\".*\" { + yylval.string=strdup(yytext); + return(T_STRINGCONSTANT); +} + +[a-zA-Z][a-zA-Z0-9_]* { + if (mydebug) { + fprintf(stderr,"Identifier found %s\n", yytext); + } + yylval.string=strdup(yytext); + return(T_ID); +} + +0x[0-9A-Za-f][0-9A-Za-f]* { + if (mydebug) fprintf(stderr,"Hex found %s\n", yytext); + yylval.value=aHexToInt((char *)yytext); + return(T_INTCONSTANT); +} + + +[0-9][0-9]* { + if (mydebug) fprintf(stderr,"Integer found %s\n", yytext); + yylval.value=atoi((const char *)yytext); + return(T_INTCONSTANT); +} + +[ \t] { + if (mydebug) fprintf(stderr,"Whitespace found\n"); +} + +[\-+*/%();{},\[\]!<>] { + if (mydebug) fprintf(stderr,"return a token %c\n",*yytext); + return (*yytext); +} + +\n { + if (mydebug) fprintf(stderr,"carriage return %c\n",*yytext); +} +\/\/.* { /* this is a comment line for double slash Return nothing, keep going */ } +%% + +int yywrap(void) +{ + return 1; +} \ No newline at end of file diff --git a/9LAB/testy/lab9.y b/9LAB/testy/lab9.y new file mode 100644 index 0000000..315de48 --- /dev/null +++ b/9LAB/testy/lab9.y @@ -0,0 +1,891 @@ +/* +Ziad Arafat - May 7 2021 +Lab 9 +*/ + +/* +Add debug flag to args +*/ +/* +April 26 2021: + - Updated main() to allow command line args + - Updated debug flag using args + - opened file using fopen and the command line args + - checked for NULL files when perms are not working + - included emit.h +*/ + +%{ +#include +#include +#include +#include + +#include "ast.h" +#include "symtable.h" +#include "emit.h" + +int level = 0; // the level of the scope we are in. +int offset = 0; // Keeps track of fielddecl offset values +int goffset = 0; // keeps track of +int maxoffset; + +int yylex(); + +extern int yylineno; // import the yylineno variable +void yyerror (s) /* Called by yyparse on error */ + char *s; +{ + // changed these to output to stderr + fprintf(stderr, "%s ", s); + + // print out the line number of the syntax error. + fprintf(stderr, "Error on line: %d \n", yylineno); +} + +struct ASTnodetype *PROGRAM; + +%} +/* defines the start symbol, what values come back +from LEX and how the operators are associated */ +/* changed to P */ +%start Program + +/* Defines possible types */ +%union +{ + int value; + char* string; + struct ASTnodetype *astnode; + enum AST_Decaf_Types asttype; + enum AST_Operators operator; +} + + +// I commented out the tokens that aren't being used. + +// I also removed the token for T_LT because idk why one was a token and the +// other was a char?? + + +// Added a token for each of the lex tokens +%token T_AND +%token T_ASSIGN +%token T_BOOLTYPE +%token T_BREAK +/* %token T_CHARCONSTANT */ +%token T_CONTINUE +/* %token T_DOT */ +%token T_ELSE +%token T_EQ +%token T_EXTERN +%token T_FALSE +/* %token T_FOR */ +%token T_FUNC +%token T_GEQ +/* %token T_GT */ +%token T_ID +%token T_IF +%token T_INTCONSTANT +%token T_INTTYPE +%token T_LEFTSHIFT +%token T_LEQ +%token T_NEQ +/* %token T_NULL */ +%token T_OR +%token T_PACKAGE +%token T_RETURN +%token T_RIGHTSHIFT +%token T_STRINGCONSTANT +%token T_STRINGTYPE +%token T_TRUE +%token T_VAR +%token T_VOID +%token T_WHILE + +/* %token T_STRING_LIT +%token T_INT_LIT */ + +%type Externs ExternDefn FullExternParmList ExternParmList FieldDecl +%type FieldDecls ArrayType MethodDecl MethodDecls Block VarDecl +%type IdTypeList IdTypeList1 VarDecls Statement Statements ReturnStmt +%type Constant BoolConstant BreakStmt Additiveexpression Term +%type Factor Simpleexpression Expr Assign Lvalue IfStmt WhileStmt +%type MethodCall MethodArgs FullMethodArgs MethodArg ContinueStmt +%type MethodType Type ExternType +%type Multop Addop Relop + + +/* added all the rules from DECAF and reformatted them to work with Bison */ +/* for each of the rules with a list of tokens I created a recursive rule +that allows for one or more of the token. +*/ + +/* Replaced any instance of '=' with T_ASSIGN */ + +%% /* end specs, begin rules */ +Program: + // uhh I noticed package name was in the output but cooper literally said + // we don't wanna do that in the video so I just didn't lol. + Externs T_PACKAGE T_ID '{' FieldDecls MethodDecls '}' { + PROGRAM = ASTCreateNode(A_PROGRAM); + PROGRAM->S1 = $1; + PROGRAM->S2 = ASTCreateNode(A_PACKAGE); + PROGRAM->S2->name = $3; + PROGRAM->S2->S1 = $5; + PROGRAM->S2->S2 = $6; + }; + +Externs: + /* empty */ { $$ = NULL; } + | ExternDefn Externs { $1->next = $2; }; + +ExternDefn: + T_EXTERN T_FUNC T_ID '(' ExternParmList ')' MethodType ';' { + // we need to see if $3 has already been defined. + // if so => BARF + if (Search($3, level, 0) != NULL) { + yyerror("Symbol already deafined"); + yyerror($3); + exit(1); + } + $$ = ASTCreateNode(A_EXTERN); + $$->name = $3; + $$->A_Declared_Type = $7; + $$->size = 0; + $$->S1 = $5; // set the S1 to the list of params node + + // set our symbol to the return value of Insert() + $$->symbol = Insert($3,$7,ID_Sub_Type_Extern_Method, level, 0, 0, $5); + // offset++; + + // moved to main + if(mydebug) Display(); // Display the table for debugging + }; + +ExternParmList: + /* empty */ { $$ = NULL; } + | FullExternParmList {$$ = $1;} ; + +FullExternParmList: + ExternType { + $$ = ASTCreateNode(A_ExternType); + $$->A_Declared_Type = $1; + } + | ExternType ',' ExternParmList { + $$ = ASTCreateNode(A_ExternType); + $$->A_Declared_Type = $1; + $$->next = $3; + }; + +FieldDecls: + /* empty */ {$$ = NULL;} + | FieldDecl FieldDecls { + $$ = $1; + $$->next = $2; + }; + +FieldDecl: + T_VAR T_ID Type ';' { + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; + $$->A_Declared_Type = $3; + $$->size = 1; // scalars are size 1 + + // insert the variable into the symtable + $$->symbol = Insert($2,$3,ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + } + | T_VAR T_ID ArrayType ';' { + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; + $$->S1 = $3; // set S1 to the ArrayType + $$->A_Declared_Type = $3->A_Declared_Type; // duplicate the type in the array + $$->size = $3->size; // Arrays are based on the ArrayType value + // insert the variable into the symtable + $$->symbol = Insert($2,$3->A_Declared_Type,ID_Sub_Type_Array, level, $$->size, offset, NULL); + offset += $3->size; // increment the offset by the size of the array. + } + | T_VAR T_ID Type T_ASSIGN Constant ';' { + // we do the same thing in here that we did for the one without the T_ASSIGN + + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; + $$->A_Declared_Type = $3; // set type to the Type output node + $$->size = 1; // this is still a scalar so we set size to 1. + $$->symbol = Insert($2,$3,ID_Sub_Type_Scalar, level,$$->size, offset, NULL); + offset++; // increment offset by 1 because it's a scalar. + $$->S2 = $5; // set S2 to the Constant node + + }; + +MethodDecls: + /* empty */ {$$ = NULL;} + | MethodDecl MethodDecls { + $$ = $1; + $$->next = $2; // set the next to the right recursive value + }; + +MethodDecl: + // set global offset to offset them reset our offset + // this way we resume global offsets and our offset is ready for next block + T_FUNC T_ID { + struct SymbTab *s; + + s = Search($2, level, 0); + + if (s != NULL){ + fprintf(stderr, "Symbol %s has already been used in a method\n", $2); + yyerror("duplicate method name"); + exit(1); + } else { + s = Insert($2,0,ID_Sub_Type_Method, level, 0, 0, NULL); + // update the type after we get it + if (mydebug) Display(); + + // set offset for start of method + goffset = offset; + offset = 2; + maxoffset = offset; + } + + + + + } '(' IdTypeList ')' MethodType { + struct SymbTab *s; + s = Search($2, level, 0); + s->Type = $7; + s->fparms = $5; + + } Block { + + // increment anything greater than $2 by 1 for the new component + $$ = ASTCreateNode(A_METHODDEC); + $$->name = $2; + $$->A_Declared_Type = $7; + // $$->size = 1; changed to offset + $$->S1 = $5; // $5; + $$->S2 = $9; // $9; + $$->symbol = Search($2, level, 0); + $$->size = maxoffset; + $$->symbol->mysize = maxoffset; // max size needed to run program + offset = goffset; + }; + +IdTypeList: + /* empty */ { $$ = NULL; } + | IdTypeList1 { $$ = $1; }; + +IdTypeList1: + T_ID Type { + // Before we create the node let's check if the T_ID is used + if(Search ($1, level + 1, 0)!= NULL) { + yyerror("Duplicate method arg name"); + yyerror($1); + } + + $$ = ASTCreateNode(A_METHODID); + $$->name = $1; + $$->A_Declared_Type = $2; + $$->size = 1; + + $$->symbol=Insert($1,$2,ID_Sub_Type_Scalar, level+1, 1, offset, NULL); + offset++; // increment offset by 1 as per instructions + } + | T_ID Type ',' IdTypeList { + // Before we create the node let's check if the T_ID is used + + // check if there are duplicate args + if(Search ($1, level + 1, 0)!= NULL) { + yyerror("Duplicate method arg name"); + yyerror($1); + } + $$ = ASTCreateNode(A_METHODID); + $$->name = $1; + $$->A_Declared_Type = $2; + $$->size = 1; + + // we do level + 1 because the args are part of the block created by the method. + $$->symbol=Insert($1,$2,ID_Sub_Type_Scalar, level+1, 1, offset, NULL); + offset++; // increment offset by 1 as per instructions + $$->next = $4; + }; + +Block: + // increment level as soon as we open a block + '{' { level++; } VarDecls Statements '}' { + $$ = ASTCreateNode(A_BLOCK); + + // incremented these because added in-rule action + $$->S1 = $3; // set S1 to the VarDecls + $$->S2 = $4; // set S2 to the Statements + if(mydebug) Display(); // Display here so we can see the symtab at each level + + // if the offset is greater than the maxoffset of the method + // then we set the maxoffset to the offset to fix it's max value + if (offset > maxoffset) { + maxoffset = offset; + } + + // We delete all the symbols at the current level before leaving. + // this way they don't conflict with levels lower. + offset -= Delete(level); + + // decrement level since we finished the block + level--; + + }; + +VarDecls: + /* empty */ { $$ = NULL; } + | VarDecl VarDecls { + $$ = $1; + $$->next = $2; + }; + +VarDecl: + T_VAR T_ID Type ';' { + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + + // Create an A_VARDEC node + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; // set it's name to T_ID + $$->A_Declared_Type = $3; // set it's type to outpit of Type + + // insert the variable into the symtable + $$->symbol = Insert($2,$3,ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + // Display(); // debugging only + } + | T_VAR T_ID ArrayType ';' { + // Before we create the node let's check if the T_ID is used + if (Search($2, level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror($2); + exit(1); + } + $$ = ASTCreateNode(A_VARDEC); + $$->name = $2; + $$->S1 = $3; // set S1 to the ArrayType node + $$->A_Declared_Type = $3->A_Declared_Type; + $$->size = $3->size; // set the size to the size of the ArrayType node + + // insert the variable into the symtable + $$->symbol = Insert($2,$3->A_Declared_Type, ID_Sub_Type_Array, level, $$->size, offset, NULL); + offset += $3->size; // increment offset by the size of the array. + }; + +Statements: + /* empty */ { $$ = NULL; } + | Statement Statements { + $$ = $1; + $$->next = $2; + }; + +/* Moved all of the Statement into one rule and moved each item into it's own +separate rule. + */ + /* Connected these all */ +Statement: + Block { $$ = $1; } + | Assign ';' { $$ = $1; } + | MethodCall ';' { $$ = $1; } + | IfStmt { $$ = $1; } + | WhileStmt { $$ = $1; } + | ReturnStmt { $$ = $1; } + | BreakStmt { $$ = $1; } + | ContinueStmt { $$ = $1; } + ; + +/* Created a continue statement idk if this was needed */ +ContinueStmt: T_CONTINUE ';' {$$ = ASTCreateNode(A_CONTINUE);}; + +WhileStmt: + T_WHILE '(' Expr ')' Block { + $$ = ASTCreateNode(A_WHILESTMT); + $$->S1 = $3; // set S1 to thje Expr + $$->S2 = $5; // Set S2 to the Block + }; + +BreakStmt: T_BREAK ';' { $$ = ASTCreateNode(A_BREAK); }; + +IfStmt: + T_IF '(' Expr ')' Block T_ELSE Block { + $$ = ASTCreateNode(A_IF); + $$->S1 = $3; // set S1 to the Expression node + $$->S2 = ASTCreateNode(A_IFBODY); // create a separate node for the body in S2 + $$->S2->S1 = $5; // set the S1 of the body to the block of the IF + $$->S2->S2 = $7; // create a new node for the else statement after the body + + /*I modified my original implementation to + not have an A_ELSE node. Instead we just store the blocks + directly in the S1 and S2 of the A_IFBODY respectively. + This makes the logic on the emit.c side much simpler*/ + + } + | T_IF '(' Expr ')' Block { + $$ = ASTCreateNode(A_IF); + + // Set S1 to the Expression node + $$->S1 = $3; + $$->S2 = ASTCreateNode(A_IFBODY); // create a separate node for the body in S2 + $$->S2->S1 = $5; // set the S1 of the body to the block + $$->S2->S2 = NULL; // since we have no Else we set it's node to NULL this time + }; + +ReturnStmt: + T_RETURN ';' { $$ = ASTCreateNode(A_RETURN);} + | T_RETURN '(' ')' ';' { $$ = ASTCreateNode(A_RETURN);} + | T_RETURN '(' Expr ')' ';' { + $$ = ASTCreateNode(A_RETURN); + $$->S1 = $3; // set the S1 to the expression we returned + }; + +Assign: + Lvalue T_ASSIGN Expr { + + // make sure the left and right hand types are matching + if ( $1->A_Declared_Type != $3->A_Declared_Type) { + yyerror("Type mismatch on assignment"); + exit(1); + } + $$ = ASTCreateNode(A_ASSIGN); + $$->S1 = $1; // set the S1 to the left hand side + $$->S2 = $3; // set the S2 to the right hand side + $$->name = TEMP_CREATE(); + // create a temporary symbol to hold value + $$->symbol = Insert($$->name, $$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // Determine if we need to increment offset + // Yes we do because the assignments need temporary values + // in the function's space + offset++; + }; + + +// in case we wanna do for loops I guess +// TODO: Implement for loops +/* Assigns: Assign + | Assign ',' Assigns + + ; */ + +Lvalue: + T_ID { + /* I am using A_VAR_RVALUE for both the LVALUE and RVALUE + Mostly because the node serves the same purpose. + */ + + /* well apparently that was wrong so I changed to a new + node type LVALUE which now has it's own case and enum + */ + + // grab the symbol from the table corresponding the T_ID + struct SymbTab *p; + p = Search($1, level, 1); + + // if we didn't find one lets barf because it wasnt defined + if(p == NULL) { + yyerror("Symbol on LVALUE not defined"); + yyerror($1); + exit(1); + } + + // Make sure the type is a scalar and not an array/method + if (p->SubType != ID_Sub_Type_Scalar){ + yyerror($1); + yyerror("needs to be a scalar, wrong subtype"); + exit(1); + } + + $$ = ASTCreateNode(A_VAR_LVALUE); + $$->name = $1; + $$->symbol = p; + $$->A_Declared_Type = p->Type; + } + | T_ID '[' Expr ']' { + struct SymbTab *p; + p = Search($1, level, 1); + + // if we didn't find one lets barf because it wasnt defined + if(p == NULL) { + yyerror("Symbol on LVALUE not defined"); + yyerror($1); + exit(1); + } + + // Make sure it's an array and not a Scalar/Method + if (p->SubType != ID_Sub_Type_Array){ + yyerror($1); + yyerror("needs to be an array, wrong subtype"); + exit(1); + } + $$ = ASTCreateNode(A_VAR_LVALUE); + $$->name = $1; + $$->S1 = $3; + $$->symbol = p; + $$->A_Declared_Type = p->Type; // the type is the same as the symbol we got it from + }; + + +MethodCall: + T_ID '(' MethodArgs ')' { + struct SymbTab *p; + p = Search($1, level, 1); + + // if we didn't find one lets barf because it wasnt defined + if(p == NULL) { + yyerror("Method symbol not defined"); + yyerror($1); + exit(1); + } + + // Make sure it's a Method or Extern Method and not an Array/Scalar + if ((p->SubType != ID_Sub_Type_Method) && (p->SubType != ID_Sub_Type_Extern_Method)){ + yyerror($1); + yyerror("needs to be a method, wrong subtype"); + exit(1); + } + + // check that the formal params match the params of the method + // definition + + if (check_parameters(p->fparms, $3) == 0) { + yyerror("Formal and actual params do not match"); + yyerror($1); + exit(1); + } + + $$ = ASTCreateNode(A_METHODCALL); + $$->name = $1; + $$->S1 = $3; + $$->symbol = p; + $$->A_Declared_Type = p->Type; // type matches it's formal type + }; + +MethodArg: Expr { + $$ = $1; + // create a temporary symbol to hold value + $$->symbol = Insert(TEMP_CREATE(),$$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // increment offset by 1 because of the temporary value being stored + offset++; + }; + +MethodArgs: + /* empty */ { + $$ = NULL; + } + | FullMethodArgs { + $$ = $1; + }; + +FullMethodArgs: + MethodArg { + $$ = $1; + } + | MethodArg ',' MethodArgs { + $$ = $1; + $$->next = $3; + } + ; + + + + +/* Statement: T_FOR '(' Assigns ';' Expr ';' Assigns ')' Block + ; */ + + + + + +Expr: Simpleexpression { $$ = $1; }; + +Simpleexpression: + Additiveexpression { $$ = $1; } + | Simpleexpression Relop Additiveexpression { + + // make type of left is type of right + if (($1->A_Declared_Type != $3->A_Declared_Type)) { + yyerror("both sides need to be the same type"); + exit(1); + } + $$ = ASTCreateNode(A_EXPR); + $$->S1 = $1; // set S1 to left hand side + $$->operator = $2; // set the operator to return of Relop + $$->S2 = $3; // set S2 to the right hand side + $$->A_Declared_Type = $1->A_Declared_Type; // duplicate the type from one of the left or right (left) + $$->name = TEMP_CREATE(); // create a temporary symbol to hold value + $$->symbol = Insert($$->name,$$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // increment offset by 1 because of the temporary value being stored + offset++; + + }; + +Relop: + '<' { $$ = A_LT; } + | '>' { $$ = A_GT; } + | T_EQ { $$ = A_EQ; } + | T_LEQ { $$ = A_LEQ; } + | T_GEQ { $$ = A_GEQ; } + | T_NEQ { $$ = A_NEQ; }; + +Additiveexpression: + Term { $$ = $1; } + | Additiveexpression Addop Term { + if (($1->A_Declared_Type != $3->A_Declared_Type) || + (check_operators($2, $1->A_Declared_Type) == 0)) { + yyerror("addition and subtraction need INTs only"); + exit(1); + } + $$ = ASTCreateNode(A_EXPR); + $$->S1 = $1; + $$->operator = $2; + $$->S2 = $3; + $$->A_Declared_Type = A_Decaf_INT; + $$->name = TEMP_CREATE(); + $$->symbol = Insert($$->name,$$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + }; + +Addop: + '+' { $$ = A_PLUS; } + | '-' { $$ = A_MINUS; }; + +Term: + Factor { $$ = $1; } + | Term Multop Factor { + // check that left is equal to right + if ($1->A_Declared_Type != $3->A_Declared_Type) { + yyerror("type mismatch"); + exit(1); + } + + // use my check_operators() function to make sure the operator + // is compatible with the types + if (check_operators($2, $1->A_Declared_Type) == 0) { + if($1->A_Declared_Type == A_Decaf_BOOL) { + yyerror("Cannot use BOOL in INT operation"); + } else { + yyerror("Cannot use INT in BOOL operation"); + } + exit(1); + } + + $$ = ASTCreateNode(A_EXPR); + $$->S1 = $1; + $$->operator = $2; + $$->S2 = $3; + $$->name = TEMP_CREATE(); + $$->symbol = Insert($$->name,$$->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + }; +/* added modulus as a multi operator */ +Multop: + '*' { $$ = A_TIMES; } + | '/' { $$ = A_DIVIDE; } + | '%' { $$ = A_MOD; } + | T_AND { $$ = A_AND; } + | T_OR { $$ = A_OR; } + | T_LEFTSHIFT { $$ = A_LEFTSHIFT; } + | T_RIGHTSHIFT { $$ = A_RIGHTSHIFT; }; + +Factor: + T_ID { + struct SymbTab *p; + p = Search($1, level, 1); + + if(p == NULL) { + yyerror("Symbol on RVALUE not defined"); + yyerror($1); + exit(1); + } + + if (p->SubType != ID_Sub_Type_Scalar){ + yyerror($1); + yyerror("needs to be an scalar, wrong subtype"); + exit(1); + } + $$ = ASTCreateNode(A_VAR_RVALUE); + $$->name = $1; + $$->symbol = p; + $$->A_Declared_Type = p->Type; + + } + | MethodCall { $$ = $1; } + | T_ID '[' Expr ']' { + struct SymbTab *p; + p = Search($1, level, 1); + if(p == NULL) { + yyerror("Symbol on RVALUE not defined"); + yyerror($1); + exit(1); + } + + if (p->SubType != ID_Sub_Type_Array){ + yyerror($1); + yyerror("needs to be an array, wrong subtype"); + exit(1); + } + + $$ = ASTCreateNode(A_VAR_RVALUE); + $$->name = $1; + $$->S1 = $3; + $$->symbol = p; + $$->A_Declared_Type = p->Type; + } + | Constant { $$ = $1; } + | '(' Expr ')' { $$ = $2; } + | '!' Factor { + + // check if our right is a bool + if ($2->A_Declared_Type != A_Decaf_BOOL) { + yyerror("Type mismatch, expected boolean"); + exit(1); + } + + $$ = ASTCreateNode(A_EXPR); + $$->operator = A_NOT; + $$->S1 = $2; + + // set type to boolean because !bool is a bool + $$->A_Declared_Type = A_Decaf_BOOL; + + $$->name = TEMP_CREATE(); + $$->symbol = Insert($$->name,A_Decaf_BOOL, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + } + + /* moved this around a lot until I got it working in here */ + | T_STRINGCONSTANT { + $$ = ASTCreateNode(A_CONSTANT_STRING); + $$->name = $1; + $$->A_Declared_Type = A_Decaf_STRING; + } + | '-' Factor { + // check if our right is an int + if ($2->A_Declared_Type != A_Decaf_INT) { + yyerror("Type mismatch, expected integer"); + exit(1); + } + $$ = ASTCreateNode(A_EXPR); + $$->operator = A_UMINUS; + $$->S1 = $2; + // set type to boolean because UMINUS is for numbers + $$->A_Declared_Type = A_Decaf_INT; + $$->name = TEMP_CREATE(); + $$->symbol = Insert($$->name,A_Decaf_BOOL, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + }; + + + + +ExternType: + T_STRINGTYPE { $$ = A_Decaf_STRING; } + | Type + ; + +Type: + T_INTTYPE { $$ = A_Decaf_INT; } + | T_BOOLTYPE{ $$ = A_Decaf_BOOL; }; + +MethodType: + T_VOID { $$ = A_Decaf_VOID; } + | Type { $$ = $1; }; + +BoolConstant: + T_TRUE { + $$ = ASTCreateNode(A_CONSTANT_BOOL); + $$->value = 1; + $$->A_Declared_Type = A_Decaf_BOOL; + } + | T_FALSE { + $$ = ASTCreateNode(A_CONSTANT_BOOL); + $$->value = 0; + $$->A_Declared_Type = A_Decaf_BOOL; + }; + +ArrayType: + '[' T_INTCONSTANT ']' Type { + $$ = ASTCreateNode(A_ARRAYTYPE); + $$->value = $2; + $$->A_Declared_Type = $4; + $$->size = $2; + // printf("THE SIZE IS %d %d", $2, $$->size);// debug + }; +/* added String and Char as constants */ +Constant: + T_INTCONSTANT { + $$ = ASTCreateNode(A_CONSTANT_INT); + $$->value = $1; + $$->A_Declared_Type = A_Decaf_INT; + } + + | BoolConstant { + $$ = $1; + }; +%% /* end of rules, start of program */ + +int main(int argc, char ** argv){ + + for (int i = 1; i 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#ifndef SIZE_MAX +#define SIZE_MAX (~(size_t)0) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +/* begin standard C++ headers. */ + +/* TODO: this is always defined, so inline it */ +#define yyconst const + +#if defined(__GNUC__) && __GNUC__ >= 3 +#define yynoreturn __attribute__((__noreturn__)) +#else +#define yynoreturn +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an + * integer in range [0..255] for use as an array index. + */ +#define YY_SC_TO_UI(c) ((YY_CHAR) (c)) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else +#define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern int yyleng; + +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + #define YY_LINENO_REWIND_TO(dst) \ + do {\ + const char *p;\ + for ( p = yy_cp-1; p >= (dst); --p)\ + if ( *p == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + int yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = NULL; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart ( FILE *input_file ); +void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size ); +void yy_delete_buffer ( YY_BUFFER_STATE b ); +void yy_flush_buffer ( YY_BUFFER_STATE b ); +void yypush_buffer_state ( YY_BUFFER_STATE new_buffer ); +void yypop_buffer_state ( void ); + +static void yyensure_buffer_stack ( void ); +static void yy_load_buffer_state ( void ); +static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file ); +#define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size ); +YY_BUFFER_STATE yy_scan_string ( const char *yy_str ); +YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len ); + +void *yyalloc ( yy_size_t ); +void *yyrealloc ( void *, yy_size_t ); +void yyfree ( void * ); + +#define yy_new_buffer yy_create_buffer +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + yyensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + yy_create_buffer( yyin, YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ +typedef flex_uint8_t YY_CHAR; + +FILE *yyin = NULL, *yyout = NULL; + +typedef int yy_state_type; + +#define YY_FLEX_LEX_COMPAT +extern int yylineno; +int yylineno = 1; + +extern char yytext[]; + +static yy_state_type yy_get_previous_state ( void ); +static yy_state_type yy_try_NUL_trans ( yy_state_type current_state ); +static int yy_get_next_buffer ( void ); +static void yynoreturn yy_fatal_error ( const char* msg ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + if ( yyleng >= YYLMAX ) \ + YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \ + yy_flex_strncpy( yytext, (yytext_ptr), yyleng + 1 ); \ + (yy_c_buf_p) = yy_cp; +#define YY_NUM_RULES 34 +#define YY_END_OF_BUFFER 35 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static const flex_int16_t yy_accept[108] = + { 0, + 0, 0, 35, 34, 30, 32, 31, 34, 31, 34, + 31, 29, 29, 31, 2, 31, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 34, 16, + 0, 26, 1, 33, 29, 0, 14, 15, 7, 11, + 20, 27, 27, 27, 27, 27, 27, 27, 27, 12, + 27, 27, 27, 27, 27, 27, 27, 27, 17, 33, + 28, 27, 27, 27, 27, 27, 27, 27, 13, 27, + 27, 27, 27, 23, 27, 27, 28, 3, 27, 27, + 6, 27, 27, 10, 27, 27, 27, 22, 24, 27, + 4, 27, 27, 9, 27, 27, 27, 25, 27, 8, + + 27, 19, 21, 27, 18, 5, 0 + } ; + +static const YY_CHAR yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 1, 1, 6, 7, 1, 6, + 6, 6, 6, 6, 6, 1, 8, 9, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 1, 6, 11, + 12, 13, 1, 1, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 6, 1, 6, 1, 15, 1, 16, 17, 18, 19, + + 20, 21, 22, 23, 24, 25, 26, 27, 25, 28, + 29, 30, 25, 31, 32, 33, 34, 35, 36, 37, + 25, 25, 6, 38, 6, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static const YY_CHAR yy_meta[39] = + { 0, + 1, 1, 2, 1, 1, 1, 1, 1, 3, 3, + 1, 1, 1, 3, 4, 3, 3, 3, 3, 3, + 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 1 + } ; + +static const flex_int16_t yy_base[113] = + { 0, + 0, 0, 128, 129, 129, 129, 115, 121, 129, 118, + 116, 30, 32, 32, 111, 33, 0, 18, 93, 21, + 34, 31, 105, 100, 86, 87, 35, 94, 78, 129, + 110, 109, 129, 0, 44, 0, 129, 129, 129, 129, + 129, 0, 84, 92, 83, 78, 76, 81, 79, 0, + 73, 87, 71, 72, 68, 70, 76, 75, 129, 0, + 0, 71, 81, 63, 75, 74, 61, 74, 0, 65, + 56, 65, 68, 0, 68, 59, 0, 0, 59, 60, + 0, 52, 62, 0, 65, 49, 51, 0, 0, 56, + 0, 42, 38, 0, 43, 35, 40, 0, 27, 0, + + 40, 0, 0, 37, 0, 0, 129, 68, 70, 74, + 53, 52 + } ; + +static const flex_int16_t yy_def[113] = + { 0, + 107, 1, 107, 107, 107, 107, 107, 108, 107, 107, + 107, 107, 107, 107, 107, 107, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 107, 107, + 108, 108, 107, 110, 107, 111, 107, 107, 107, 107, + 107, 109, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 107, 110, + 112, 109, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 112, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, + + 109, 109, 109, 109, 109, 109, 0, 107, 107, 107, + 107, 107 + } ; + +static const flex_int16_t yy_nxt[168] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 4, 17, 18, 19, 17, 20, + 21, 17, 17, 22, 17, 17, 17, 17, 17, 23, + 24, 25, 26, 17, 27, 28, 17, 29, 35, 35, + 35, 35, 37, 38, 40, 41, 43, 46, 44, 48, + 56, 50, 35, 35, 77, 61, 106, 47, 51, 105, + 104, 103, 102, 57, 101, 100, 36, 49, 31, 99, + 31, 31, 42, 42, 60, 98, 60, 60, 97, 96, + 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, + 85, 84, 83, 82, 81, 80, 79, 78, 76, 75, + + 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, + 64, 63, 62, 32, 32, 59, 58, 55, 54, 53, + 52, 45, 39, 34, 33, 32, 30, 107, 3, 107, + 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, + 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, + 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, + 107, 107, 107, 107, 107, 107, 107 + } ; + +static const flex_int16_t yy_chk[168] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 12, 12, + 13, 13, 14, 14, 16, 16, 18, 20, 18, 21, + 27, 22, 35, 35, 112, 111, 104, 20, 22, 101, + 99, 97, 96, 27, 95, 93, 12, 21, 108, 92, + 108, 108, 109, 109, 110, 90, 110, 110, 87, 86, + 85, 83, 82, 80, 79, 76, 75, 73, 72, 71, + 70, 68, 67, 66, 65, 64, 63, 62, 58, 57, + + 56, 55, 54, 53, 52, 51, 49, 48, 47, 46, + 45, 44, 43, 32, 31, 29, 28, 26, 25, 24, + 23, 19, 15, 11, 10, 8, 7, 3, 107, 107, + 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, + 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, + 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, + 107, 107, 107, 107, 107, 107, 107 + } ; + +/* Table of booleans, true if rule could match eol. */ +static const flex_int32_t yy_rule_can_match_eol[35] = + { 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, }; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int yy_flex_debug; +int yy_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#ifndef YYLMAX +#define YYLMAX 8192 +#endif + +char yytext[YYLMAX]; +char *yytext_ptr; +#line 1 "lab9.l" +/* Small LEX routine which returns two formal tokens (INTEGER and VARIABLE) + along with single string elements like '+'. + + This LEX definition is the companion to the docalc.y YACC routine which + is a simple calculator + + Shaun Cooper + January 2015 +*/ +/* Ziad Arafat Mar 8 2021 */ +#line 14 "lab9.l" + +#include "ast.h" +#include "y.tab.h" +#include +int yylex(); +static int mydebug=0; + +int aHexToInt(char * hexstr) +{ + // I used the code we used in one of the 273 labs and adapted it to + // work on any number of chars. + + // Uses the difference of the ASCII table values of the chars to get + // the value. + + size_t len = strlen(hexstr)-1; + int mult = 1; + int val = 0; + + // since we already check to make sure it's 0-9 we don't need to + // exclude the x in 0x and obviously the 0 will make no change to the + // value. + if (*(hexstr + len) >= '0' && *(hexstr + len) <= '9') val = (*(hexstr + len) - '0') * mult; + else if (*(hexstr + len) >= 'a' && *(hexstr + len) <= 'f') val = (*(hexstr + len) - 'a' + 10) * mult; + else if (*(hexstr + len) >= 'A' && *(hexstr + len) <='F') val = (*(hexstr + len) - 'A' + 10) * mult; + + mult *= 16; + + char *hexstrptr; + for (hexstrptr = hexstr+(len-1); hexstrptr != hexstr; hexstrptr--){ + if (*hexstrptr >= '0' && *hexstrptr <= '9') val += (*hexstrptr - '0') * mult; + else if (*hexstrptr >= 'a' && *hexstrptr <= 'f') val += (*hexstrptr - 'a' + 10) * mult; + else if (*hexstrptr >= 'A' && *hexstrptr <='F') val += (*hexstrptr - 'A' + 10) * mult; + mult *= 16; + } + + // printf("The hex value is: %d\n", val); + + return val; +} + +#line 594 "lex.yy.c" +/* +CHANGES: + - added the DECAF tokens + - Added some debug prints to the tokens + - Added square brackets to the lex directive + - Added '<' token to the directive + - Added modulus '%' + - Added directive for HEX numbers + - Created function to convert hex numbers to their int value + - Disabled the newline return token +*/ +#line 606 "lex.yy.c" + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +#include +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals ( void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int yylex_destroy ( void ); + +int yyget_debug ( void ); + +void yyset_debug ( int debug_flag ); + +YY_EXTRA_TYPE yyget_extra ( void ); + +void yyset_extra ( YY_EXTRA_TYPE user_defined ); + +FILE *yyget_in ( void ); + +void yyset_in ( FILE * _in_str ); + +FILE *yyget_out ( void ); + +void yyset_out ( FILE * _out_str ); + + int yyget_leng ( void ); + +char *yyget_text ( void ); + +int yyget_lineno ( void ); + +void yyset_lineno ( int _line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap ( void ); +#else +extern int yywrap ( void ); +#endif +#endif + +#ifndef YY_NO_UNPUT + + static void yyunput ( int c, char *buf_ptr ); + +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy ( char *, const char *, int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen ( const char * ); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput ( void ); +#else +static int input ( void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else +#define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int yylex (void); + +#define YY_DECL int yylex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK /*LINTED*/break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_load_buffer_state( ); + } + + { +#line 70 "lab9.l" + +#line 825 "lex.yy.c" + + while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of yytext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 108 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 129 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + yylineno++; +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 71 "lab9.l" +{return(T_AND);} + YY_BREAK +case 2: +YY_RULE_SETUP +#line 73 "lab9.l" +{ + if (mydebug) fprintf(stderr,"T_ASSIGN found\n"); + return(T_ASSIGN); +} + YY_BREAK +case 3: +YY_RULE_SETUP +#line 78 "lab9.l" +{return(T_BOOLTYPE);} + YY_BREAK +case 4: +YY_RULE_SETUP +#line 79 "lab9.l" +{return(T_BREAK);} + YY_BREAK +case 5: +YY_RULE_SETUP +#line 80 "lab9.l" +{return(T_CONTINUE);} + YY_BREAK +case 6: +YY_RULE_SETUP +#line 81 "lab9.l" +{return(T_ELSE);} + YY_BREAK +case 7: +YY_RULE_SETUP +#line 82 "lab9.l" +{return(T_EQ);} + YY_BREAK +case 8: +YY_RULE_SETUP +#line 83 "lab9.l" +{return(T_EXTERN);} + YY_BREAK +case 9: +YY_RULE_SETUP +#line 84 "lab9.l" +{return(T_FALSE);} + YY_BREAK +case 10: +YY_RULE_SETUP +#line 85 "lab9.l" +{return(T_FUNC);} + YY_BREAK +case 11: +YY_RULE_SETUP +#line 86 "lab9.l" +{return(T_GEQ);} + YY_BREAK +case 12: +YY_RULE_SETUP +#line 89 "lab9.l" +{if (mydebug) fprintf(stderr,"T_IF found\n");return(T_IF);} + YY_BREAK +case 13: +YY_RULE_SETUP +#line 91 "lab9.l" +{ + if (mydebug) fprintf(stderr,"T_INTTYPE found\n"); + return(T_INTTYPE); + +} + YY_BREAK +case 14: +YY_RULE_SETUP +#line 97 "lab9.l" +{return(T_LEFTSHIFT);} + YY_BREAK +case 15: +YY_RULE_SETUP +#line 98 "lab9.l" +{return(T_LEQ);} + YY_BREAK +case 16: +YY_RULE_SETUP +#line 99 "lab9.l" +{return(T_NEQ);} + YY_BREAK +case 17: +YY_RULE_SETUP +#line 100 "lab9.l" +{return(T_OR);} + YY_BREAK +case 18: +YY_RULE_SETUP +#line 101 "lab9.l" +{return(T_PACKAGE);} + YY_BREAK +case 19: +YY_RULE_SETUP +#line 102 "lab9.l" +{return(T_RETURN);} + YY_BREAK +case 20: +YY_RULE_SETUP +#line 103 "lab9.l" +{return(T_RIGHTSHIFT);} + YY_BREAK +case 21: +YY_RULE_SETUP +#line 104 "lab9.l" +{return(T_STRINGTYPE);} + YY_BREAK +case 22: +YY_RULE_SETUP +#line 105 "lab9.l" +{return(T_TRUE);} + YY_BREAK +case 23: +YY_RULE_SETUP +#line 106 "lab9.l" +{if (mydebug) fprintf(stderr,"T_VAR found\n");return(T_VAR);} + YY_BREAK +case 24: +YY_RULE_SETUP +#line 107 "lab9.l" +{if (mydebug) fprintf(stderr,"T_VOID found\n");return(T_VOID);} + YY_BREAK +case 25: +YY_RULE_SETUP +#line 108 "lab9.l" +{return(T_WHILE);} + YY_BREAK +case 26: +YY_RULE_SETUP +#line 111 "lab9.l" +{ + yylval.string=strdup(yytext); + return(T_STRINGCONSTANT); +} + YY_BREAK +case 27: +YY_RULE_SETUP +#line 116 "lab9.l" +{ + if (mydebug) { + fprintf(stderr,"Identifier found %s\n", yytext); + } + yylval.string=strdup(yytext); + return(T_ID); +} + YY_BREAK +case 28: +YY_RULE_SETUP +#line 124 "lab9.l" +{ + if (mydebug) fprintf(stderr,"Hex found %s\n", yytext); + yylval.value=aHexToInt((char *)yytext); + return(T_INTCONSTANT); +} + YY_BREAK +case 29: +YY_RULE_SETUP +#line 131 "lab9.l" +{ + if (mydebug) fprintf(stderr,"Integer found %s\n", yytext); + yylval.value=atoi((const char *)yytext); + return(T_INTCONSTANT); +} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 137 "lab9.l" +{ + if (mydebug) fprintf(stderr,"Whitespace found\n"); +} + YY_BREAK +case 31: +YY_RULE_SETUP +#line 141 "lab9.l" +{ + if (mydebug) fprintf(stderr,"return a token %c\n",*yytext); + return (*yytext); +} + YY_BREAK +case 32: +/* rule 32 can match eol */ +YY_RULE_SETUP +#line 146 "lab9.l" +{ + if (mydebug) fprintf(stderr,"carriage return %c\n",*yytext); +} + YY_BREAK +case 33: +YY_RULE_SETUP +#line 149 "lab9.l" +{ /* this is a comment line for double slash Return nothing, keep going */ } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 150 "lab9.l" +ECHO; + YY_BREAK +#line 1094 "lex.yy.c" +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( yywrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of user's declarations */ +} /* end of yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1); + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yyrealloc( (void *) b->yy_ch_buf, + (yy_size_t) (b->yy_buf_size + 2) ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = NULL; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc( + (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + /* "- 2" to take care of EOB's */ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + yy_state_type yy_current_state; + char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 108 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); + + YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 108 ) + yy_c = yy_meta[yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; + yy_is_jam = (yy_current_state == 107); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_UNPUT + + static void yyunput (int c, char * yy_bp ) +{ + char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up yytext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + int number_to_move = (yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + if ( c == '\n' ){ + --yylineno; + } + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (int) ((yy_c_buf_p) - (yytext_ptr)); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap( ) ) + return 0; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve yytext */ + (yy_hold_char) = *++(yy_c_buf_p); + + if ( c == '\n' ) + + yylineno++; +; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void yyrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + yyensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + yy_create_buffer( yyin, YY_BUF_SIZE ); + } + + yy_init_buffer( YY_CURRENT_BUFFER, input_file ); + yy_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * yypop_buffer_state(); + * yypush_buffer_state(new_buffer); + */ + yyensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + yy_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void yy_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with yy_create_buffer() + * + */ + void yy_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yyfree( (void *) b->yy_ch_buf ); + + yyfree( (void *) b ); +} + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a yyrestart() or at EOF. + */ + static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then yy_init_buffer was _probably_ + * called from yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void yy_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + yy_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + yyensure_buffer_stack(); + + /* This block is copied from yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from yy_switch_to_buffer. */ + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void yypop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + yy_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + yy_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void yyensure_buffer_stack (void) +{ + yy_size_t num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */ + (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + yy_size_t grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return NULL; + + b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = NULL; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * yy_scan_bytes() instead. + */ +YY_BUFFER_STATE yy_scan_string (const char * yystr ) +{ + + return yy_scan_bytes( yystr, (int) strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = (yy_size_t) (_yybytes_len + 2); + buf = (char *) yyalloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yynoreturn yy_fatal_error (const char* msg ) +{ + fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = (yy_hold_char); \ + (yy_c_buf_p) = yytext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int yyget_lineno (void) +{ + + return yylineno; +} + +/** Get the input stream. + * + */ +FILE *yyget_in (void) +{ + return yyin; +} + +/** Get the output stream. + * + */ +FILE *yyget_out (void) +{ + return yyout; +} + +/** Get the length of the current token. + * + */ +int yyget_leng (void) +{ + return yyleng; +} + +/** Get the current token. + * + */ + +char *yyget_text (void) +{ + return yytext; +} + +/** Set the current line number. + * @param _line_number line number + * + */ +void yyset_lineno (int _line_number ) +{ + + yylineno = _line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param _in_str A readable stream. + * + * @see yy_switch_to_buffer + */ +void yyset_in (FILE * _in_str ) +{ + yyin = _in_str ; +} + +void yyset_out (FILE * _out_str ) +{ + yyout = _out_str ; +} + +int yyget_debug (void) +{ + return yy_flex_debug; +} + +void yyset_debug (int _bdebug ) +{ + yy_flex_debug = _bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from yylex_destroy(), so don't allocate here. + */ + + /* We do not touch yylineno unless the option is enabled. */ + yylineno = 1; + + (yy_buffer_stack) = NULL; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = NULL; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = NULL; + yyout = NULL; +#endif + + /* For future reference: Set errno on error, since we are called by + * yylex_init() + */ + return 0; +} + +/* yylex_destroy is for both reentrant and non-reentrant scanners. */ +int yylex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + yy_delete_buffer( YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + yypop_buffer_state(); + } + + /* Destroy the stack itself. */ + yyfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * yylex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, const char * s2, int n ) +{ + + int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (const char * s ) +{ + int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *yyalloc (yy_size_t size ) +{ + return malloc(size); +} + +void *yyrealloc (void * ptr, yy_size_t size ) +{ + + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return realloc(ptr, size); +} + +void yyfree (void * ptr ) +{ + free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 150 "lab9.l" + + +int yywrap(void) +{ + return 1; +} diff --git a/9LAB/testy/readme b/9LAB/testy/readme new file mode 100644 index 0000000..f52bf41 --- /dev/null +++ b/9LAB/testy/readme @@ -0,0 +1,4 @@ +# how to run +make clean +make +make test diff --git a/9LAB/testy/symtable.c b/9LAB/testy/symtable.c new file mode 100644 index 0000000..e938d3b --- /dev/null +++ b/9LAB/testy/symtable.c @@ -0,0 +1,201 @@ +/* Symbol Table --linked list + Used for Compilers class + + Modified Spring 2015 to allow for name to pointed to by symtable, instead of copied, since the name is copied + into the heap + + Modified to have levels. A level 0 means global variable, other levels means in range of the function. We + start out our offsets at 0 (from stack pointer) for level 1,,,when we enter a functional declaration. + We increment offset each time we insert a new variable. A variable is considered to be valid if it is found in + the symbol table at our level or lesser level. If at 0, then it is global. + + We return a pointer to the symbol table when a variable matches our creteria. + + We add a routine to remove variables at our level and above. +*/ +/* +Ziad Arafat - Apr 26 2021 +Lab 9 +*/ + +#include +#include "ast.h" +#include "symtable.h" + +int GTEMP = 0; // one up number for creating temps + +char *TEMP_CREATE() +{ + char s[100]; + sprintf(s, "_T%d", GTEMP); + GTEMP++; + + return (strdup(s)); +} + +struct SymbTab *first = NULL; + +/* Simple Insert into the symbol table with the size, type level that the name is being inserted into */ + +struct SymbTab *Insert(char *name, enum AST_Decaf_Types Type, + enum ID_Sub_Type subtype, int level, int mysize, + int offset, ASTnode *fparms) + +{ + struct SymbTab *n; + n = Search(name, level, 0); + if (n != NULL) { + printf("\n\tThe name %s exists at level %d already in the symbol table\n\tDuplicate can.t be inserted", + name, level); + return (NULL); + } else { + struct SymbTab *p; + p = malloc(sizeof(struct SymbTab)); + p->name = name; + p->offset = offset; /* assign the offset */ + p->level = level; /* assign the level */ + p->mysize = mysize; /* assign the size */ + p->Type = Type; /* assign the Type */ + p->SubType = subtype; /* assign the Function */ + p->fparms = fparms; /* assign the Method parameter list */ + p->next = NULL; + + /* Check on how many elements we have in the symbol table */ + if (first == NULL) { + first = p; + } else { + p->next = first; + first = p; + } + return (p); + } + + printf("\n\tLabel inserted\n"); +} + +/* print out a single symbol table entry -- for debugging */ +void PrintSym(struct SymbTab *s) +{ + char *string, *display_type; + display_type = " "; + switch (s->SubType) { + case ID_Sub_Type_Scalar: + string = "Scalar "; + break; + case ID_Sub_Type_Method: + string = "Method "; + break; + case ID_Sub_Type_Extern_Method: + string = "Extern Method "; + break; + case ID_Sub_Type_Array: + string = "Array "; + break; + // case ID_Sub_Type_Void: + // string = "Void "; // OOps this is not a thing + // break; + default: + string = "Unknown subtype in print symbol"; + } + switch (s->Type) { + case A_Decaf_INT: + display_type = "INT "; + break; + case A_Decaf_BOOL: + display_type = "BOOL "; + break; + case A_Decaf_VOID: + display_type = "VOID "; + break; + default: + string = "Unknown Declared TYPE in print symbol"; + } + // changed this to use the c space formatting so it always looks pretty. + printf("%-12s%-7d%-7d%-7d%-10s%-10s\n", s->name, s->offset, s->mysize, + s->level, display_type, string); + + // printf("%-12s%-7d%-7d%-10s%-10s\n", s->name, s->offset, + // s->level, display_type, string); +} + +/* General display to see what is our symbol table */ +void Display() +{ + int i; + struct SymbTab *p; + p = first; + // printf("\n\tLABEL\t\tOffset\tLEVEL\ttype\tsubtype\n"); + // changed this to use the c space formatting so it always looks pretty. + printf("%-12s%-7s%-7s%-7s%-10s%-10s\n", "LABEL", "OFFSET", "SIZE", + "LEVEL", "TYPE", "SUBTYPE"); + + // printf("%-12s%-7s%-7s%-10s%-10s\n", "LABEL", "OFFSET", + // "LEVEL", "TYPE", "SUBTYPE"); + + while (p != NULL) { + PrintSym(p); + p = p->next; + } + printf("\n"); +} + +/* Search for a symbol name at level or below. We have to do multiple passes into the symbol table because we have to find + the name closest to us + + + If recur is non-zero, then we look through all of the levels, otherwise, only our level + We return a pointer to a SymbolTab structure so that we can use other functions/methods to get the attributes */ + +struct SymbTab *Search(char name[], int level, int recur) +{ + int i, flag = 0; + struct SymbTab *p; + + /* for each level, try to find our symbol */ + while (level >= 0) { + p = first; + while (p != NULL) { + if ((strcmp(p->name, name) == 0) && (p->level == level)) + return p; + p = p->next; + } + if (recur == 0) + return (NULL); /* we did not find it at our level */ + level--; /* check the next level up */ + } + + return NULL; /* did not find it, return 0 */ +} + +/* Remove all enteries that have the indicated level + We need to take care about updating first pointer into the linked list when we are deleting edge elements */ + +int Delete(int level) +{ + struct SymbTab *p, *f = NULL; /* we follow with pointer f */ + int SIZE = 0; + p = first; + + /* cruise through the list */ + + while (p != NULL) { + /* do we match? */ + if (p->level >= + level) { /* if it is the first in the list we have to update first, we know this by f being NULL */ + SIZE += p->mysize; + if (f == NULL) + first = p->next; + else /* not the first element */ + { + f->next = p->next; + } + p = p->next; + + } else { + /* update follow pointer, move the p pointer */ + f = p; + p = p->next; + } + } + return (SIZE); +} diff --git a/9LAB/testy/symtable.h b/9LAB/testy/symtable.h new file mode 100644 index 0000000..10c3af8 --- /dev/null +++ b/9LAB/testy/symtable.h @@ -0,0 +1,65 @@ +/* Symbol Table --linked list headers + Used for Compilers class + + Modified Spring 2015 to allow for name to pointed to by symtable, instead + of copied, since the name is copied into the heap + + Modified to have levels. A level 0 means global variable, other levels + means in range of the function. We start out our + offsets at 0 (from stack pointer) for level 1,,,when we enter a functional + declaration. + + We increment offset each time we insert a new variable. A variable is + considered to be valid if it is found in the symbol table at our level or + lesser level. If at 0, then it is global. + + We return a pointer to the symbol table + when a variable matches our creteria. + + We add a routine to remove variables at our level and above. +*/ +/* +Ziad Arafat - Apr 26 2021 +Lab 9 +*/ + +#include "ast.h" + +#ifndef _SYMTAB +#define _SYMTAB + +char *TEMP_CREATE(); + +void Display(); +int Delete(int level); + +int FetchAddr(char *lab); + +// The types an ID can have +enum ID_Sub_Type { + ID_Sub_Type_Scalar, + ID_Sub_Type_Method, + ID_Sub_Type_Extern_Method, + ID_Sub_Type_Array, + // ID_Sub_Type_Void // OOps this is not a thing +}; + +struct SymbTab { + char *name; + int offset; /* from activation record boundary */ + int mysize; /* number of words this item is 1 or more */ + int level; /* the level where we found the variable */ + enum AST_Decaf_Types Type; /* the type of the symbol */ + enum ID_Sub_Type SubType; /* the element is a function */ + ASTnode *fparms; /* pointer to parameters of the function in the AST */ + + struct SymbTab *next; +}; + +struct SymbTab *Insert(char *name, enum AST_Decaf_Types Type, + enum ID_Sub_Type subtype, int level, int mysize, + int offset, ASTnode *fparms); + +struct SymbTab *Search(char name[], int level, int recur); + +#endif diff --git a/9LAB/testy/test4.decaf b/9LAB/testy/test4.decaf new file mode 100644 index 0000000..d94df11 --- /dev/null +++ b/9LAB/testy/test4.decaf @@ -0,0 +1,42 @@ +extern func print_int (int) void; +extern func print_string (string) void; +extern func read_int () int; + +package foo { + var y int = 7; + var Z int; + var A[100] int; + var x bool = true; + + func dothis(a int, s bool) void { + if (a == 5) { + print_string("x is 5"); + } else { + print_string("x is not 5"); + } + } + + func main () int + { + var x int; + print_string("hello, what is the meaning of life: "); + x = read_int(); + print_string("The meaning of life is: "); + print_int(x); + + x = 0; + while (x > 0) { + print_int(x); + x = x - 1; + } + + x = x + 1 - 2 + 5; + + dothis(5, true); + + + + } // of main + +} // of foo + diff --git a/9LAB/testy/y.output b/9LAB/testy/y.output new file mode 100644 index 0000000..d829ded --- /dev/null +++ b/9LAB/testy/y.output @@ -0,0 +1,1918 @@ +Grammar + + 0 $accept: Program $end + + 1 Program: Externs T_PACKAGE T_ID '{' FieldDecls MethodDecls '}' + + 2 Externs: %empty + 3 | ExternDefn Externs + + 4 ExternDefn: T_EXTERN T_FUNC T_ID '(' ExternParmList ')' MethodType ';' + + 5 ExternParmList: %empty + 6 | FullExternParmList + + 7 FullExternParmList: ExternType + 8 | ExternType ',' ExternParmList + + 9 FieldDecls: %empty + 10 | FieldDecl FieldDecls + + 11 FieldDecl: T_VAR T_ID Type ';' + 12 | T_VAR T_ID ArrayType ';' + 13 | T_VAR T_ID Type T_ASSIGN Constant ';' + + 14 MethodDecls: %empty + 15 | MethodDecl MethodDecls + + 16 $@1: %empty + + 17 $@2: %empty + + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' MethodType $@2 Block + + 19 IdTypeList: %empty + 20 | IdTypeList1 + + 21 IdTypeList1: T_ID Type + 22 | T_ID Type ',' IdTypeList + + 23 $@3: %empty + + 24 Block: '{' $@3 VarDecls Statements '}' + + 25 VarDecls: %empty + 26 | VarDecl VarDecls + + 27 VarDecl: T_VAR T_ID Type ';' + 28 | T_VAR T_ID ArrayType ';' + + 29 Statements: %empty + 30 | Statement Statements + + 31 Statement: Block + 32 | Assign ';' + 33 | MethodCall ';' + 34 | IfStmt + 35 | WhileStmt + 36 | ReturnStmt + 37 | BreakStmt + 38 | ContinueStmt + + 39 ContinueStmt: T_CONTINUE ';' + + 40 WhileStmt: T_WHILE '(' Expr ')' Block + + 41 BreakStmt: T_BREAK ';' + + 42 IfStmt: T_IF '(' Expr ')' Block T_ELSE Block + 43 | T_IF '(' Expr ')' Block + + 44 ReturnStmt: T_RETURN ';' + 45 | T_RETURN '(' ')' ';' + 46 | T_RETURN '(' Expr ')' ';' + + 47 Assign: Lvalue T_ASSIGN Expr + + 48 Lvalue: T_ID + 49 | T_ID '[' Expr ']' + + 50 MethodCall: T_ID '(' MethodArgs ')' + + 51 MethodArg: Expr + + 52 MethodArgs: %empty + 53 | FullMethodArgs + + 54 FullMethodArgs: MethodArg + 55 | MethodArg ',' MethodArgs + + 56 Expr: Simpleexpression + + 57 Simpleexpression: Additiveexpression + 58 | Simpleexpression Relop Additiveexpression + + 59 Relop: '<' + 60 | '>' + 61 | T_EQ + 62 | T_LEQ + 63 | T_GEQ + 64 | T_NEQ + + 65 Additiveexpression: Term + 66 | Additiveexpression Addop Term + + 67 Addop: '+' + 68 | '-' + + 69 Term: Factor + 70 | Term Multop Factor + + 71 Multop: '*' + 72 | '/' + 73 | '%' + 74 | T_AND + 75 | T_OR + 76 | T_LEFTSHIFT + 77 | T_RIGHTSHIFT + + 78 Factor: T_ID + 79 | MethodCall + 80 | T_ID '[' Expr ']' + 81 | Constant + 82 | '(' Expr ')' + 83 | '!' Factor + 84 | T_STRINGCONSTANT + 85 | '-' Factor + + 86 ExternType: T_STRINGTYPE + 87 | Type + + 88 Type: T_INTTYPE + 89 | T_BOOLTYPE + + 90 MethodType: T_VOID + 91 | Type + + 92 BoolConstant: T_TRUE + 93 | T_FALSE + + 94 ArrayType: '[' T_INTCONSTANT ']' Type + + 95 Constant: T_INTCONSTANT + 96 | BoolConstant + + +Terminals, with rules where they appear + +$end (0) 0 +'!' (33) 83 +'%' (37) 73 +'(' (40) 4 18 40 42 43 45 46 50 82 +')' (41) 4 18 40 42 43 45 46 50 82 +'*' (42) 71 +'+' (43) 67 +',' (44) 8 22 55 +'-' (45) 68 85 +'/' (47) 72 +';' (59) 4 11 12 13 27 28 32 33 39 41 44 45 46 +'<' (60) 59 +'>' (62) 60 +'[' (91) 49 80 94 +']' (93) 49 80 94 +'{' (123) 1 24 +'}' (125) 1 24 +error (256) +T_AND (258) 74 +T_ASSIGN (259) 13 47 +T_BOOLTYPE (260) 89 +T_BREAK (261) 41 +T_CONTINUE (262) 39 +T_ELSE (263) 42 +T_EQ (264) 61 +T_EXTERN (265) 4 +T_FALSE (266) 93 +T_FUNC (267) 4 18 +T_GEQ (268) 63 +T_ID (269) 1 4 11 12 13 18 21 22 27 28 48 49 50 78 80 +T_IF (270) 42 43 +T_INTCONSTANT (271) 94 95 +T_INTTYPE (272) 88 +T_LEFTSHIFT (273) 76 +T_LEQ (274) 62 +T_NEQ (275) 64 +T_OR (276) 75 +T_PACKAGE (277) 1 +T_RETURN (278) 44 45 46 +T_RIGHTSHIFT (279) 77 +T_STRINGCONSTANT (280) 84 +T_STRINGTYPE (281) 86 +T_TRUE (282) 92 +T_VAR (283) 11 12 13 27 28 +T_VOID (284) 90 +T_WHILE (285) 40 + + +Nonterminals, with rules where they appear + +$accept (47) + on left: 0 +Program (48) + on left: 1, on right: 0 +Externs (49) + on left: 2 3, on right: 1 3 +ExternDefn (50) + on left: 4, on right: 3 +ExternParmList (51) + on left: 5 6, on right: 4 8 +FullExternParmList (52) + on left: 7 8, on right: 6 +FieldDecls (53) + on left: 9 10, on right: 1 10 +FieldDecl (54) + on left: 11 12 13, on right: 10 +MethodDecls (55) + on left: 14 15, on right: 1 15 +MethodDecl (56) + on left: 18, on right: 15 +$@1 (57) + on left: 16, on right: 18 +$@2 (58) + on left: 17, on right: 18 +IdTypeList (59) + on left: 19 20, on right: 18 22 +IdTypeList1 (60) + on left: 21 22, on right: 20 +Block (61) + on left: 24, on right: 18 31 40 42 43 +$@3 (62) + on left: 23, on right: 24 +VarDecls (63) + on left: 25 26, on right: 24 26 +VarDecl (64) + on left: 27 28, on right: 26 +Statements (65) + on left: 29 30, on right: 24 30 +Statement (66) + on left: 31 32 33 34 35 36 37 38, on right: 30 +ContinueStmt (67) + on left: 39, on right: 38 +WhileStmt (68) + on left: 40, on right: 35 +BreakStmt (69) + on left: 41, on right: 37 +IfStmt (70) + on left: 42 43, on right: 34 +ReturnStmt (71) + on left: 44 45 46, on right: 36 +Assign (72) + on left: 47, on right: 32 +Lvalue (73) + on left: 48 49, on right: 47 +MethodCall (74) + on left: 50, on right: 33 79 +MethodArg (75) + on left: 51, on right: 54 55 +MethodArgs (76) + on left: 52 53, on right: 50 55 +FullMethodArgs (77) + on left: 54 55, on right: 53 +Expr (78) + on left: 56, on right: 40 42 43 46 47 49 51 80 82 +Simpleexpression (79) + on left: 57 58, on right: 56 58 +Relop (80) + on left: 59 60 61 62 63 64, on right: 58 +Additiveexpression (81) + on left: 65 66, on right: 57 58 66 +Addop (82) + on left: 67 68, on right: 66 +Term (83) + on left: 69 70, on right: 65 66 70 +Multop (84) + on left: 71 72 73 74 75 76 77, on right: 70 +Factor (85) + on left: 78 79 80 81 82 83 84 85, on right: 69 70 83 85 +ExternType (86) + on left: 86 87, on right: 7 8 +Type (87) + on left: 88 89, on right: 11 13 21 22 27 87 91 94 +MethodType (88) + on left: 90 91, on right: 4 18 +BoolConstant (89) + on left: 92 93, on right: 96 +ArrayType (90) + on left: 94, on right: 12 28 +Constant (91) + on left: 95 96, on right: 13 81 + + +State 0 + + 0 $accept: . Program $end + + T_EXTERN shift, and go to state 1 + + $default reduce using rule 2 (Externs) + + Program go to state 2 + Externs go to state 3 + ExternDefn go to state 4 + + +State 1 + + 4 ExternDefn: T_EXTERN . T_FUNC T_ID '(' ExternParmList ')' MethodType ';' + + T_FUNC shift, and go to state 5 + + +State 2 + + 0 $accept: Program . $end + + $end shift, and go to state 6 + + +State 3 + + 1 Program: Externs . T_PACKAGE T_ID '{' FieldDecls MethodDecls '}' + + T_PACKAGE shift, and go to state 7 + + +State 4 + + 3 Externs: ExternDefn . Externs + + T_EXTERN shift, and go to state 1 + + $default reduce using rule 2 (Externs) + + Externs go to state 8 + ExternDefn go to state 4 + + +State 5 + + 4 ExternDefn: T_EXTERN T_FUNC . T_ID '(' ExternParmList ')' MethodType ';' + + T_ID shift, and go to state 9 + + +State 6 + + 0 $accept: Program $end . + + $default accept + + +State 7 + + 1 Program: Externs T_PACKAGE . T_ID '{' FieldDecls MethodDecls '}' + + T_ID shift, and go to state 10 + + +State 8 + + 3 Externs: ExternDefn Externs . + + $default reduce using rule 3 (Externs) + + +State 9 + + 4 ExternDefn: T_EXTERN T_FUNC T_ID . '(' ExternParmList ')' MethodType ';' + + '(' shift, and go to state 11 + + +State 10 + + 1 Program: Externs T_PACKAGE T_ID . '{' FieldDecls MethodDecls '}' + + '{' shift, and go to state 12 + + +State 11 + + 4 ExternDefn: T_EXTERN T_FUNC T_ID '(' . ExternParmList ')' MethodType ';' + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + T_STRINGTYPE shift, and go to state 15 + + $default reduce using rule 5 (ExternParmList) + + ExternParmList go to state 16 + FullExternParmList go to state 17 + ExternType go to state 18 + Type go to state 19 + + +State 12 + + 1 Program: Externs T_PACKAGE T_ID '{' . FieldDecls MethodDecls '}' + + T_VAR shift, and go to state 20 + + $default reduce using rule 9 (FieldDecls) + + FieldDecls go to state 21 + FieldDecl go to state 22 + + +State 13 + + 89 Type: T_BOOLTYPE . + + $default reduce using rule 89 (Type) + + +State 14 + + 88 Type: T_INTTYPE . + + $default reduce using rule 88 (Type) + + +State 15 + + 86 ExternType: T_STRINGTYPE . + + $default reduce using rule 86 (ExternType) + + +State 16 + + 4 ExternDefn: T_EXTERN T_FUNC T_ID '(' ExternParmList . ')' MethodType ';' + + ')' shift, and go to state 23 + + +State 17 + + 6 ExternParmList: FullExternParmList . + + $default reduce using rule 6 (ExternParmList) + + +State 18 + + 7 FullExternParmList: ExternType . + 8 | ExternType . ',' ExternParmList + + ',' shift, and go to state 24 + + $default reduce using rule 7 (FullExternParmList) + + +State 19 + + 87 ExternType: Type . + + $default reduce using rule 87 (ExternType) + + +State 20 + + 11 FieldDecl: T_VAR . T_ID Type ';' + 12 | T_VAR . T_ID ArrayType ';' + 13 | T_VAR . T_ID Type T_ASSIGN Constant ';' + + T_ID shift, and go to state 25 + + +State 21 + + 1 Program: Externs T_PACKAGE T_ID '{' FieldDecls . MethodDecls '}' + + T_FUNC shift, and go to state 26 + + $default reduce using rule 14 (MethodDecls) + + MethodDecls go to state 27 + MethodDecl go to state 28 + + +State 22 + + 10 FieldDecls: FieldDecl . FieldDecls + + T_VAR shift, and go to state 20 + + $default reduce using rule 9 (FieldDecls) + + FieldDecls go to state 29 + FieldDecl go to state 22 + + +State 23 + + 4 ExternDefn: T_EXTERN T_FUNC T_ID '(' ExternParmList ')' . MethodType ';' + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + T_VOID shift, and go to state 30 + + Type go to state 31 + MethodType go to state 32 + + +State 24 + + 8 FullExternParmList: ExternType ',' . ExternParmList + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + T_STRINGTYPE shift, and go to state 15 + + $default reduce using rule 5 (ExternParmList) + + ExternParmList go to state 33 + FullExternParmList go to state 17 + ExternType go to state 18 + Type go to state 19 + + +State 25 + + 11 FieldDecl: T_VAR T_ID . Type ';' + 12 | T_VAR T_ID . ArrayType ';' + 13 | T_VAR T_ID . Type T_ASSIGN Constant ';' + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + '[' shift, and go to state 34 + + Type go to state 35 + ArrayType go to state 36 + + +State 26 + + 18 MethodDecl: T_FUNC . T_ID $@1 '(' IdTypeList ')' MethodType $@2 Block + + T_ID shift, and go to state 37 + + +State 27 + + 1 Program: Externs T_PACKAGE T_ID '{' FieldDecls MethodDecls . '}' + + '}' shift, and go to state 38 + + +State 28 + + 15 MethodDecls: MethodDecl . MethodDecls + + T_FUNC shift, and go to state 26 + + $default reduce using rule 14 (MethodDecls) + + MethodDecls go to state 39 + MethodDecl go to state 28 + + +State 29 + + 10 FieldDecls: FieldDecl FieldDecls . + + $default reduce using rule 10 (FieldDecls) + + +State 30 + + 90 MethodType: T_VOID . + + $default reduce using rule 90 (MethodType) + + +State 31 + + 91 MethodType: Type . + + $default reduce using rule 91 (MethodType) + + +State 32 + + 4 ExternDefn: T_EXTERN T_FUNC T_ID '(' ExternParmList ')' MethodType . ';' + + ';' shift, and go to state 40 + + +State 33 + + 8 FullExternParmList: ExternType ',' ExternParmList . + + $default reduce using rule 8 (FullExternParmList) + + +State 34 + + 94 ArrayType: '[' . T_INTCONSTANT ']' Type + + T_INTCONSTANT shift, and go to state 41 + + +State 35 + + 11 FieldDecl: T_VAR T_ID Type . ';' + 13 | T_VAR T_ID Type . T_ASSIGN Constant ';' + + T_ASSIGN shift, and go to state 42 + ';' shift, and go to state 43 + + +State 36 + + 12 FieldDecl: T_VAR T_ID ArrayType . ';' + + ';' shift, and go to state 44 + + +State 37 + + 18 MethodDecl: T_FUNC T_ID . $@1 '(' IdTypeList ')' MethodType $@2 Block + + $default reduce using rule 16 ($@1) + + $@1 go to state 45 + + +State 38 + + 1 Program: Externs T_PACKAGE T_ID '{' FieldDecls MethodDecls '}' . + + $default reduce using rule 1 (Program) + + +State 39 + + 15 MethodDecls: MethodDecl MethodDecls . + + $default reduce using rule 15 (MethodDecls) + + +State 40 + + 4 ExternDefn: T_EXTERN T_FUNC T_ID '(' ExternParmList ')' MethodType ';' . + + $default reduce using rule 4 (ExternDefn) + + +State 41 + + 94 ArrayType: '[' T_INTCONSTANT . ']' Type + + ']' shift, and go to state 46 + + +State 42 + + 13 FieldDecl: T_VAR T_ID Type T_ASSIGN . Constant ';' + + T_FALSE shift, and go to state 47 + T_INTCONSTANT shift, and go to state 48 + T_TRUE shift, and go to state 49 + + BoolConstant go to state 50 + Constant go to state 51 + + +State 43 + + 11 FieldDecl: T_VAR T_ID Type ';' . + + $default reduce using rule 11 (FieldDecl) + + +State 44 + + 12 FieldDecl: T_VAR T_ID ArrayType ';' . + + $default reduce using rule 12 (FieldDecl) + + +State 45 + + 18 MethodDecl: T_FUNC T_ID $@1 . '(' IdTypeList ')' MethodType $@2 Block + + '(' shift, and go to state 52 + + +State 46 + + 94 ArrayType: '[' T_INTCONSTANT ']' . Type + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + + Type go to state 53 + + +State 47 + + 93 BoolConstant: T_FALSE . + + $default reduce using rule 93 (BoolConstant) + + +State 48 + + 95 Constant: T_INTCONSTANT . + + $default reduce using rule 95 (Constant) + + +State 49 + + 92 BoolConstant: T_TRUE . + + $default reduce using rule 92 (BoolConstant) + + +State 50 + + 96 Constant: BoolConstant . + + $default reduce using rule 96 (Constant) + + +State 51 + + 13 FieldDecl: T_VAR T_ID Type T_ASSIGN Constant . ';' + + ';' shift, and go to state 54 + + +State 52 + + 18 MethodDecl: T_FUNC T_ID $@1 '(' . IdTypeList ')' MethodType $@2 Block + + T_ID shift, and go to state 55 + + $default reduce using rule 19 (IdTypeList) + + IdTypeList go to state 56 + IdTypeList1 go to state 57 + + +State 53 + + 94 ArrayType: '[' T_INTCONSTANT ']' Type . + + $default reduce using rule 94 (ArrayType) + + +State 54 + + 13 FieldDecl: T_VAR T_ID Type T_ASSIGN Constant ';' . + + $default reduce using rule 13 (FieldDecl) + + +State 55 + + 21 IdTypeList1: T_ID . Type + 22 | T_ID . Type ',' IdTypeList + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + + Type go to state 58 + + +State 56 + + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList . ')' MethodType $@2 Block + + ')' shift, and go to state 59 + + +State 57 + + 20 IdTypeList: IdTypeList1 . + + $default reduce using rule 20 (IdTypeList) + + +State 58 + + 21 IdTypeList1: T_ID Type . + 22 | T_ID Type . ',' IdTypeList + + ',' shift, and go to state 60 + + $default reduce using rule 21 (IdTypeList1) + + +State 59 + + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' . MethodType $@2 Block + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + T_VOID shift, and go to state 30 + + Type go to state 31 + MethodType go to state 61 + + +State 60 + + 22 IdTypeList1: T_ID Type ',' . IdTypeList + + T_ID shift, and go to state 55 + + $default reduce using rule 19 (IdTypeList) + + IdTypeList go to state 62 + IdTypeList1 go to state 57 + + +State 61 + + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' MethodType . $@2 Block + + $default reduce using rule 17 ($@2) + + $@2 go to state 63 + + +State 62 + + 22 IdTypeList1: T_ID Type ',' IdTypeList . + + $default reduce using rule 22 (IdTypeList1) + + +State 63 + + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' MethodType $@2 . Block + + '{' shift, and go to state 64 + + Block go to state 65 + + +State 64 + + 24 Block: '{' . $@3 VarDecls Statements '}' + + $default reduce using rule 23 ($@3) + + $@3 go to state 66 + + +State 65 + + 18 MethodDecl: T_FUNC T_ID $@1 '(' IdTypeList ')' MethodType $@2 Block . + + $default reduce using rule 18 (MethodDecl) + + +State 66 + + 24 Block: '{' $@3 . VarDecls Statements '}' + + T_VAR shift, and go to state 67 + + $default reduce using rule 25 (VarDecls) + + VarDecls go to state 68 + VarDecl go to state 69 + + +State 67 + + 27 VarDecl: T_VAR . T_ID Type ';' + 28 | T_VAR . T_ID ArrayType ';' + + T_ID shift, and go to state 70 + + +State 68 + + 24 Block: '{' $@3 VarDecls . Statements '}' + + T_BREAK shift, and go to state 71 + T_CONTINUE shift, and go to state 72 + T_ID shift, and go to state 73 + T_IF shift, and go to state 74 + T_RETURN shift, and go to state 75 + T_WHILE shift, and go to state 76 + '{' shift, and go to state 64 + + $default reduce using rule 29 (Statements) + + Block go to state 77 + Statements go to state 78 + Statement go to state 79 + ContinueStmt go to state 80 + WhileStmt go to state 81 + BreakStmt go to state 82 + IfStmt go to state 83 + ReturnStmt go to state 84 + Assign go to state 85 + Lvalue go to state 86 + MethodCall go to state 87 + + +State 69 + + 26 VarDecls: VarDecl . VarDecls + + T_VAR shift, and go to state 67 + + $default reduce using rule 25 (VarDecls) + + VarDecls go to state 88 + VarDecl go to state 69 + + +State 70 + + 27 VarDecl: T_VAR T_ID . Type ';' + 28 | T_VAR T_ID . ArrayType ';' + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + '[' shift, and go to state 34 + + Type go to state 89 + ArrayType go to state 90 + + +State 71 + + 41 BreakStmt: T_BREAK . ';' + + ';' shift, and go to state 91 + + +State 72 + + 39 ContinueStmt: T_CONTINUE . ';' + + ';' shift, and go to state 92 + + +State 73 + + 48 Lvalue: T_ID . + 49 | T_ID . '[' Expr ']' + 50 MethodCall: T_ID . '(' MethodArgs ')' + + '(' shift, and go to state 93 + '[' shift, and go to state 94 + + $default reduce using rule 48 (Lvalue) + + +State 74 + + 42 IfStmt: T_IF . '(' Expr ')' Block T_ELSE Block + 43 | T_IF . '(' Expr ')' Block + + '(' shift, and go to state 95 + + +State 75 + + 44 ReturnStmt: T_RETURN . ';' + 45 | T_RETURN . '(' ')' ';' + 46 | T_RETURN . '(' Expr ')' ';' + + '(' shift, and go to state 96 + ';' shift, and go to state 97 + + +State 76 + + 40 WhileStmt: T_WHILE . '(' Expr ')' Block + + '(' shift, and go to state 98 + + +State 77 + + 31 Statement: Block . + + $default reduce using rule 31 (Statement) + + +State 78 + + 24 Block: '{' $@3 VarDecls Statements . '}' + + '}' shift, and go to state 99 + + +State 79 + + 30 Statements: Statement . Statements + + T_BREAK shift, and go to state 71 + T_CONTINUE shift, and go to state 72 + T_ID shift, and go to state 73 + T_IF shift, and go to state 74 + T_RETURN shift, and go to state 75 + T_WHILE shift, and go to state 76 + '{' shift, and go to state 64 + + $default reduce using rule 29 (Statements) + + Block go to state 77 + Statements go to state 100 + Statement go to state 79 + ContinueStmt go to state 80 + WhileStmt go to state 81 + BreakStmt go to state 82 + IfStmt go to state 83 + ReturnStmt go to state 84 + Assign go to state 85 + Lvalue go to state 86 + MethodCall go to state 87 + + +State 80 + + 38 Statement: ContinueStmt . + + $default reduce using rule 38 (Statement) + + +State 81 + + 35 Statement: WhileStmt . + + $default reduce using rule 35 (Statement) + + +State 82 + + 37 Statement: BreakStmt . + + $default reduce using rule 37 (Statement) + + +State 83 + + 34 Statement: IfStmt . + + $default reduce using rule 34 (Statement) + + +State 84 + + 36 Statement: ReturnStmt . + + $default reduce using rule 36 (Statement) + + +State 85 + + 32 Statement: Assign . ';' + + ';' shift, and go to state 101 + + +State 86 + + 47 Assign: Lvalue . T_ASSIGN Expr + + T_ASSIGN shift, and go to state 102 + + +State 87 + + 33 Statement: MethodCall . ';' + + ';' shift, and go to state 103 + + +State 88 + + 26 VarDecls: VarDecl VarDecls . + + $default reduce using rule 26 (VarDecls) + + +State 89 + + 27 VarDecl: T_VAR T_ID Type . ';' + + ';' shift, and go to state 104 + + +State 90 + + 28 VarDecl: T_VAR T_ID ArrayType . ';' + + ';' shift, and go to state 105 + + +State 91 + + 41 BreakStmt: T_BREAK ';' . + + $default reduce using rule 41 (BreakStmt) + + +State 92 + + 39 ContinueStmt: T_CONTINUE ';' . + + $default reduce using rule 39 (ContinueStmt) + + +State 93 + + 50 MethodCall: T_ID '(' . MethodArgs ')' + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + $default reduce using rule 52 (MethodArgs) + + MethodCall go to state 111 + MethodArg go to state 112 + MethodArgs go to state 113 + FullMethodArgs go to state 114 + Expr go to state 115 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 94 + + 49 Lvalue: T_ID '[' . Expr ']' + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 121 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 95 + + 42 IfStmt: T_IF '(' . Expr ')' Block T_ELSE Block + 43 | T_IF '(' . Expr ')' Block + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 122 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 96 + + 45 ReturnStmt: T_RETURN '(' . ')' ';' + 46 | T_RETURN '(' . Expr ')' ';' + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + ')' shift, and go to state 123 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 124 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 97 + + 44 ReturnStmt: T_RETURN ';' . + + $default reduce using rule 44 (ReturnStmt) + + +State 98 + + 40 WhileStmt: T_WHILE '(' . Expr ')' Block + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 125 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 99 + + 24 Block: '{' $@3 VarDecls Statements '}' . + + $default reduce using rule 24 (Block) + + +State 100 + + 30 Statements: Statement Statements . + + $default reduce using rule 30 (Statements) + + +State 101 + + 32 Statement: Assign ';' . + + $default reduce using rule 32 (Statement) + + +State 102 + + 47 Assign: Lvalue T_ASSIGN . Expr + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 126 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 103 + + 33 Statement: MethodCall ';' . + + $default reduce using rule 33 (Statement) + + +State 104 + + 27 VarDecl: T_VAR T_ID Type ';' . + + $default reduce using rule 27 (VarDecl) + + +State 105 + + 28 VarDecl: T_VAR T_ID ArrayType ';' . + + $default reduce using rule 28 (VarDecl) + + +State 106 + + 50 MethodCall: T_ID . '(' MethodArgs ')' + 78 Factor: T_ID . + 80 | T_ID . '[' Expr ']' + + '(' shift, and go to state 93 + '[' shift, and go to state 127 + + $default reduce using rule 78 (Factor) + + +State 107 + + 84 Factor: T_STRINGCONSTANT . + + $default reduce using rule 84 (Factor) + + +State 108 + + 82 Factor: '(' . Expr ')' + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 128 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 109 + + 85 Factor: '-' . Factor + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Factor go to state 129 + BoolConstant go to state 50 + Constant go to state 120 + + +State 110 + + 83 Factor: '!' . Factor + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Factor go to state 130 + BoolConstant go to state 50 + Constant go to state 120 + + +State 111 + + 79 Factor: MethodCall . + + $default reduce using rule 79 (Factor) + + +State 112 + + 54 FullMethodArgs: MethodArg . + 55 | MethodArg . ',' MethodArgs + + ',' shift, and go to state 131 + + $default reduce using rule 54 (FullMethodArgs) + + +State 113 + + 50 MethodCall: T_ID '(' MethodArgs . ')' + + ')' shift, and go to state 132 + + +State 114 + + 53 MethodArgs: FullMethodArgs . + + $default reduce using rule 53 (MethodArgs) + + +State 115 + + 51 MethodArg: Expr . + + $default reduce using rule 51 (MethodArg) + + +State 116 + + 56 Expr: Simpleexpression . + 58 Simpleexpression: Simpleexpression . Relop Additiveexpression + + T_EQ shift, and go to state 133 + T_GEQ shift, and go to state 134 + T_LEQ shift, and go to state 135 + T_NEQ shift, and go to state 136 + '<' shift, and go to state 137 + '>' shift, and go to state 138 + + $default reduce using rule 56 (Expr) + + Relop go to state 139 + + +State 117 + + 57 Simpleexpression: Additiveexpression . + 66 Additiveexpression: Additiveexpression . Addop Term + + '+' shift, and go to state 140 + '-' shift, and go to state 141 + + $default reduce using rule 57 (Simpleexpression) + + Addop go to state 142 + + +State 118 + + 65 Additiveexpression: Term . + 70 Term: Term . Multop Factor + + T_AND shift, and go to state 143 + T_LEFTSHIFT shift, and go to state 144 + T_OR shift, and go to state 145 + T_RIGHTSHIFT shift, and go to state 146 + '*' shift, and go to state 147 + '/' shift, and go to state 148 + '%' shift, and go to state 149 + + $default reduce using rule 65 (Additiveexpression) + + Multop go to state 150 + + +State 119 + + 69 Term: Factor . + + $default reduce using rule 69 (Term) + + +State 120 + + 81 Factor: Constant . + + $default reduce using rule 81 (Factor) + + +State 121 + + 49 Lvalue: T_ID '[' Expr . ']' + + ']' shift, and go to state 151 + + +State 122 + + 42 IfStmt: T_IF '(' Expr . ')' Block T_ELSE Block + 43 | T_IF '(' Expr . ')' Block + + ')' shift, and go to state 152 + + +State 123 + + 45 ReturnStmt: T_RETURN '(' ')' . ';' + + ';' shift, and go to state 153 + + +State 124 + + 46 ReturnStmt: T_RETURN '(' Expr . ')' ';' + + ')' shift, and go to state 154 + + +State 125 + + 40 WhileStmt: T_WHILE '(' Expr . ')' Block + + ')' shift, and go to state 155 + + +State 126 + + 47 Assign: Lvalue T_ASSIGN Expr . + + $default reduce using rule 47 (Assign) + + +State 127 + + 80 Factor: T_ID '[' . Expr ']' + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Expr go to state 156 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 128 + + 82 Factor: '(' Expr . ')' + + ')' shift, and go to state 157 + + +State 129 + + 85 Factor: '-' Factor . + + $default reduce using rule 85 (Factor) + + +State 130 + + 83 Factor: '!' Factor . + + $default reduce using rule 83 (Factor) + + +State 131 + + 55 FullMethodArgs: MethodArg ',' . MethodArgs + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + $default reduce using rule 52 (MethodArgs) + + MethodCall go to state 111 + MethodArg go to state 112 + MethodArgs go to state 158 + FullMethodArgs go to state 114 + Expr go to state 115 + Simpleexpression go to state 116 + Additiveexpression go to state 117 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 132 + + 50 MethodCall: T_ID '(' MethodArgs ')' . + + $default reduce using rule 50 (MethodCall) + + +State 133 + + 61 Relop: T_EQ . + + $default reduce using rule 61 (Relop) + + +State 134 + + 63 Relop: T_GEQ . + + $default reduce using rule 63 (Relop) + + +State 135 + + 62 Relop: T_LEQ . + + $default reduce using rule 62 (Relop) + + +State 136 + + 64 Relop: T_NEQ . + + $default reduce using rule 64 (Relop) + + +State 137 + + 59 Relop: '<' . + + $default reduce using rule 59 (Relop) + + +State 138 + + 60 Relop: '>' . + + $default reduce using rule 60 (Relop) + + +State 139 + + 58 Simpleexpression: Simpleexpression Relop . Additiveexpression + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Additiveexpression go to state 159 + Term go to state 118 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 140 + + 67 Addop: '+' . + + $default reduce using rule 67 (Addop) + + +State 141 + + 68 Addop: '-' . + + $default reduce using rule 68 (Addop) + + +State 142 + + 66 Additiveexpression: Additiveexpression Addop . Term + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Term go to state 160 + Factor go to state 119 + BoolConstant go to state 50 + Constant go to state 120 + + +State 143 + + 74 Multop: T_AND . + + $default reduce using rule 74 (Multop) + + +State 144 + + 76 Multop: T_LEFTSHIFT . + + $default reduce using rule 76 (Multop) + + +State 145 + + 75 Multop: T_OR . + + $default reduce using rule 75 (Multop) + + +State 146 + + 77 Multop: T_RIGHTSHIFT . + + $default reduce using rule 77 (Multop) + + +State 147 + + 71 Multop: '*' . + + $default reduce using rule 71 (Multop) + + +State 148 + + 72 Multop: '/' . + + $default reduce using rule 72 (Multop) + + +State 149 + + 73 Multop: '%' . + + $default reduce using rule 73 (Multop) + + +State 150 + + 70 Term: Term Multop . Factor + + T_FALSE shift, and go to state 47 + T_ID shift, and go to state 106 + T_INTCONSTANT shift, and go to state 48 + T_STRINGCONSTANT shift, and go to state 107 + T_TRUE shift, and go to state 49 + '(' shift, and go to state 108 + '-' shift, and go to state 109 + '!' shift, and go to state 110 + + MethodCall go to state 111 + Factor go to state 161 + BoolConstant go to state 50 + Constant go to state 120 + + +State 151 + + 49 Lvalue: T_ID '[' Expr ']' . + + $default reduce using rule 49 (Lvalue) + + +State 152 + + 42 IfStmt: T_IF '(' Expr ')' . Block T_ELSE Block + 43 | T_IF '(' Expr ')' . Block + + '{' shift, and go to state 64 + + Block go to state 162 + + +State 153 + + 45 ReturnStmt: T_RETURN '(' ')' ';' . + + $default reduce using rule 45 (ReturnStmt) + + +State 154 + + 46 ReturnStmt: T_RETURN '(' Expr ')' . ';' + + ';' shift, and go to state 163 + + +State 155 + + 40 WhileStmt: T_WHILE '(' Expr ')' . Block + + '{' shift, and go to state 64 + + Block go to state 164 + + +State 156 + + 80 Factor: T_ID '[' Expr . ']' + + ']' shift, and go to state 165 + + +State 157 + + 82 Factor: '(' Expr ')' . + + $default reduce using rule 82 (Factor) + + +State 158 + + 55 FullMethodArgs: MethodArg ',' MethodArgs . + + $default reduce using rule 55 (FullMethodArgs) + + +State 159 + + 58 Simpleexpression: Simpleexpression Relop Additiveexpression . + 66 Additiveexpression: Additiveexpression . Addop Term + + '+' shift, and go to state 140 + '-' shift, and go to state 141 + + $default reduce using rule 58 (Simpleexpression) + + Addop go to state 142 + + +State 160 + + 66 Additiveexpression: Additiveexpression Addop Term . + 70 Term: Term . Multop Factor + + T_AND shift, and go to state 143 + T_LEFTSHIFT shift, and go to state 144 + T_OR shift, and go to state 145 + T_RIGHTSHIFT shift, and go to state 146 + '*' shift, and go to state 147 + '/' shift, and go to state 148 + '%' shift, and go to state 149 + + $default reduce using rule 66 (Additiveexpression) + + Multop go to state 150 + + +State 161 + + 70 Term: Term Multop Factor . + + $default reduce using rule 70 (Term) + + +State 162 + + 42 IfStmt: T_IF '(' Expr ')' Block . T_ELSE Block + 43 | T_IF '(' Expr ')' Block . + + T_ELSE shift, and go to state 166 + + $default reduce using rule 43 (IfStmt) + + +State 163 + + 46 ReturnStmt: T_RETURN '(' Expr ')' ';' . + + $default reduce using rule 46 (ReturnStmt) + + +State 164 + + 40 WhileStmt: T_WHILE '(' Expr ')' Block . + + $default reduce using rule 40 (WhileStmt) + + +State 165 + + 80 Factor: T_ID '[' Expr ']' . + + $default reduce using rule 80 (Factor) + + +State 166 + + 42 IfStmt: T_IF '(' Expr ')' Block T_ELSE . Block + + '{' shift, and go to state 64 + + Block go to state 167 + + +State 167 + + 42 IfStmt: T_IF '(' Expr ')' Block T_ELSE Block . + + $default reduce using rule 42 (IfStmt) diff --git a/9LAB/testy/y.tab.c b/9LAB/testy/y.tab.c new file mode 100644 index 0000000..05a9cc5 --- /dev/null +++ b/9LAB/testy/y.tab.c @@ -0,0 +1,2774 @@ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.4" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 18 "lab9.y" /* yacc.c:339 */ + +#include +#include +#include +#include + +#include "ast.h" +#include "symtable.h" +#include "emit.h" + +int level = 0; // the level of the scope we are in. +int offset = 0; // Keeps track of fielddecl offset values +int goffset = 0; // keeps track of +int maxoffset; + +int yylex(); + +extern int yylineno; // import the yylineno variable +void yyerror (s) /* Called by yyparse on error */ + char *s; +{ + // changed these to output to stderr + fprintf(stderr, "%s ", s); + + // print out the line number of the syntax error. + fprintf(stderr, "Error on line: %d \n", yylineno); +} + +struct ASTnodetype *PROGRAM; + + +#line 98 "y.tab.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* In a future release of Bison, this section will be replaced + by #include "y.tab.h". */ +#ifndef YY_YY_Y_TAB_H_INCLUDED +# define YY_YY_Y_TAB_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + T_AND = 258, + T_ASSIGN = 259, + T_BOOLTYPE = 260, + T_BREAK = 261, + T_CONTINUE = 262, + T_ELSE = 263, + T_EQ = 264, + T_EXTERN = 265, + T_FALSE = 266, + T_FUNC = 267, + T_GEQ = 268, + T_ID = 269, + T_IF = 270, + T_INTCONSTANT = 271, + T_INTTYPE = 272, + T_LEFTSHIFT = 273, + T_LEQ = 274, + T_NEQ = 275, + T_OR = 276, + T_PACKAGE = 277, + T_RETURN = 278, + T_RIGHTSHIFT = 279, + T_STRINGCONSTANT = 280, + T_STRINGTYPE = 281, + T_TRUE = 282, + T_VAR = 283, + T_VOID = 284, + T_WHILE = 285 + }; +#endif +/* Tokens. */ +#define T_AND 258 +#define T_ASSIGN 259 +#define T_BOOLTYPE 260 +#define T_BREAK 261 +#define T_CONTINUE 262 +#define T_ELSE 263 +#define T_EQ 264 +#define T_EXTERN 265 +#define T_FALSE 266 +#define T_FUNC 267 +#define T_GEQ 268 +#define T_ID 269 +#define T_IF 270 +#define T_INTCONSTANT 271 +#define T_INTTYPE 272 +#define T_LEFTSHIFT 273 +#define T_LEQ 274 +#define T_NEQ 275 +#define T_OR 276 +#define T_PACKAGE 277 +#define T_RETURN 278 +#define T_RIGHTSHIFT 279 +#define T_STRINGCONSTANT 280 +#define T_STRINGTYPE 281 +#define T_TRUE 282 +#define T_VAR 283 +#define T_VOID 284 +#define T_WHILE 285 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 56 "lab9.y" /* yacc.c:355 */ + + int value; + char* string; + struct ASTnodetype *astnode; + enum AST_Decaf_Types asttype; + enum AST_Operators operator; + +#line 206 "y.tab.c" /* yacc.c:355 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_Y_TAB_H_INCLUDED */ + +/* Copy the second part of user declarations. */ + +#line 223 "y.tab.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 6 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 153 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 47 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 45 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 97 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 168 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 285 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 46, 2, 2, 2, 45, 2, 2, + 33, 34, 43, 41, 36, 42, 2, 44, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 35, + 39, 2, 40, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 37, 2, 38, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 31, 2, 32, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 130, 130, 140, 141, 144, 167, 168, 171, 175, + 182, 183, 189, 205, 221, 241, 242, 250, 273, 250, + 295, 296, 299, 314, 335, 335, 359, 360, 366, 384, + 403, 404, 414, 415, 416, 417, 418, 419, 420, 421, + 425, 428, 434, 437, 450, 461, 462, 463, 469, 498, + 530, 556, 590, 600, 603, 608, 611, 627, 630, 631, + 652, 653, 654, 655, 656, 657, 660, 661, 678, 679, + 682, 683, 711, 712, 713, 714, 715, 716, 717, 720, + 741, 742, 763, 764, 765, 786, 791, 811, 812, 816, + 817, 820, 821, 824, 829, 836, 845, 851 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "T_AND", "T_ASSIGN", "T_BOOLTYPE", + "T_BREAK", "T_CONTINUE", "T_ELSE", "T_EQ", "T_EXTERN", "T_FALSE", + "T_FUNC", "T_GEQ", "T_ID", "T_IF", "T_INTCONSTANT", "T_INTTYPE", + "T_LEFTSHIFT", "T_LEQ", "T_NEQ", "T_OR", "T_PACKAGE", "T_RETURN", + "T_RIGHTSHIFT", "T_STRINGCONSTANT", "T_STRINGTYPE", "T_TRUE", "T_VAR", + "T_VOID", "T_WHILE", "'{'", "'}'", "'('", "')'", "';'", "','", "'['", + "']'", "'<'", "'>'", "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "$accept", + "Program", "Externs", "ExternDefn", "ExternParmList", + "FullExternParmList", "FieldDecls", "FieldDecl", "MethodDecls", + "MethodDecl", "$@1", "$@2", "IdTypeList", "IdTypeList1", "Block", "$@3", + "VarDecls", "VarDecl", "Statements", "Statement", "ContinueStmt", + "WhileStmt", "BreakStmt", "IfStmt", "ReturnStmt", "Assign", "Lvalue", + "MethodCall", "MethodArg", "MethodArgs", "FullMethodArgs", "Expr", + "Simpleexpression", "Relop", "Additiveexpression", "Addop", "Term", + "Multop", "Factor", "ExternType", "Type", "MethodType", "BoolConstant", + "ArrayType", "Constant", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 123, 125, 40, 41, 59, 44, 91, 93, 60, + 62, 43, 45, 42, 47, 37, 33 +}; +# endif + +#define YYPACT_NINF -106 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-106))) + +#define YYTABLE_NINF -1 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int8 yypact[] = +{ + 26, 3, 40, 37, 26, 50, -106, 58, -106, 42, + 51, 8, 53, -106, -106, -106, 39, -106, 43, -106, + 62, 71, 53, 45, 8, 9, 77, 64, 71, -106, + -106, -106, 60, -106, 81, 18, 65, -106, -106, -106, + -106, 61, 74, -106, -106, 69, 1, -106, -106, -106, + -106, 70, 84, -106, -106, 1, 72, -106, 68, 45, + 84, -106, -106, 76, -106, -106, 80, 95, 63, 80, + 9, 75, 78, -26, 79, 23, 82, -106, 85, 63, + -106, -106, -106, -106, -106, 83, 107, 86, -106, 87, + 88, -106, -106, 38, 38, 38, 5, -106, 38, -106, + -106, -106, 38, -106, -106, -106, -25, -106, 38, 38, + 38, -106, 89, 90, -106, -106, 48, -32, -1, -106, + -106, 91, 92, 93, 96, 97, -106, 38, 98, -106, + -106, 38, -106, -106, -106, -106, -106, -106, -106, 38, + -106, -106, 38, -106, -106, -106, -106, -106, -106, -106, + 38, -106, 76, -106, 99, 76, 100, -106, -106, -32, + -1, -106, 106, -106, -106, -106, 76, -106 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 3, 0, 0, 0, 3, 0, 1, 0, 4, 0, + 0, 6, 10, 90, 89, 87, 0, 7, 8, 88, + 0, 15, 10, 0, 6, 0, 0, 0, 15, 11, + 91, 92, 0, 9, 0, 0, 0, 17, 2, 16, + 5, 0, 0, 12, 13, 0, 0, 94, 96, 93, + 97, 0, 20, 95, 14, 0, 0, 21, 22, 0, + 20, 18, 23, 0, 24, 19, 26, 0, 30, 26, + 0, 0, 0, 49, 0, 0, 0, 32, 0, 30, + 39, 36, 38, 35, 37, 0, 0, 0, 27, 0, + 0, 42, 40, 53, 0, 0, 0, 45, 0, 25, + 31, 33, 0, 34, 28, 29, 79, 85, 0, 0, + 0, 80, 55, 0, 54, 52, 57, 58, 66, 70, + 82, 0, 0, 0, 0, 0, 48, 0, 0, 86, + 84, 53, 51, 62, 64, 63, 65, 60, 61, 0, + 68, 69, 0, 75, 77, 76, 78, 72, 73, 74, + 0, 50, 0, 46, 0, 0, 0, 83, 56, 59, + 67, 71, 44, 47, 41, 81, 0, 43 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -106, -106, 112, -106, 103, -106, 111, -106, 108, -106, + -106, -106, 59, -106, -63, -106, 66, -106, 41, -106, + -106, -106, -106, -106, -106, -106, -106, -13, -106, 6, + -106, -67, -106, -106, 0, -106, -2, -106, -105, -106, + -22, 94, -106, 73, 102 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 2, 3, 4, 16, 17, 21, 22, 27, 28, + 45, 63, 56, 57, 77, 66, 68, 69, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 111, 112, 113, + 114, 115, 116, 139, 117, 142, 118, 150, 119, 18, + 19, 32, 50, 36, 120 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_uint8 yytable[] = +{ + 65, 31, 143, 35, 129, 130, 13, 93, 93, 140, + 141, 94, 127, 13, 13, 5, 47, 144, 14, 106, + 145, 48, 42, 146, 53, 14, 14, 121, 122, 124, + 107, 125, 49, 58, 15, 126, 1, 31, 108, 123, + 6, 128, 147, 148, 149, 161, 34, 109, 89, 47, + 13, 110, 106, 43, 48, 87, 96, 133, 97, 7, + 156, 134, 14, 107, 9, 49, 87, 135, 136, 71, + 72, 108, 10, 23, 30, 11, 25, 73, 74, 24, + 109, 20, 12, 26, 110, 47, 75, 137, 138, 162, + 48, 37, 164, 76, 64, 40, 38, 41, 55, 46, + 44, 49, 52, 167, 60, 54, 59, 64, 67, 70, + 91, 102, 95, 92, 166, 98, 8, 99, 101, 62, + 100, 103, 104, 105, 132, 131, 152, 33, 153, 151, + 154, 155, 157, 29, 163, 88, 39, 158, 165, 159, + 160, 0, 0, 90, 51, 0, 0, 0, 0, 0, + 0, 0, 0, 61 +}; + +static const yytype_int16 yycheck[] = +{ + 63, 23, 3, 25, 109, 110, 5, 33, 33, 41, + 42, 37, 37, 5, 5, 12, 11, 18, 17, 14, + 21, 16, 4, 24, 46, 17, 17, 94, 95, 96, + 25, 98, 27, 55, 26, 102, 10, 59, 33, 34, + 0, 108, 43, 44, 45, 150, 37, 42, 70, 11, + 5, 46, 14, 35, 16, 68, 33, 9, 35, 22, + 127, 13, 17, 25, 14, 27, 79, 19, 20, 6, + 7, 33, 14, 34, 29, 33, 14, 14, 15, 36, + 42, 28, 31, 12, 46, 11, 23, 39, 40, 152, + 16, 14, 155, 30, 31, 35, 32, 16, 14, 38, + 35, 27, 33, 166, 36, 35, 34, 31, 28, 14, + 35, 4, 33, 35, 8, 33, 4, 32, 35, 60, + 79, 35, 35, 35, 34, 36, 34, 24, 35, 38, + 34, 34, 34, 22, 35, 69, 28, 131, 38, 139, + 142, -1, -1, 70, 42, -1, -1, -1, -1, -1, + -1, -1, -1, 59 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 10, 48, 49, 50, 12, 0, 22, 49, 14, + 14, 33, 31, 5, 17, 26, 51, 52, 86, 87, + 28, 53, 54, 34, 36, 14, 12, 55, 56, 53, + 29, 87, 88, 51, 37, 87, 90, 14, 32, 55, + 35, 16, 4, 35, 35, 57, 38, 11, 16, 27, + 89, 91, 33, 87, 35, 14, 59, 60, 87, 34, + 36, 88, 59, 58, 31, 61, 62, 28, 63, 64, + 14, 6, 7, 14, 15, 23, 30, 61, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 63, 87, + 90, 35, 35, 33, 37, 33, 33, 35, 33, 32, + 65, 35, 4, 35, 35, 35, 14, 25, 33, 42, + 46, 74, 75, 76, 77, 78, 79, 81, 83, 85, + 91, 78, 78, 34, 78, 78, 78, 37, 78, 85, + 85, 36, 34, 9, 13, 19, 20, 39, 40, 80, + 41, 42, 82, 3, 18, 21, 24, 43, 44, 45, + 84, 38, 34, 35, 34, 34, 78, 34, 76, 81, + 83, 85, 61, 35, 61, 38, 8, 61 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 47, 48, 49, 49, 50, 51, 51, 52, 52, + 53, 53, 54, 54, 54, 55, 55, 57, 58, 56, + 59, 59, 60, 60, 62, 61, 63, 63, 64, 64, + 65, 65, 66, 66, 66, 66, 66, 66, 66, 66, + 67, 68, 69, 70, 70, 71, 71, 71, 72, 73, + 73, 74, 75, 76, 76, 77, 77, 78, 79, 79, + 80, 80, 80, 80, 80, 80, 81, 81, 82, 82, + 83, 83, 84, 84, 84, 84, 84, 84, 84, 85, + 85, 85, 85, 85, 85, 85, 85, 86, 86, 87, + 87, 88, 88, 89, 89, 90, 91, 91 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 7, 0, 2, 8, 0, 1, 1, 3, + 0, 2, 4, 4, 6, 0, 2, 0, 0, 9, + 0, 1, 2, 4, 0, 5, 0, 2, 4, 4, + 0, 2, 1, 2, 2, 1, 1, 1, 1, 1, + 2, 5, 2, 7, 5, 2, 4, 5, 3, 1, + 4, 4, 1, 0, 1, 1, 3, 1, 1, 3, + 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, + 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 1, 3, 2, 1, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 4, 1, 1 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 130 "lab9.y" /* yacc.c:1646 */ + { + PROGRAM = ASTCreateNode(A_PROGRAM); + PROGRAM->S1 = (yyvsp[-6].astnode); + PROGRAM->S2 = ASTCreateNode(A_PACKAGE); + PROGRAM->S2->name = (yyvsp[-4].string); + PROGRAM->S2->S1 = (yyvsp[-2].astnode); + PROGRAM->S2->S2 = (yyvsp[-1].astnode); + } +#line 1429 "y.tab.c" /* yacc.c:1646 */ + break; + + case 3: +#line 140 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = NULL; } +#line 1435 "y.tab.c" /* yacc.c:1646 */ + break; + + case 4: +#line 141 "lab9.y" /* yacc.c:1646 */ + { (yyvsp[-1].astnode)->next = (yyvsp[0].astnode); } +#line 1441 "y.tab.c" /* yacc.c:1646 */ + break; + + case 5: +#line 144 "lab9.y" /* yacc.c:1646 */ + { + // we need to see if $3 has already been defined. + // if so => BARF + if (Search((yyvsp[-5].string), level, 0) != NULL) { + yyerror("Symbol already deafined"); + yyerror((yyvsp[-5].string)); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_EXTERN); + (yyval.astnode)->name = (yyvsp[-5].string); + (yyval.astnode)->A_Declared_Type = (yyvsp[-1].asttype); + (yyval.astnode)->size = 0; + (yyval.astnode)->S1 = (yyvsp[-3].astnode); // set the S1 to the list of params node + + // set our symbol to the return value of Insert() + (yyval.astnode)->symbol = Insert((yyvsp[-5].string),(yyvsp[-1].asttype),ID_Sub_Type_Extern_Method, level, 0, 0, (yyvsp[-3].astnode)); + // offset++; + + // moved to main + if(mydebug) Display(); // Display the table for debugging + } +#line 1467 "y.tab.c" /* yacc.c:1646 */ + break; + + case 6: +#line 167 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = NULL; } +#line 1473 "y.tab.c" /* yacc.c:1646 */ + break; + + case 7: +#line 168 "lab9.y" /* yacc.c:1646 */ + {(yyval.astnode) = (yyvsp[0].astnode);} +#line 1479 "y.tab.c" /* yacc.c:1646 */ + break; + + case 8: +#line 171 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_ExternType); + (yyval.astnode)->A_Declared_Type = (yyvsp[0].asttype); + } +#line 1488 "y.tab.c" /* yacc.c:1646 */ + break; + + case 9: +#line 175 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_ExternType); + (yyval.astnode)->A_Declared_Type = (yyvsp[-2].asttype); + (yyval.astnode)->next = (yyvsp[0].astnode); + } +#line 1498 "y.tab.c" /* yacc.c:1646 */ + break; + + case 10: +#line 182 "lab9.y" /* yacc.c:1646 */ + {(yyval.astnode) = NULL;} +#line 1504 "y.tab.c" /* yacc.c:1646 */ + break; + + case 11: +#line 183 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[-1].astnode); + (yyval.astnode)->next = (yyvsp[0].astnode); + } +#line 1513 "y.tab.c" /* yacc.c:1646 */ + break; + + case 12: +#line 189 "lab9.y" /* yacc.c:1646 */ + { + // Before we create the node let's check if the T_ID is used + if (Search((yyvsp[-2].string), level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror((yyvsp[-2].string)); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_VARDEC); + (yyval.astnode)->name = (yyvsp[-2].string); + (yyval.astnode)->A_Declared_Type = (yyvsp[-1].asttype); + (yyval.astnode)->size = 1; // scalars are size 1 + + // insert the variable into the symtable + (yyval.astnode)->symbol = Insert((yyvsp[-2].string),(yyvsp[-1].asttype),ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + } +#line 1534 "y.tab.c" /* yacc.c:1646 */ + break; + + case 13: +#line 205 "lab9.y" /* yacc.c:1646 */ + { + // Before we create the node let's check if the T_ID is used + if (Search((yyvsp[-2].string), level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror((yyvsp[-2].string)); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_VARDEC); + (yyval.astnode)->name = (yyvsp[-2].string); + (yyval.astnode)->S1 = (yyvsp[-1].astnode); // set S1 to the ArrayType + (yyval.astnode)->A_Declared_Type = (yyvsp[-1].astnode)->A_Declared_Type; // duplicate the type in the array + (yyval.astnode)->size = (yyvsp[-1].astnode)->size; // Arrays are based on the ArrayType value + // insert the variable into the symtable + (yyval.astnode)->symbol = Insert((yyvsp[-2].string),(yyvsp[-1].astnode)->A_Declared_Type,ID_Sub_Type_Array, level, (yyval.astnode)->size, offset, NULL); + offset += (yyvsp[-1].astnode)->size; // increment the offset by the size of the array. + } +#line 1555 "y.tab.c" /* yacc.c:1646 */ + break; + + case 14: +#line 221 "lab9.y" /* yacc.c:1646 */ + { + // we do the same thing in here that we did for the one without the T_ASSIGN + + // Before we create the node let's check if the T_ID is used + if (Search((yyvsp[-4].string), level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror((yyvsp[-4].string)); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_VARDEC); + (yyval.astnode)->name = (yyvsp[-4].string); + (yyval.astnode)->A_Declared_Type = (yyvsp[-3].asttype); // set type to the Type output node + (yyval.astnode)->size = 1; // this is still a scalar so we set size to 1. + (yyval.astnode)->symbol = Insert((yyvsp[-4].string),(yyvsp[-3].asttype),ID_Sub_Type_Scalar, level,(yyval.astnode)->size, offset, NULL); + offset++; // increment offset by 1 because it's a scalar. + (yyval.astnode)->S2 = (yyvsp[-1].astnode); // set S2 to the Constant node + + } +#line 1578 "y.tab.c" /* yacc.c:1646 */ + break; + + case 15: +#line 241 "lab9.y" /* yacc.c:1646 */ + {(yyval.astnode) = NULL;} +#line 1584 "y.tab.c" /* yacc.c:1646 */ + break; + + case 16: +#line 242 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[-1].astnode); + (yyval.astnode)->next = (yyvsp[0].astnode); // set the next to the right recursive value + } +#line 1593 "y.tab.c" /* yacc.c:1646 */ + break; + + case 17: +#line 250 "lab9.y" /* yacc.c:1646 */ + { + struct SymbTab *s; + + s = Search((yyvsp[0].string), level, 0); + + if (s != NULL){ + fprintf(stderr, "Symbol %s has already been used in a method\n", (yyvsp[0].string)); + yyerror("duplicate method name"); + exit(1); + } else { + s = Insert((yyvsp[0].string),0,ID_Sub_Type_Method, level, 0, 0, NULL); + // update the type after we get it + if (mydebug) Display(); + + // set offset for start of method + goffset = offset; + offset = 2; + maxoffset = offset; + } + + + + + } +#line 1622 "y.tab.c" /* yacc.c:1646 */ + break; + + case 18: +#line 273 "lab9.y" /* yacc.c:1646 */ + { + struct SymbTab *s; + s = Search((yyvsp[-5].string), level, 0); + s->Type = (yyvsp[0].asttype); + s->fparms = (yyvsp[-2].astnode); + + } +#line 1634 "y.tab.c" /* yacc.c:1646 */ + break; + + case 19: +#line 279 "lab9.y" /* yacc.c:1646 */ + { + + // increment anything greater than $2 by 1 for the new component + (yyval.astnode) = ASTCreateNode(A_METHODDEC); + (yyval.astnode)->name = (yyvsp[-7].string); + (yyval.astnode)->A_Declared_Type = (yyvsp[-2].asttype); + // $$->size = 1; changed to offset + (yyval.astnode)->S1 = (yyvsp[-4].astnode); // $5; + (yyval.astnode)->S2 = (yyvsp[0].astnode); // $9; + (yyval.astnode)->symbol = Search((yyvsp[-7].string), level, 0); + (yyval.astnode)->size = maxoffset; + (yyval.astnode)->symbol->mysize = maxoffset; // max size needed to run program + offset = goffset; + } +#line 1653 "y.tab.c" /* yacc.c:1646 */ + break; + + case 20: +#line 295 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = NULL; } +#line 1659 "y.tab.c" /* yacc.c:1646 */ + break; + + case 21: +#line 296 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 1665 "y.tab.c" /* yacc.c:1646 */ + break; + + case 22: +#line 299 "lab9.y" /* yacc.c:1646 */ + { + // Before we create the node let's check if the T_ID is used + if(Search ((yyvsp[-1].string), level + 1, 0)!= NULL) { + yyerror("Duplicate method arg name"); + yyerror((yyvsp[-1].string)); + } + + (yyval.astnode) = ASTCreateNode(A_METHODID); + (yyval.astnode)->name = (yyvsp[-1].string); + (yyval.astnode)->A_Declared_Type = (yyvsp[0].asttype); + (yyval.astnode)->size = 1; + + (yyval.astnode)->symbol=Insert((yyvsp[-1].string),(yyvsp[0].asttype),ID_Sub_Type_Scalar, level+1, 1, offset, NULL); + offset++; // increment offset by 1 as per instructions + } +#line 1685 "y.tab.c" /* yacc.c:1646 */ + break; + + case 23: +#line 314 "lab9.y" /* yacc.c:1646 */ + { + // Before we create the node let's check if the T_ID is used + + // check if there are duplicate args + if(Search ((yyvsp[-3].string), level + 1, 0)!= NULL) { + yyerror("Duplicate method arg name"); + yyerror((yyvsp[-3].string)); + } + (yyval.astnode) = ASTCreateNode(A_METHODID); + (yyval.astnode)->name = (yyvsp[-3].string); + (yyval.astnode)->A_Declared_Type = (yyvsp[-2].asttype); + (yyval.astnode)->size = 1; + + // we do level + 1 because the args are part of the block created by the method. + (yyval.astnode)->symbol=Insert((yyvsp[-3].string),(yyvsp[-2].asttype),ID_Sub_Type_Scalar, level+1, 1, offset, NULL); + offset++; // increment offset by 1 as per instructions + (yyval.astnode)->next = (yyvsp[0].astnode); + } +#line 1708 "y.tab.c" /* yacc.c:1646 */ + break; + + case 24: +#line 335 "lab9.y" /* yacc.c:1646 */ + { level++; } +#line 1714 "y.tab.c" /* yacc.c:1646 */ + break; + + case 25: +#line 335 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_BLOCK); + + // incremented these because added in-rule action + (yyval.astnode)->S1 = (yyvsp[-2].astnode); // set S1 to the VarDecls + (yyval.astnode)->S2 = (yyvsp[-1].astnode); // set S2 to the Statements + if(mydebug) Display(); // Display here so we can see the symtab at each level + + // if the offset is greater than the maxoffset of the method + // then we set the maxoffset to the offset to fix it's max value + if (offset > maxoffset) { + maxoffset = offset; + } + + // We delete all the symbols at the current level before leaving. + // this way they don't conflict with levels lower. + offset -= Delete(level); + + // decrement level since we finished the block + level--; + + } +#line 1741 "y.tab.c" /* yacc.c:1646 */ + break; + + case 26: +#line 359 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = NULL; } +#line 1747 "y.tab.c" /* yacc.c:1646 */ + break; + + case 27: +#line 360 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[-1].astnode); + (yyval.astnode)->next = (yyvsp[0].astnode); + } +#line 1756 "y.tab.c" /* yacc.c:1646 */ + break; + + case 28: +#line 366 "lab9.y" /* yacc.c:1646 */ + { + // Before we create the node let's check if the T_ID is used + if (Search((yyvsp[-2].string), level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror((yyvsp[-2].string)); + exit(1); + } + + // Create an A_VARDEC node + (yyval.astnode) = ASTCreateNode(A_VARDEC); + (yyval.astnode)->name = (yyvsp[-2].string); // set it's name to T_ID + (yyval.astnode)->A_Declared_Type = (yyvsp[-1].asttype); // set it's type to outpit of Type + + // insert the variable into the symtable + (yyval.astnode)->symbol = Insert((yyvsp[-2].string),(yyvsp[-1].asttype),ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + // Display(); // debugging only + } +#line 1779 "y.tab.c" /* yacc.c:1646 */ + break; + + case 29: +#line 384 "lab9.y" /* yacc.c:1646 */ + { + // Before we create the node let's check if the T_ID is used + if (Search((yyvsp[-2].string), level, 0) != NULL) { + yyerror("Variable already defined"); + yyerror((yyvsp[-2].string)); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_VARDEC); + (yyval.astnode)->name = (yyvsp[-2].string); + (yyval.astnode)->S1 = (yyvsp[-1].astnode); // set S1 to the ArrayType node + (yyval.astnode)->A_Declared_Type = (yyvsp[-1].astnode)->A_Declared_Type; + (yyval.astnode)->size = (yyvsp[-1].astnode)->size; // set the size to the size of the ArrayType node + + // insert the variable into the symtable + (yyval.astnode)->symbol = Insert((yyvsp[-2].string),(yyvsp[-1].astnode)->A_Declared_Type, ID_Sub_Type_Array, level, (yyval.astnode)->size, offset, NULL); + offset += (yyvsp[-1].astnode)->size; // increment offset by the size of the array. + } +#line 1801 "y.tab.c" /* yacc.c:1646 */ + break; + + case 30: +#line 403 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = NULL; } +#line 1807 "y.tab.c" /* yacc.c:1646 */ + break; + + case 31: +#line 404 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[-1].astnode); + (yyval.astnode)->next = (yyvsp[0].astnode); + } +#line 1816 "y.tab.c" /* yacc.c:1646 */ + break; + + case 32: +#line 414 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 1822 "y.tab.c" /* yacc.c:1646 */ + break; + + case 33: +#line 415 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[-1].astnode); } +#line 1828 "y.tab.c" /* yacc.c:1646 */ + break; + + case 34: +#line 416 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[-1].astnode); } +#line 1834 "y.tab.c" /* yacc.c:1646 */ + break; + + case 35: +#line 417 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 1840 "y.tab.c" /* yacc.c:1646 */ + break; + + case 36: +#line 418 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 1846 "y.tab.c" /* yacc.c:1646 */ + break; + + case 37: +#line 419 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 1852 "y.tab.c" /* yacc.c:1646 */ + break; + + case 38: +#line 420 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 1858 "y.tab.c" /* yacc.c:1646 */ + break; + + case 39: +#line 421 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 1864 "y.tab.c" /* yacc.c:1646 */ + break; + + case 40: +#line 425 "lab9.y" /* yacc.c:1646 */ + {(yyval.astnode) = ASTCreateNode(A_CONTINUE);} +#line 1870 "y.tab.c" /* yacc.c:1646 */ + break; + + case 41: +#line 428 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_WHILESTMT); + (yyval.astnode)->S1 = (yyvsp[-2].astnode); // set S1 to thje Expr + (yyval.astnode)->S2 = (yyvsp[0].astnode); // Set S2 to the Block + } +#line 1880 "y.tab.c" /* yacc.c:1646 */ + break; + + case 42: +#line 434 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = ASTCreateNode(A_BREAK); } +#line 1886 "y.tab.c" /* yacc.c:1646 */ + break; + + case 43: +#line 437 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_IF); + (yyval.astnode)->S1 = (yyvsp[-4].astnode); // set S1 to the Expression node + (yyval.astnode)->S2 = ASTCreateNode(A_IFBODY); // create a separate node for the body in S2 + (yyval.astnode)->S2->S1 = (yyvsp[-2].astnode); // set the S1 of the body to the block of the IF + (yyval.astnode)->S2->S2 = (yyvsp[0].astnode); // create a new node for the else statement after the body + + /*I modified my original implementation to + not have an A_ELSE node. Instead we just store the blocks + directly in the S1 and S2 of the A_IFBODY respectively. + This makes the logic on the emit.c side much simpler*/ + + } +#line 1904 "y.tab.c" /* yacc.c:1646 */ + break; + + case 44: +#line 450 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_IF); + + // Set S1 to the Expression node + (yyval.astnode)->S1 = (yyvsp[-2].astnode); + (yyval.astnode)->S2 = ASTCreateNode(A_IFBODY); // create a separate node for the body in S2 + (yyval.astnode)->S2->S1 = (yyvsp[0].astnode); // set the S1 of the body to the block + (yyval.astnode)->S2->S2 = NULL; // since we have no Else we set it's node to NULL this time + } +#line 1918 "y.tab.c" /* yacc.c:1646 */ + break; + + case 45: +#line 461 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = ASTCreateNode(A_RETURN);} +#line 1924 "y.tab.c" /* yacc.c:1646 */ + break; + + case 46: +#line 462 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = ASTCreateNode(A_RETURN);} +#line 1930 "y.tab.c" /* yacc.c:1646 */ + break; + + case 47: +#line 463 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_RETURN); + (yyval.astnode)->S1 = (yyvsp[-2].astnode); // set the S1 to the expression we returned + } +#line 1939 "y.tab.c" /* yacc.c:1646 */ + break; + + case 48: +#line 469 "lab9.y" /* yacc.c:1646 */ + { + + // make sure the left and right hand types are matching + if ( (yyvsp[-2].astnode)->A_Declared_Type != (yyvsp[0].astnode)->A_Declared_Type) { + yyerror("Type mismatch on assignment"); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_ASSIGN); + (yyval.astnode)->S1 = (yyvsp[-2].astnode); // set the S1 to the left hand side + (yyval.astnode)->S2 = (yyvsp[0].astnode); // set the S2 to the right hand side + (yyval.astnode)->name = TEMP_CREATE(); + // create a temporary symbol to hold value + (yyval.astnode)->symbol = Insert((yyval.astnode)->name, (yyval.astnode)->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // Determine if we need to increment offset + // Yes we do because the assignments need temporary values + // in the function's space + offset++; + } +#line 1963 "y.tab.c" /* yacc.c:1646 */ + break; + + case 49: +#line 498 "lab9.y" /* yacc.c:1646 */ + { + /* I am using A_VAR_RVALUE for both the LVALUE and RVALUE + Mostly because the node serves the same purpose. + */ + + /* well apparently that was wrong so I changed to a new + node type LVALUE which now has it's own case and enum + */ + + // grab the symbol from the table corresponding the T_ID + struct SymbTab *p; + p = Search((yyvsp[0].string), level, 1); + + // if we didn't find one lets barf because it wasnt defined + if(p == NULL) { + yyerror("Symbol on LVALUE not defined"); + yyerror((yyvsp[0].string)); + exit(1); + } + + // Make sure the type is a scalar and not an array/method + if (p->SubType != ID_Sub_Type_Scalar){ + yyerror((yyvsp[0].string)); + yyerror("needs to be a scalar, wrong subtype"); + exit(1); + } + + (yyval.astnode) = ASTCreateNode(A_VAR_LVALUE); + (yyval.astnode)->name = (yyvsp[0].string); + (yyval.astnode)->symbol = p; + (yyval.astnode)->A_Declared_Type = p->Type; + } +#line 2000 "y.tab.c" /* yacc.c:1646 */ + break; + + case 50: +#line 530 "lab9.y" /* yacc.c:1646 */ + { + struct SymbTab *p; + p = Search((yyvsp[-3].string), level, 1); + + // if we didn't find one lets barf because it wasnt defined + if(p == NULL) { + yyerror("Symbol on LVALUE not defined"); + yyerror((yyvsp[-3].string)); + exit(1); + } + + // Make sure it's an array and not a Scalar/Method + if (p->SubType != ID_Sub_Type_Array){ + yyerror((yyvsp[-3].string)); + yyerror("needs to be an array, wrong subtype"); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_VAR_LVALUE); + (yyval.astnode)->name = (yyvsp[-3].string); + (yyval.astnode)->S1 = (yyvsp[-1].astnode); + (yyval.astnode)->symbol = p; + (yyval.astnode)->A_Declared_Type = p->Type; // the type is the same as the symbol we got it from + } +#line 2028 "y.tab.c" /* yacc.c:1646 */ + break; + + case 51: +#line 556 "lab9.y" /* yacc.c:1646 */ + { + struct SymbTab *p; + p = Search((yyvsp[-3].string), level, 1); + + // if we didn't find one lets barf because it wasnt defined + if(p == NULL) { + yyerror("Method symbol not defined"); + yyerror((yyvsp[-3].string)); + exit(1); + } + + // Make sure it's a Method or Extern Method and not an Array/Scalar + if ((p->SubType != ID_Sub_Type_Method) && (p->SubType != ID_Sub_Type_Extern_Method)){ + yyerror((yyvsp[-3].string)); + yyerror("needs to be a method, wrong subtype"); + exit(1); + } + + // check that the formal params match the params of the method + // definition + + if (check_parameters(p->fparms, (yyvsp[-1].astnode)) == 0) { + yyerror("Formal and actual params do not match"); + yyerror((yyvsp[-3].string)); + exit(1); + } + + (yyval.astnode) = ASTCreateNode(A_METHODCALL); + (yyval.astnode)->name = (yyvsp[-3].string); + (yyval.astnode)->S1 = (yyvsp[-1].astnode); + (yyval.astnode)->symbol = p; + (yyval.astnode)->A_Declared_Type = p->Type; // type matches it's formal type + } +#line 2066 "y.tab.c" /* yacc.c:1646 */ + break; + + case 52: +#line 590 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[0].astnode); + // create a temporary symbol to hold value + (yyval.astnode)->symbol = Insert(TEMP_CREATE(),(yyval.astnode)->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // increment offset by 1 because of the temporary value being stored + offset++; + } +#line 2079 "y.tab.c" /* yacc.c:1646 */ + break; + + case 53: +#line 600 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = NULL; + } +#line 2087 "y.tab.c" /* yacc.c:1646 */ + break; + + case 54: +#line 603 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[0].astnode); + } +#line 2095 "y.tab.c" /* yacc.c:1646 */ + break; + + case 55: +#line 608 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[0].astnode); + } +#line 2103 "y.tab.c" /* yacc.c:1646 */ + break; + + case 56: +#line 611 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[-2].astnode); + (yyval.astnode)->next = (yyvsp[0].astnode); + } +#line 2112 "y.tab.c" /* yacc.c:1646 */ + break; + + case 57: +#line 627 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 2118 "y.tab.c" /* yacc.c:1646 */ + break; + + case 58: +#line 630 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 2124 "y.tab.c" /* yacc.c:1646 */ + break; + + case 59: +#line 631 "lab9.y" /* yacc.c:1646 */ + { + + // make type of left is type of right + if (((yyvsp[-2].astnode)->A_Declared_Type != (yyvsp[0].astnode)->A_Declared_Type)) { + yyerror("both sides need to be the same type"); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_EXPR); + (yyval.astnode)->S1 = (yyvsp[-2].astnode); // set S1 to left hand side + (yyval.astnode)->operator = (yyvsp[-1].operator); // set the operator to return of Relop + (yyval.astnode)->S2 = (yyvsp[0].astnode); // set S2 to the right hand side + (yyval.astnode)->A_Declared_Type = (yyvsp[-2].astnode)->A_Declared_Type; // duplicate the type from one of the left or right (left) + (yyval.astnode)->name = TEMP_CREATE(); // create a temporary symbol to hold value + (yyval.astnode)->symbol = Insert((yyval.astnode)->name,(yyval.astnode)->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // increment offset by 1 because of the temporary value being stored + offset++; + + } +#line 2148 "y.tab.c" /* yacc.c:1646 */ + break; + + case 60: +#line 652 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_LT; } +#line 2154 "y.tab.c" /* yacc.c:1646 */ + break; + + case 61: +#line 653 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_GT; } +#line 2160 "y.tab.c" /* yacc.c:1646 */ + break; + + case 62: +#line 654 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_EQ; } +#line 2166 "y.tab.c" /* yacc.c:1646 */ + break; + + case 63: +#line 655 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_LEQ; } +#line 2172 "y.tab.c" /* yacc.c:1646 */ + break; + + case 64: +#line 656 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_GEQ; } +#line 2178 "y.tab.c" /* yacc.c:1646 */ + break; + + case 65: +#line 657 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_NEQ; } +#line 2184 "y.tab.c" /* yacc.c:1646 */ + break; + + case 66: +#line 660 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 2190 "y.tab.c" /* yacc.c:1646 */ + break; + + case 67: +#line 661 "lab9.y" /* yacc.c:1646 */ + { + if (((yyvsp[-2].astnode)->A_Declared_Type != (yyvsp[0].astnode)->A_Declared_Type) || + (check_operators((yyvsp[-1].operator), (yyvsp[-2].astnode)->A_Declared_Type) == 0)) { + yyerror("addition and subtraction need INTs only"); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_EXPR); + (yyval.astnode)->S1 = (yyvsp[-2].astnode); + (yyval.astnode)->operator = (yyvsp[-1].operator); + (yyval.astnode)->S2 = (yyvsp[0].astnode); + (yyval.astnode)->A_Declared_Type = A_Decaf_INT; + (yyval.astnode)->name = TEMP_CREATE(); + (yyval.astnode)->symbol = Insert((yyval.astnode)->name,(yyval.astnode)->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + } +#line 2210 "y.tab.c" /* yacc.c:1646 */ + break; + + case 68: +#line 678 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_PLUS; } +#line 2216 "y.tab.c" /* yacc.c:1646 */ + break; + + case 69: +#line 679 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_MINUS; } +#line 2222 "y.tab.c" /* yacc.c:1646 */ + break; + + case 70: +#line 682 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 2228 "y.tab.c" /* yacc.c:1646 */ + break; + + case 71: +#line 683 "lab9.y" /* yacc.c:1646 */ + { + // check that left is equal to right + if ((yyvsp[-2].astnode)->A_Declared_Type != (yyvsp[0].astnode)->A_Declared_Type) { + yyerror("type mismatch"); + exit(1); + } + + // use my check_operators() function to make sure the operator + // is compatible with the types + if (check_operators((yyvsp[-1].operator), (yyvsp[-2].astnode)->A_Declared_Type) == 0) { + if((yyvsp[-2].astnode)->A_Declared_Type == A_Decaf_BOOL) { + yyerror("Cannot use BOOL in INT operation"); + } else { + yyerror("Cannot use INT in BOOL operation"); + } + exit(1); + } + + (yyval.astnode) = ASTCreateNode(A_EXPR); + (yyval.astnode)->S1 = (yyvsp[-2].astnode); + (yyval.astnode)->operator = (yyvsp[-1].operator); + (yyval.astnode)->S2 = (yyvsp[0].astnode); + (yyval.astnode)->name = TEMP_CREATE(); + (yyval.astnode)->symbol = Insert((yyval.astnode)->name,(yyval.astnode)->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + } +#line 2259 "y.tab.c" /* yacc.c:1646 */ + break; + + case 72: +#line 711 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_TIMES; } +#line 2265 "y.tab.c" /* yacc.c:1646 */ + break; + + case 73: +#line 712 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_DIVIDE; } +#line 2271 "y.tab.c" /* yacc.c:1646 */ + break; + + case 74: +#line 713 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_MOD; } +#line 2277 "y.tab.c" /* yacc.c:1646 */ + break; + + case 75: +#line 714 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_AND; } +#line 2283 "y.tab.c" /* yacc.c:1646 */ + break; + + case 76: +#line 715 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_OR; } +#line 2289 "y.tab.c" /* yacc.c:1646 */ + break; + + case 77: +#line 716 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_LEFTSHIFT; } +#line 2295 "y.tab.c" /* yacc.c:1646 */ + break; + + case 78: +#line 717 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_RIGHTSHIFT; } +#line 2301 "y.tab.c" /* yacc.c:1646 */ + break; + + case 79: +#line 720 "lab9.y" /* yacc.c:1646 */ + { + struct SymbTab *p; + p = Search((yyvsp[0].string), level, 1); + + if(p == NULL) { + yyerror("Symbol on RVALUE not defined"); + yyerror((yyvsp[0].string)); + exit(1); + } + + if (p->SubType != ID_Sub_Type_Scalar){ + yyerror((yyvsp[0].string)); + yyerror("needs to be an scalar, wrong subtype"); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_VAR_RVALUE); + (yyval.astnode)->name = (yyvsp[0].string); + (yyval.astnode)->symbol = p; + (yyval.astnode)->A_Declared_Type = p->Type; + + } +#line 2327 "y.tab.c" /* yacc.c:1646 */ + break; + + case 80: +#line 741 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 2333 "y.tab.c" /* yacc.c:1646 */ + break; + + case 81: +#line 742 "lab9.y" /* yacc.c:1646 */ + { + struct SymbTab *p; + p = Search((yyvsp[-3].string), level, 1); + if(p == NULL) { + yyerror("Symbol on RVALUE not defined"); + yyerror((yyvsp[-3].string)); + exit(1); + } + + if (p->SubType != ID_Sub_Type_Array){ + yyerror((yyvsp[-3].string)); + yyerror("needs to be an array, wrong subtype"); + exit(1); + } + + (yyval.astnode) = ASTCreateNode(A_VAR_RVALUE); + (yyval.astnode)->name = (yyvsp[-3].string); + (yyval.astnode)->S1 = (yyvsp[-1].astnode); + (yyval.astnode)->symbol = p; + (yyval.astnode)->A_Declared_Type = p->Type; + } +#line 2359 "y.tab.c" /* yacc.c:1646 */ + break; + + case 82: +#line 763 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 2365 "y.tab.c" /* yacc.c:1646 */ + break; + + case 83: +#line 764 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[-1].astnode); } +#line 2371 "y.tab.c" /* yacc.c:1646 */ + break; + + case 84: +#line 765 "lab9.y" /* yacc.c:1646 */ + { + + // check if our right is a bool + if ((yyvsp[0].astnode)->A_Declared_Type != A_Decaf_BOOL) { + yyerror("Type mismatch, expected boolean"); + exit(1); + } + + (yyval.astnode) = ASTCreateNode(A_EXPR); + (yyval.astnode)->operator = A_NOT; + (yyval.astnode)->S1 = (yyvsp[0].astnode); + + // set type to boolean because !bool is a bool + (yyval.astnode)->A_Declared_Type = A_Decaf_BOOL; + + (yyval.astnode)->name = TEMP_CREATE(); + (yyval.astnode)->symbol = Insert((yyval.astnode)->name,A_Decaf_BOOL, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + } +#line 2395 "y.tab.c" /* yacc.c:1646 */ + break; + + case 85: +#line 786 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_CONSTANT_STRING); + (yyval.astnode)->name = (yyvsp[0].string); + (yyval.astnode)->A_Declared_Type = A_Decaf_STRING; + } +#line 2405 "y.tab.c" /* yacc.c:1646 */ + break; + + case 86: +#line 791 "lab9.y" /* yacc.c:1646 */ + { + // check if our right is an int + if ((yyvsp[0].astnode)->A_Declared_Type != A_Decaf_INT) { + yyerror("Type mismatch, expected integer"); + exit(1); + } + (yyval.astnode) = ASTCreateNode(A_EXPR); + (yyval.astnode)->operator = A_UMINUS; + (yyval.astnode)->S1 = (yyvsp[0].astnode); + // set type to boolean because UMINUS is for numbers + (yyval.astnode)->A_Declared_Type = A_Decaf_INT; + (yyval.astnode)->name = TEMP_CREATE(); + (yyval.astnode)->symbol = Insert((yyval.astnode)->name,A_Decaf_BOOL, ID_Sub_Type_Scalar, level, 1, offset, NULL); + offset++; + } +#line 2425 "y.tab.c" /* yacc.c:1646 */ + break; + + case 87: +#line 811 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = A_Decaf_STRING; } +#line 2431 "y.tab.c" /* yacc.c:1646 */ + break; + + case 89: +#line 816 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = A_Decaf_INT; } +#line 2437 "y.tab.c" /* yacc.c:1646 */ + break; + + case 90: +#line 817 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = A_Decaf_BOOL; } +#line 2443 "y.tab.c" /* yacc.c:1646 */ + break; + + case 91: +#line 820 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = A_Decaf_VOID; } +#line 2449 "y.tab.c" /* yacc.c:1646 */ + break; + + case 92: +#line 821 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = (yyvsp[0].asttype); } +#line 2455 "y.tab.c" /* yacc.c:1646 */ + break; + + case 93: +#line 824 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_CONSTANT_BOOL); + (yyval.astnode)->value = 1; + (yyval.astnode)->A_Declared_Type = A_Decaf_BOOL; + } +#line 2465 "y.tab.c" /* yacc.c:1646 */ + break; + + case 94: +#line 829 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_CONSTANT_BOOL); + (yyval.astnode)->value = 0; + (yyval.astnode)->A_Declared_Type = A_Decaf_BOOL; + } +#line 2475 "y.tab.c" /* yacc.c:1646 */ + break; + + case 95: +#line 836 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_ARRAYTYPE); + (yyval.astnode)->value = (yyvsp[-2].value); + (yyval.astnode)->A_Declared_Type = (yyvsp[0].asttype); + (yyval.astnode)->size = (yyvsp[-2].value); + // printf("THE SIZE IS %d %d", $2, $$->size);// debug + } +#line 2487 "y.tab.c" /* yacc.c:1646 */ + break; + + case 96: +#line 845 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = ASTCreateNode(A_CONSTANT_INT); + (yyval.astnode)->value = (yyvsp[0].value); + (yyval.astnode)->A_Declared_Type = A_Decaf_INT; + } +#line 2497 "y.tab.c" /* yacc.c:1646 */ + break; + + case 97: +#line 851 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[0].astnode); + } +#line 2505 "y.tab.c" /* yacc.c:1646 */ + break; + + +#line 2509 "y.tab.c" /* yacc.c:1646 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 854 "lab9.y" /* yacc.c:1906 */ + /* end of rules, start of program */ + +int main(int argc, char ** argv){ + + for (int i = 1; i. */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +#ifndef YY_YY_Y_TAB_H_INCLUDED +# define YY_YY_Y_TAB_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 1 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + T_AND = 258, + T_ASSIGN = 259, + T_BOOLTYPE = 260, + T_BREAK = 261, + T_CONTINUE = 262, + T_ELSE = 263, + T_EQ = 264, + T_EXTERN = 265, + T_FALSE = 266, + T_FUNC = 267, + T_GEQ = 268, + T_ID = 269, + T_IF = 270, + T_INTCONSTANT = 271, + T_INTTYPE = 272, + T_LEFTSHIFT = 273, + T_LEQ = 274, + T_NEQ = 275, + T_OR = 276, + T_PACKAGE = 277, + T_RETURN = 278, + T_RIGHTSHIFT = 279, + T_STRINGCONSTANT = 280, + T_STRINGTYPE = 281, + T_TRUE = 282, + T_VAR = 283, + T_VOID = 284, + T_WHILE = 285 + }; +#endif +/* Tokens. */ +#define T_AND 258 +#define T_ASSIGN 259 +#define T_BOOLTYPE 260 +#define T_BREAK 261 +#define T_CONTINUE 262 +#define T_ELSE 263 +#define T_EQ 264 +#define T_EXTERN 265 +#define T_FALSE 266 +#define T_FUNC 267 +#define T_GEQ 268 +#define T_ID 269 +#define T_IF 270 +#define T_INTCONSTANT 271 +#define T_INTTYPE 272 +#define T_LEFTSHIFT 273 +#define T_LEQ 274 +#define T_NEQ 275 +#define T_OR 276 +#define T_PACKAGE 277 +#define T_RETURN 278 +#define T_RIGHTSHIFT 279 +#define T_STRINGCONSTANT 280 +#define T_STRINGTYPE 281 +#define T_TRUE 282 +#define T_VAR 283 +#define T_VOID 284 +#define T_WHILE 285 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + +union YYSTYPE +{ +#line 56 "lab9.y" /* yacc.c:1909 */ + + int value; + char* string; + struct ASTnodetype *astnode; + enum AST_Decaf_Types asttype; + enum AST_Operators operator; + +#line 122 "y.tab.h" /* yacc.c:1909 */ +}; + +typedef union YYSTYPE YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); + +#endif /* !YY_YY_Y_TAB_H_INCLUDED */ diff --git a/9LAB/y.tab.c b/9LAB/y.tab.c index 036767a..05a9cc5 100644 --- a/9LAB/y.tab.c +++ b/9LAB/y.tab.c @@ -523,12 +523,12 @@ static const yytype_uint16 yyrline[] = 182, 183, 189, 205, 221, 241, 242, 250, 273, 250, 295, 296, 299, 314, 335, 335, 359, 360, 366, 384, 403, 404, 414, 415, 416, 417, 418, 419, 420, 421, - 425, 428, 434, 437, 447, 458, 459, 460, 466, 484, - 516, 542, 576, 579, 582, 587, 590, 606, 609, 610, - 631, 632, 633, 634, 635, 636, 639, 640, 657, 658, - 661, 662, 690, 691, 692, 693, 694, 695, 696, 699, - 720, 721, 742, 743, 744, 765, 770, 790, 791, 795, - 796, 799, 800, 803, 808, 815, 824, 830 + 425, 428, 434, 437, 450, 461, 462, 463, 469, 498, + 530, 556, 590, 600, 603, 608, 611, 627, 630, 631, + 652, 653, 654, 655, 656, 657, 660, 661, 678, 679, + 682, 683, 711, 712, 713, 714, 715, 716, 717, 720, + 741, 742, 763, 764, 765, 786, 791, 811, 812, 816, + 817, 820, 821, 824, 829, 836, 845, 851 }; #endif @@ -1892,16 +1892,19 @@ yyreduce: (yyval.astnode)->S1 = (yyvsp[-4].astnode); // set S1 to the Expression node (yyval.astnode)->S2 = ASTCreateNode(A_IFBODY); // create a separate node for the body in S2 (yyval.astnode)->S2->S1 = (yyvsp[-2].astnode); // set the S1 of the body to the block of the IF - (yyval.astnode)->S2->S2 = ASTCreateNode(A_ELSE); // create a new node for the else statement after the body + (yyval.astnode)->S2->S2 = (yyvsp[0].astnode); // create a new node for the else statement after the body + + /*I modified my original implementation to + not have an A_ELSE node. Instead we just store the blocks + directly in the S1 and S2 of the A_IFBODY respectively. + This makes the logic on the emit.c side much simpler*/ - // set the S1 of the Else to the Else's Block - (yyval.astnode)->S2->S2->S1 = (yyvsp[0].astnode); } -#line 1901 "y.tab.c" /* yacc.c:1646 */ +#line 1904 "y.tab.c" /* yacc.c:1646 */ break; case 44: -#line 447 "lab9.y" /* yacc.c:1646 */ +#line 450 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = ASTCreateNode(A_IF); @@ -1911,32 +1914,32 @@ yyreduce: (yyval.astnode)->S2->S1 = (yyvsp[0].astnode); // set the S1 of the body to the block (yyval.astnode)->S2->S2 = NULL; // since we have no Else we set it's node to NULL this time } -#line 1915 "y.tab.c" /* yacc.c:1646 */ +#line 1918 "y.tab.c" /* yacc.c:1646 */ break; case 45: -#line 458 "lab9.y" /* yacc.c:1646 */ +#line 461 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = ASTCreateNode(A_RETURN);} -#line 1921 "y.tab.c" /* yacc.c:1646 */ +#line 1924 "y.tab.c" /* yacc.c:1646 */ break; case 46: -#line 459 "lab9.y" /* yacc.c:1646 */ +#line 462 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = ASTCreateNode(A_RETURN);} -#line 1927 "y.tab.c" /* yacc.c:1646 */ +#line 1930 "y.tab.c" /* yacc.c:1646 */ break; case 47: -#line 460 "lab9.y" /* yacc.c:1646 */ +#line 463 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = ASTCreateNode(A_RETURN); (yyval.astnode)->S1 = (yyvsp[-2].astnode); // set the S1 to the expression we returned } -#line 1936 "y.tab.c" /* yacc.c:1646 */ +#line 1939 "y.tab.c" /* yacc.c:1646 */ break; case 48: -#line 466 "lab9.y" /* yacc.c:1646 */ +#line 469 "lab9.y" /* yacc.c:1646 */ { // make sure the left and right hand types are matching @@ -1947,12 +1950,20 @@ yyreduce: (yyval.astnode) = ASTCreateNode(A_ASSIGN); (yyval.astnode)->S1 = (yyvsp[-2].astnode); // set the S1 to the left hand side (yyval.astnode)->S2 = (yyvsp[0].astnode); // set the S2 to the right hand side + (yyval.astnode)->name = TEMP_CREATE(); + // create a temporary symbol to hold value + (yyval.astnode)->symbol = Insert((yyval.astnode)->name, (yyval.astnode)->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // Determine if we need to increment offset + // Yes we do because the assignments need temporary values + // in the function's space + offset++; } -#line 1952 "y.tab.c" /* yacc.c:1646 */ +#line 1963 "y.tab.c" /* yacc.c:1646 */ break; case 49: -#line 484 "lab9.y" /* yacc.c:1646 */ +#line 498 "lab9.y" /* yacc.c:1646 */ { /* I am using A_VAR_RVALUE for both the LVALUE and RVALUE Mostly because the node serves the same purpose. @@ -1985,11 +1996,11 @@ yyreduce: (yyval.astnode)->symbol = p; (yyval.astnode)->A_Declared_Type = p->Type; } -#line 1989 "y.tab.c" /* yacc.c:1646 */ +#line 2000 "y.tab.c" /* yacc.c:1646 */ break; case 50: -#line 516 "lab9.y" /* yacc.c:1646 */ +#line 530 "lab9.y" /* yacc.c:1646 */ { struct SymbTab *p; p = Search((yyvsp[-3].string), level, 1); @@ -2013,18 +2024,18 @@ yyreduce: (yyval.astnode)->symbol = p; (yyval.astnode)->A_Declared_Type = p->Type; // the type is the same as the symbol we got it from } -#line 2017 "y.tab.c" /* yacc.c:1646 */ +#line 2028 "y.tab.c" /* yacc.c:1646 */ break; case 51: -#line 542 "lab9.y" /* yacc.c:1646 */ +#line 556 "lab9.y" /* yacc.c:1646 */ { struct SymbTab *p; p = Search((yyvsp[-3].string), level, 1); // if we didn't find one lets barf because it wasnt defined if(p == NULL) { - yyerror("Symbol on LVALUE not defined"); + yyerror("Method symbol not defined"); yyerror((yyvsp[-3].string)); exit(1); } @@ -2051,62 +2062,69 @@ yyreduce: (yyval.astnode)->symbol = p; (yyval.astnode)->A_Declared_Type = p->Type; // type matches it's formal type } -#line 2055 "y.tab.c" /* yacc.c:1646 */ +#line 2066 "y.tab.c" /* yacc.c:1646 */ break; case 52: -#line 576 "lab9.y" /* yacc.c:1646 */ - { (yyval.astnode) = (yyvsp[0].astnode); } -#line 2061 "y.tab.c" /* yacc.c:1646 */ +#line 590 "lab9.y" /* yacc.c:1646 */ + { + (yyval.astnode) = (yyvsp[0].astnode); + // create a temporary symbol to hold value + (yyval.astnode)->symbol = Insert(TEMP_CREATE(),(yyval.astnode)->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); + + // increment offset by 1 because of the temporary value being stored + offset++; + } +#line 2079 "y.tab.c" /* yacc.c:1646 */ break; case 53: -#line 579 "lab9.y" /* yacc.c:1646 */ +#line 600 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = NULL; } -#line 2069 "y.tab.c" /* yacc.c:1646 */ +#line 2087 "y.tab.c" /* yacc.c:1646 */ break; case 54: -#line 582 "lab9.y" /* yacc.c:1646 */ +#line 603 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = (yyvsp[0].astnode); } -#line 2077 "y.tab.c" /* yacc.c:1646 */ +#line 2095 "y.tab.c" /* yacc.c:1646 */ break; case 55: -#line 587 "lab9.y" /* yacc.c:1646 */ +#line 608 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = (yyvsp[0].astnode); } -#line 2085 "y.tab.c" /* yacc.c:1646 */ +#line 2103 "y.tab.c" /* yacc.c:1646 */ break; case 56: -#line 590 "lab9.y" /* yacc.c:1646 */ +#line 611 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = (yyvsp[-2].astnode); (yyval.astnode)->next = (yyvsp[0].astnode); } -#line 2094 "y.tab.c" /* yacc.c:1646 */ +#line 2112 "y.tab.c" /* yacc.c:1646 */ break; case 57: -#line 606 "lab9.y" /* yacc.c:1646 */ +#line 627 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = (yyvsp[0].astnode); } -#line 2100 "y.tab.c" /* yacc.c:1646 */ +#line 2118 "y.tab.c" /* yacc.c:1646 */ break; case 58: -#line 609 "lab9.y" /* yacc.c:1646 */ +#line 630 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = (yyvsp[0].astnode); } -#line 2106 "y.tab.c" /* yacc.c:1646 */ +#line 2124 "y.tab.c" /* yacc.c:1646 */ break; case 59: -#line 610 "lab9.y" /* yacc.c:1646 */ +#line 631 "lab9.y" /* yacc.c:1646 */ { // make type of left is type of right @@ -2126,53 +2144,53 @@ yyreduce: offset++; } -#line 2130 "y.tab.c" /* yacc.c:1646 */ - break; - - case 60: -#line 631 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_LT; } -#line 2136 "y.tab.c" /* yacc.c:1646 */ - break; - - case 61: -#line 632 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_GT; } -#line 2142 "y.tab.c" /* yacc.c:1646 */ - break; - - case 62: -#line 633 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_EQ; } #line 2148 "y.tab.c" /* yacc.c:1646 */ break; - case 63: -#line 634 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_LEQ; } + case 60: +#line 652 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_LT; } #line 2154 "y.tab.c" /* yacc.c:1646 */ break; - case 64: -#line 635 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_GEQ; } + case 61: +#line 653 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_GT; } #line 2160 "y.tab.c" /* yacc.c:1646 */ break; - case 65: -#line 636 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_NEQ; } + case 62: +#line 654 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_EQ; } #line 2166 "y.tab.c" /* yacc.c:1646 */ break; - case 66: -#line 639 "lab9.y" /* yacc.c:1646 */ - { (yyval.astnode) = (yyvsp[0].astnode); } + case 63: +#line 655 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_LEQ; } #line 2172 "y.tab.c" /* yacc.c:1646 */ break; + case 64: +#line 656 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_GEQ; } +#line 2178 "y.tab.c" /* yacc.c:1646 */ + break; + + case 65: +#line 657 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_NEQ; } +#line 2184 "y.tab.c" /* yacc.c:1646 */ + break; + + case 66: +#line 660 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 2190 "y.tab.c" /* yacc.c:1646 */ + break; + case 67: -#line 640 "lab9.y" /* yacc.c:1646 */ +#line 661 "lab9.y" /* yacc.c:1646 */ { if (((yyvsp[-2].astnode)->A_Declared_Type != (yyvsp[0].astnode)->A_Declared_Type) || (check_operators((yyvsp[-1].operator), (yyvsp[-2].astnode)->A_Declared_Type) == 0)) { @@ -2188,29 +2206,29 @@ yyreduce: (yyval.astnode)->symbol = Insert((yyval.astnode)->name,(yyval.astnode)->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); offset++; } -#line 2192 "y.tab.c" /* yacc.c:1646 */ - break; - - case 68: -#line 657 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_PLUS; } -#line 2198 "y.tab.c" /* yacc.c:1646 */ - break; - - case 69: -#line 658 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_MINUS; } -#line 2204 "y.tab.c" /* yacc.c:1646 */ - break; - - case 70: -#line 661 "lab9.y" /* yacc.c:1646 */ - { (yyval.astnode) = (yyvsp[0].astnode); } #line 2210 "y.tab.c" /* yacc.c:1646 */ break; + case 68: +#line 678 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_PLUS; } +#line 2216 "y.tab.c" /* yacc.c:1646 */ + break; + + case 69: +#line 679 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_MINUS; } +#line 2222 "y.tab.c" /* yacc.c:1646 */ + break; + + case 70: +#line 682 "lab9.y" /* yacc.c:1646 */ + { (yyval.astnode) = (yyvsp[0].astnode); } +#line 2228 "y.tab.c" /* yacc.c:1646 */ + break; + case 71: -#line 662 "lab9.y" /* yacc.c:1646 */ +#line 683 "lab9.y" /* yacc.c:1646 */ { // check that left is equal to right if ((yyvsp[-2].astnode)->A_Declared_Type != (yyvsp[0].astnode)->A_Declared_Type) { @@ -2237,59 +2255,59 @@ yyreduce: (yyval.astnode)->symbol = Insert((yyval.astnode)->name,(yyval.astnode)->A_Declared_Type, ID_Sub_Type_Scalar, level, 1, offset, NULL); offset++; } -#line 2241 "y.tab.c" /* yacc.c:1646 */ - break; - - case 72: -#line 690 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_TIMES; } -#line 2247 "y.tab.c" /* yacc.c:1646 */ - break; - - case 73: -#line 691 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_DIVIDE; } -#line 2253 "y.tab.c" /* yacc.c:1646 */ - break; - - case 74: -#line 692 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_MOD; } #line 2259 "y.tab.c" /* yacc.c:1646 */ break; - case 75: -#line 693 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_AND; } + case 72: +#line 711 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_TIMES; } #line 2265 "y.tab.c" /* yacc.c:1646 */ break; - case 76: -#line 694 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_OR; } + case 73: +#line 712 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_DIVIDE; } #line 2271 "y.tab.c" /* yacc.c:1646 */ break; - case 77: -#line 695 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_LEFTSHIFT; } + case 74: +#line 713 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_MOD; } #line 2277 "y.tab.c" /* yacc.c:1646 */ break; - case 78: -#line 696 "lab9.y" /* yacc.c:1646 */ - { (yyval.operator) = A_RIGHTSHIFT; } + case 75: +#line 714 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_AND; } #line 2283 "y.tab.c" /* yacc.c:1646 */ break; + case 76: +#line 715 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_OR; } +#line 2289 "y.tab.c" /* yacc.c:1646 */ + break; + + case 77: +#line 716 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_LEFTSHIFT; } +#line 2295 "y.tab.c" /* yacc.c:1646 */ + break; + + case 78: +#line 717 "lab9.y" /* yacc.c:1646 */ + { (yyval.operator) = A_RIGHTSHIFT; } +#line 2301 "y.tab.c" /* yacc.c:1646 */ + break; + case 79: -#line 699 "lab9.y" /* yacc.c:1646 */ +#line 720 "lab9.y" /* yacc.c:1646 */ { struct SymbTab *p; p = Search((yyvsp[0].string), level, 1); if(p == NULL) { - yyerror("Symbol on LVALUE not defined"); + yyerror("Symbol on RVALUE not defined"); yyerror((yyvsp[0].string)); exit(1); } @@ -2305,17 +2323,17 @@ yyreduce: (yyval.astnode)->A_Declared_Type = p->Type; } -#line 2309 "y.tab.c" /* yacc.c:1646 */ +#line 2327 "y.tab.c" /* yacc.c:1646 */ break; case 80: -#line 720 "lab9.y" /* yacc.c:1646 */ +#line 741 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = (yyvsp[0].astnode); } -#line 2315 "y.tab.c" /* yacc.c:1646 */ +#line 2333 "y.tab.c" /* yacc.c:1646 */ break; case 81: -#line 721 "lab9.y" /* yacc.c:1646 */ +#line 742 "lab9.y" /* yacc.c:1646 */ { struct SymbTab *p; p = Search((yyvsp[-3].string), level, 1); @@ -2337,23 +2355,23 @@ yyreduce: (yyval.astnode)->symbol = p; (yyval.astnode)->A_Declared_Type = p->Type; } -#line 2341 "y.tab.c" /* yacc.c:1646 */ +#line 2359 "y.tab.c" /* yacc.c:1646 */ break; case 82: -#line 742 "lab9.y" /* yacc.c:1646 */ +#line 763 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = (yyvsp[0].astnode); } -#line 2347 "y.tab.c" /* yacc.c:1646 */ +#line 2365 "y.tab.c" /* yacc.c:1646 */ break; case 83: -#line 743 "lab9.y" /* yacc.c:1646 */ +#line 764 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = (yyvsp[-1].astnode); } -#line 2353 "y.tab.c" /* yacc.c:1646 */ +#line 2371 "y.tab.c" /* yacc.c:1646 */ break; case 84: -#line 744 "lab9.y" /* yacc.c:1646 */ +#line 765 "lab9.y" /* yacc.c:1646 */ { // check if our right is a bool @@ -2373,21 +2391,21 @@ yyreduce: (yyval.astnode)->symbol = Insert((yyval.astnode)->name,A_Decaf_BOOL, ID_Sub_Type_Scalar, level, 1, offset, NULL); offset++; } -#line 2377 "y.tab.c" /* yacc.c:1646 */ +#line 2395 "y.tab.c" /* yacc.c:1646 */ break; case 85: -#line 765 "lab9.y" /* yacc.c:1646 */ +#line 786 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = ASTCreateNode(A_CONSTANT_STRING); (yyval.astnode)->name = (yyvsp[0].string); (yyval.astnode)->A_Declared_Type = A_Decaf_STRING; } -#line 2387 "y.tab.c" /* yacc.c:1646 */ +#line 2405 "y.tab.c" /* yacc.c:1646 */ break; case 86: -#line 770 "lab9.y" /* yacc.c:1646 */ +#line 791 "lab9.y" /* yacc.c:1646 */ { // check if our right is an int if ((yyvsp[0].astnode)->A_Declared_Type != A_Decaf_INT) { @@ -2403,61 +2421,61 @@ yyreduce: (yyval.astnode)->symbol = Insert((yyval.astnode)->name,A_Decaf_BOOL, ID_Sub_Type_Scalar, level, 1, offset, NULL); offset++; } -#line 2407 "y.tab.c" /* yacc.c:1646 */ - break; - - case 87: -#line 790 "lab9.y" /* yacc.c:1646 */ - { (yyval.asttype) = A_Decaf_STRING; } -#line 2413 "y.tab.c" /* yacc.c:1646 */ - break; - - case 89: -#line 795 "lab9.y" /* yacc.c:1646 */ - { (yyval.asttype) = A_Decaf_INT; } -#line 2419 "y.tab.c" /* yacc.c:1646 */ - break; - - case 90: -#line 796 "lab9.y" /* yacc.c:1646 */ - { (yyval.asttype) = A_Decaf_BOOL; } #line 2425 "y.tab.c" /* yacc.c:1646 */ break; - case 91: -#line 799 "lab9.y" /* yacc.c:1646 */ - { (yyval.asttype) = A_Decaf_VOID; } + case 87: +#line 811 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = A_Decaf_STRING; } #line 2431 "y.tab.c" /* yacc.c:1646 */ break; - case 92: -#line 800 "lab9.y" /* yacc.c:1646 */ - { (yyval.asttype) = (yyvsp[0].asttype); } + case 89: +#line 816 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = A_Decaf_INT; } #line 2437 "y.tab.c" /* yacc.c:1646 */ break; + case 90: +#line 817 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = A_Decaf_BOOL; } +#line 2443 "y.tab.c" /* yacc.c:1646 */ + break; + + case 91: +#line 820 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = A_Decaf_VOID; } +#line 2449 "y.tab.c" /* yacc.c:1646 */ + break; + + case 92: +#line 821 "lab9.y" /* yacc.c:1646 */ + { (yyval.asttype) = (yyvsp[0].asttype); } +#line 2455 "y.tab.c" /* yacc.c:1646 */ + break; + case 93: -#line 803 "lab9.y" /* yacc.c:1646 */ +#line 824 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = ASTCreateNode(A_CONSTANT_BOOL); (yyval.astnode)->value = 1; (yyval.astnode)->A_Declared_Type = A_Decaf_BOOL; } -#line 2447 "y.tab.c" /* yacc.c:1646 */ +#line 2465 "y.tab.c" /* yacc.c:1646 */ break; case 94: -#line 808 "lab9.y" /* yacc.c:1646 */ +#line 829 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = ASTCreateNode(A_CONSTANT_BOOL); (yyval.astnode)->value = 0; (yyval.astnode)->A_Declared_Type = A_Decaf_BOOL; } -#line 2457 "y.tab.c" /* yacc.c:1646 */ +#line 2475 "y.tab.c" /* yacc.c:1646 */ break; case 95: -#line 815 "lab9.y" /* yacc.c:1646 */ +#line 836 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = ASTCreateNode(A_ARRAYTYPE); (yyval.astnode)->value = (yyvsp[-2].value); @@ -2465,29 +2483,29 @@ yyreduce: (yyval.astnode)->size = (yyvsp[-2].value); // printf("THE SIZE IS %d %d", $2, $$->size);// debug } -#line 2469 "y.tab.c" /* yacc.c:1646 */ +#line 2487 "y.tab.c" /* yacc.c:1646 */ break; case 96: -#line 824 "lab9.y" /* yacc.c:1646 */ +#line 845 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = ASTCreateNode(A_CONSTANT_INT); (yyval.astnode)->value = (yyvsp[0].value); (yyval.astnode)->A_Declared_Type = A_Decaf_INT; } -#line 2479 "y.tab.c" /* yacc.c:1646 */ +#line 2497 "y.tab.c" /* yacc.c:1646 */ break; case 97: -#line 830 "lab9.y" /* yacc.c:1646 */ +#line 851 "lab9.y" /* yacc.c:1646 */ { (yyval.astnode) = (yyvsp[0].astnode); } -#line 2487 "y.tab.c" /* yacc.c:1646 */ +#line 2505 "y.tab.c" /* yacc.c:1646 */ break; -#line 2491 "y.tab.c" /* yacc.c:1646 */ +#line 2509 "y.tab.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2715,13 +2733,13 @@ yyreturn: #endif return yyresult; } -#line 833 "lab9.y" /* yacc.c:1906 */ +#line 854 "lab9.y" /* yacc.c:1906 */ /* end of rules, start of program */ int main(int argc, char ** argv){ for (int i = 1; iname == "john"){ + return ( count(p->next) + + count (p->S1) + + count (p->S2) + 1); + } else { + return ( count(p->next) + + count (p->S1) + + count (p->S2)); + } + + +} +``` + +--- + +$$ E \Rightarrow E - E | id$$ + +$$ E \Rightarrow id - E | id$$ \ No newline at end of file