diff --git a/LAB5/ErrorTest.decaf b/LAB5/ErrorTest.decaf index 90b6efd..41091f4 100644 --- a/LAB5/ErrorTest.decaf +++ b/LAB5/ErrorTest.decaf @@ -34,13 +34,13 @@ package foo { } func main() int { foo(1); - // for ( i=1,j=2; i <= k; i=i+1, j=j+2) // for loop - // { - // var x,y,z int; - // var x,y,z bool; + for ( i=1,j=2; i <= k; i=i+1, j=j+2) // for loop + { + var x,y,z int; + var x,y,z bool; i = print_int(i); - // x = 0xBad0FF; // HEX - // } + x = 0xBad0FF; // HEX + } } diff --git a/LAB5/ErrorTest.png b/LAB5/ErrorTest.png new file mode 100644 index 0000000..455a97a Binary files /dev/null and b/LAB5/ErrorTest.png differ diff --git a/LAB5/GoodTest.decaf b/LAB5/GoodTest.decaf index 17a840c..7b72c77 100644 --- a/LAB5/GoodTest.decaf +++ b/LAB5/GoodTest.decaf @@ -4,12 +4,12 @@ extern func print_int(int) void; extern func print_string(string) void; package foo { + var x int; var y int = 100; var A[100] bool; - func foo(x int) void { - var x int; + func foo(x int) void { var x int; var x int; var y bool; while ( x <= y ) diff --git a/LAB5/GoodTest.png b/LAB5/GoodTest.png new file mode 100644 index 0000000..54ad74a Binary files /dev/null and b/LAB5/GoodTest.png differ diff --git a/LAB5/Makefile b/LAB5/Makefile index 24bf909..2a6c04a 100644 --- a/LAB5/Makefile +++ b/LAB5/Makefile @@ -10,7 +10,7 @@ all: lab5 # Compile all the THINGS! lab5: lab5.l lab5.y symtable.c symtable.h lex lab5.l - yacc -d lab5.y + yacc -d --verbose --debug lab5.y gcc $(FLAGS) y.tab.c lex.yy.c symtable.c -o lab5 -lm # remove the binary and other generated stuff diff --git a/LAB5/README.md b/LAB5/README.md new file mode 100644 index 0000000..faac1e1 --- /dev/null +++ b/LAB5/README.md @@ -0,0 +1,29 @@ +# CS370 Compilers Lab 5 +## Ziad Arafat - Mar 8 2021 + +In this lab we take our previous lab code and implement the proper syntax rules from the DECAF programming language. + +## Screenshots +#### Good Test +![alt](GoodTest.png) + +#### Error Test + +![alt](ErrorTest.png) + +## Changelog + +#### 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 + +#### 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 diff --git a/LAB5/lab5.l b/LAB5/lab5.l index aaece4c..64647d8 100644 --- a/LAB5/lab5.l +++ b/LAB5/lab5.l @@ -8,31 +8,47 @@ January 2015 */ +/* Ziad Arafat Mar 8 2021 */ + %{ #include "y.tab.h" +#include int yylex(); int mydebug=0; -int readHexValue(char * inch) +int aHexToInt(char * hexstr) { - int val; - if (*inch >= '0' && *inch <= '9') val = (*inch - '0') * 16; - else if (*inch >= 'a' && *inch <= 'f') val = (*inch - 'a' + 10) * 16; - else if (*inch >= 'A' && *inch <='F') val = (*inch - 'A' + 10) * 16; + // 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; - char *inchptr; - for (inchptr = inch; *inchptr != '\0'; inchptr++){ - if (*inchptr >= '0' && *inchptr <= '9') val += (*inchptr - '0'); - else if (*inchptr >= 'a' && *inchptr <= 'f') val += (*inchptr - 'a' + 10); - else if (*inchptr >= 'A' && *inchptr <='F') val += (*inchptr - 'A' + 10); - } + // 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; - printf("The hex value is: %d\n", val); - - return val; + 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; } %} @@ -40,50 +56,58 @@ int readHexValue(char * inch) /* 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);} +"&&" {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);} -\. {return(T_DOT);} -"else" {return(T_ELSE);} -"==" {return(T_EQ);} -"extern" {return(T_EXTERN);} -"false" {return(T_FALSE);} -"for" {return(T_FOR);} -"func" {return(T_FUNC);} -">=" {return(T_GEQ);} -">" {return(T_GT);} -"<" {return(T_LT);} -"if" {if (mydebug) fprintf(stderr,"T_IF found\n");return(T_IF);} +"bool" {return(T_BOOLTYPE);} +"break" {return(T_BREAK);} +"continue" {return(T_CONTINUE);} +\. {return(T_DOT);} +"else" {return(T_ELSE);} +"==" {return(T_EQ);} +"extern" {return(T_EXTERN);} +"false" {return(T_FALSE);} +"for" {return(T_FOR);} +"func" {return(T_FUNC);} +">=" {return(T_GEQ);} +">" {return(T_GT);} + +"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);} -"null" {return(T_NULL);} -"||" {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);} + +"<<" {return(T_LEFTSHIFT);} +"<=" {return(T_LEQ);} +"!=" {return(T_NEQ);} +"null" {return(T_NULL);} +"||" {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.value=yytext[1]; @@ -102,6 +126,14 @@ CHANGES: 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); @@ -112,7 +144,7 @@ CHANGES: if (mydebug) fprintf(stderr,"Whitespace found\n"); } -[\-+*/%();{},\[\]!] { +[\-+*/%();{},\[\]!<] { if (mydebug) fprintf(stderr,"return a token %c\n",*yytext); return (*yytext); } @@ -124,4 +156,6 @@ CHANGES: %% int yywrap(void) -{ return 1;} \ No newline at end of file +{ + return 1; +} \ No newline at end of file diff --git a/LAB5/lab5.y b/LAB5/lab5.y index 74316ad..52bfdc3 100644 --- a/LAB5/lab5.y +++ b/LAB5/lab5.y @@ -1,15 +1,23 @@ +/* +Ziad Arafat - Mar 8 2021 +Lab 5 +*/ + %{ #include -#include #include + int yylex(); -extern int yylineno; +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); - fprintf(stderr, "Error on line: %d \n", yylineno); + + // print out the line number of the syntax error. + fprintf(stderr, "Error on line: %d \n", yylineno); } @@ -26,6 +34,7 @@ from LEX and how the operators are associated */ char* string; } +// Added a token for each of the lex tokens %token T_AND %token T_ASSIGN %token T_BOOLTYPE @@ -41,7 +50,6 @@ from LEX and how the operators are associated */ %token T_FUNC %token T_GEQ %token T_GT -%token T_LT %token T_ID %token T_IF %token T_INTCONSTANT @@ -61,7 +69,13 @@ from LEX and how the operators are associated */ %token T_VOID %token T_WHILE +/* 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 '}' @@ -135,6 +149,9 @@ Statement : Assign ';' Assign : Lvalue T_ASSIGN Expr ; +/* Assigns : Assign + | Assign ',' Assigns + ; */ Lvalue : T_ID | T_ID '[' Expr ']' @@ -147,7 +164,6 @@ MethodCall : T_ID '(' MethodArgs ')' ; MethodArg : Expr - | T_STRINGCONSTANT ; MethodArgs : /* empty */ @@ -165,6 +181,9 @@ Statement : T_IF '(' Expr ')' Block T_ELSE Block Statement : T_WHILE '(' Expr ')' Block ; +/* Statement : T_FOR '(' Assigns ';' Expr ';' Assigns ')' Block + ; */ + Statement : T_RETURN ';' | T_RETURN '(' ')' ';' | T_RETURN '(' Expr ')' ';' @@ -183,7 +202,7 @@ Simpleexpression : Additiveexpression | Simpleexpression Relop Additiveexpression ; -Relop : T_LEQ | T_LT | T_GT | T_GEQ | T_EQ | T_NEQ +Relop : T_LEQ | '<' | T_GT | T_GEQ | T_EQ | T_NEQ ; Additiveexpression : Term @@ -196,7 +215,7 @@ Addop : '+' | '-' Term : Factor | Term Multop Factor ; - +/* added modulus as a multi operator */ Multop : '*' | '/' | '%' | T_AND | T_OR | T_LEFTSHIFT | T_RIGHTSHIFT ; @@ -230,9 +249,10 @@ BoolConstant : T_TRUE ArrayType : '[' T_INTCONSTANT ']' Type ; - +/* added String and Char as constants */ Constant : T_INTCONSTANT | T_STRINGCONSTANT + | T_CHARCONSTANT | BoolConstant ; %% /* end of rules, start of program */ diff --git a/LAB5/y.output b/LAB5/y.output new file mode 100644 index 0000000..66a66ec --- /dev/null +++ b/LAB5/y.output @@ -0,0 +1,1851 @@ +Terminals unused in grammar + + T_DOT + T_FOR + T_NULL + + +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 MethodDecl: T_FUNC T_ID '(' IdTypeList ')' MethodType Block + + 17 IdTypeList: %empty + 18 | IdTypeList1 + + 19 IdTypeList1: T_ID Type + 20 | T_ID Type ',' IdTypeList + + 21 Block: '{' VarDecls Statements '}' + + 22 VarDecls: %empty + 23 | VarDecl VarDecls + + 24 VarDecl: T_VAR T_ID Type ';' + 25 | T_VAR T_ID ArrayType ';' + + 26 Statements: %empty + 27 | Statement Statements + + 28 Statement: Block + 29 | Assign ';' + + 30 Assign: Lvalue T_ASSIGN Expr + + 31 Lvalue: T_ID + 32 | T_ID '[' Expr ']' + + 33 Statement: MethodCall ';' + + 34 MethodCall: T_ID '(' MethodArgs ')' + + 35 MethodArg: Expr + + 36 MethodArgs: %empty + 37 | FullMethodArgs + + 38 FullMethodArgs: MethodArg + 39 | MethodArg ',' MethodArgs + + 40 Statement: T_IF '(' Expr ')' Block T_ELSE Block + 41 | T_IF '(' Expr ')' Block + 42 | T_WHILE '(' Expr ')' Block + 43 | T_RETURN ';' + 44 | T_RETURN '(' ')' ';' + 45 | T_RETURN '(' Expr ')' ';' + 46 | T_BREAK ';' + 47 | T_CONTINUE ';' + + 48 Expr: Simpleexpression + + 49 Simpleexpression: Additiveexpression + 50 | Simpleexpression Relop Additiveexpression + + 51 Relop: T_LEQ + 52 | '<' + 53 | T_GT + 54 | T_GEQ + 55 | T_EQ + 56 | T_NEQ + + 57 Additiveexpression: Term + 58 | Additiveexpression Addop Term + + 59 Addop: '+' + 60 | '-' + + 61 Term: Factor + 62 | Term Multop Factor + + 63 Multop: '*' + 64 | '/' + 65 | '%' + 66 | T_AND + 67 | T_OR + 68 | T_LEFTSHIFT + 69 | T_RIGHTSHIFT + + 70 Factor: T_ID + 71 | MethodCall + 72 | T_ID '[' Expr ']' + 73 | Constant + 74 | '(' Expr ')' + 75 | '!' Factor + 76 | '-' Factor + + 77 ExternType: T_STRINGTYPE + 78 | Type + + 79 Type: T_INTTYPE + 80 | T_BOOLTYPE + + 81 MethodType: T_VOID + 82 | Type + + 83 BoolConstant: T_TRUE + 84 | T_FALSE + + 85 ArrayType: '[' T_INTCONSTANT ']' Type + + 86 Constant: T_INTCONSTANT + 87 | T_STRINGCONSTANT + 88 | T_CHARCONSTANT + 89 | BoolConstant + + +Terminals, with rules where they appear + +$end (0) 0 +'!' (33) 75 +'%' (37) 65 +'(' (40) 4 16 34 40 41 42 44 45 74 +')' (41) 4 16 34 40 41 42 44 45 74 +'*' (42) 63 +'+' (43) 59 +',' (44) 8 20 39 +'-' (45) 60 76 +'/' (47) 64 +';' (59) 4 11 12 13 24 25 29 33 43 44 45 46 47 +'<' (60) 52 +'[' (91) 32 72 85 +']' (93) 32 72 85 +'{' (123) 1 21 +'}' (125) 1 21 +error (256) +T_AND (258) 66 +T_ASSIGN (259) 13 30 +T_BOOLTYPE (260) 80 +T_BREAK (261) 46 +T_CHARCONSTANT (262) 88 +T_CONTINUE (263) 47 +T_DOT (264) +T_ELSE (265) 40 +T_EQ (266) 55 +T_EXTERN (267) 4 +T_FALSE (268) 84 +T_FOR (269) +T_FUNC (270) 4 16 +T_GEQ (271) 54 +T_GT (272) 53 +T_ID (273) 1 4 11 12 13 16 19 20 24 25 31 32 34 70 72 +T_IF (274) 40 41 +T_INTCONSTANT (275) 85 86 +T_INTTYPE (276) 79 +T_LEFTSHIFT (277) 68 +T_LEQ (278) 51 +T_NEQ (279) 56 +T_NULL (280) +T_OR (281) 67 +T_PACKAGE (282) 1 +T_RETURN (283) 43 44 45 +T_RIGHTSHIFT (284) 69 +T_STRINGCONSTANT (285) 87 +T_STRINGTYPE (286) 77 +T_TRUE (287) 83 +T_VAR (288) 11 12 13 24 25 +T_VOID (289) 81 +T_WHILE (290) 42 + + +Nonterminals, with rules where they appear + +$accept (51) + on left: 0 +Program (52) + on left: 1, on right: 0 +Externs (53) + on left: 2 3, on right: 1 3 +ExternDefn (54) + on left: 4, on right: 3 +ExternParmList (55) + on left: 5 6, on right: 4 8 +FullExternParmList (56) + on left: 7 8, on right: 6 +FieldDecls (57) + on left: 9 10, on right: 1 10 +FieldDecl (58) + on left: 11 12 13, on right: 10 +MethodDecls (59) + on left: 14 15, on right: 1 15 +MethodDecl (60) + on left: 16, on right: 15 +IdTypeList (61) + on left: 17 18, on right: 16 20 +IdTypeList1 (62) + on left: 19 20, on right: 18 +Block (63) + on left: 21, on right: 16 28 40 41 42 +VarDecls (64) + on left: 22 23, on right: 21 23 +VarDecl (65) + on left: 24 25, on right: 23 +Statements (66) + on left: 26 27, on right: 21 27 +Statement (67) + on left: 28 29 33 40 41 42 43 44 45 46 47, on right: 27 +Assign (68) + on left: 30, on right: 29 +Lvalue (69) + on left: 31 32, on right: 30 +MethodCall (70) + on left: 34, on right: 33 71 +MethodArg (71) + on left: 35, on right: 38 39 +MethodArgs (72) + on left: 36 37, on right: 34 39 +FullMethodArgs (73) + on left: 38 39, on right: 37 +Expr (74) + on left: 48, on right: 30 32 35 40 41 42 45 72 74 +Simpleexpression (75) + on left: 49 50, on right: 48 50 +Relop (76) + on left: 51 52 53 54 55 56, on right: 50 +Additiveexpression (77) + on left: 57 58, on right: 49 50 58 +Addop (78) + on left: 59 60, on right: 58 +Term (79) + on left: 61 62, on right: 57 58 62 +Multop (80) + on left: 63 64 65 66 67 68 69, on right: 62 +Factor (81) + on left: 70 71 72 73 74 75 76, on right: 61 62 75 76 +ExternType (82) + on left: 77 78, on right: 7 8 +Type (83) + on left: 79 80, on right: 11 13 19 20 24 78 82 85 +MethodType (84) + on left: 81 82, on right: 4 16 +BoolConstant (85) + on left: 83 84, on right: 89 +ArrayType (86) + on left: 85, on right: 12 25 +Constant (87) + on left: 86 87 88 89, on right: 13 73 + + +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 + + 80 Type: T_BOOLTYPE . + + $default reduce using rule 80 (Type) + + +State 14 + + 79 Type: T_INTTYPE . + + $default reduce using rule 79 (Type) + + +State 15 + + 77 ExternType: T_STRINGTYPE . + + $default reduce using rule 77 (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 + + 78 ExternType: Type . + + $default reduce using rule 78 (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 + + 16 MethodDecl: T_FUNC . T_ID '(' IdTypeList ')' MethodType 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 + + 81 MethodType: T_VOID . + + $default reduce using rule 81 (MethodType) + + +State 31 + + 82 MethodType: Type . + + $default reduce using rule 82 (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 + + 85 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 + + 16 MethodDecl: T_FUNC T_ID . '(' IdTypeList ')' MethodType Block + + '(' shift, and 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 + + 85 ArrayType: '[' T_INTCONSTANT . ']' Type + + ']' shift, and go to state 46 + + +State 42 + + 13 FieldDecl: T_VAR T_ID Type T_ASSIGN . Constant ';' + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + + BoolConstant go to state 52 + Constant go to state 53 + + +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 + + 16 MethodDecl: T_FUNC T_ID '(' . IdTypeList ')' MethodType Block + + T_ID shift, and go to state 54 + + $default reduce using rule 17 (IdTypeList) + + IdTypeList go to state 55 + IdTypeList1 go to state 56 + + +State 46 + + 85 ArrayType: '[' T_INTCONSTANT ']' . Type + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + + Type go to state 57 + + +State 47 + + 88 Constant: T_CHARCONSTANT . + + $default reduce using rule 88 (Constant) + + +State 48 + + 84 BoolConstant: T_FALSE . + + $default reduce using rule 84 (BoolConstant) + + +State 49 + + 86 Constant: T_INTCONSTANT . + + $default reduce using rule 86 (Constant) + + +State 50 + + 87 Constant: T_STRINGCONSTANT . + + $default reduce using rule 87 (Constant) + + +State 51 + + 83 BoolConstant: T_TRUE . + + $default reduce using rule 83 (BoolConstant) + + +State 52 + + 89 Constant: BoolConstant . + + $default reduce using rule 89 (Constant) + + +State 53 + + 13 FieldDecl: T_VAR T_ID Type T_ASSIGN Constant . ';' + + ';' shift, and go to state 58 + + +State 54 + + 19 IdTypeList1: T_ID . Type + 20 | T_ID . Type ',' IdTypeList + + T_BOOLTYPE shift, and go to state 13 + T_INTTYPE shift, and go to state 14 + + Type go to state 59 + + +State 55 + + 16 MethodDecl: T_FUNC T_ID '(' IdTypeList . ')' MethodType Block + + ')' shift, and go to state 60 + + +State 56 + + 18 IdTypeList: IdTypeList1 . + + $default reduce using rule 18 (IdTypeList) + + +State 57 + + 85 ArrayType: '[' T_INTCONSTANT ']' Type . + + $default reduce using rule 85 (ArrayType) + + +State 58 + + 13 FieldDecl: T_VAR T_ID Type T_ASSIGN Constant ';' . + + $default reduce using rule 13 (FieldDecl) + + +State 59 + + 19 IdTypeList1: T_ID Type . + 20 | T_ID Type . ',' IdTypeList + + ',' shift, and go to state 61 + + $default reduce using rule 19 (IdTypeList1) + + +State 60 + + 16 MethodDecl: T_FUNC T_ID '(' IdTypeList ')' . MethodType 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 62 + + +State 61 + + 20 IdTypeList1: T_ID Type ',' . IdTypeList + + T_ID shift, and go to state 54 + + $default reduce using rule 17 (IdTypeList) + + IdTypeList go to state 63 + IdTypeList1 go to state 56 + + +State 62 + + 16 MethodDecl: T_FUNC T_ID '(' IdTypeList ')' MethodType . Block + + '{' shift, and go to state 64 + + Block go to state 65 + + +State 63 + + 20 IdTypeList1: T_ID Type ',' IdTypeList . + + $default reduce using rule 20 (IdTypeList1) + + +State 64 + + 21 Block: '{' . VarDecls Statements '}' + + T_VAR shift, and go to state 66 + + $default reduce using rule 22 (VarDecls) + + VarDecls go to state 67 + VarDecl go to state 68 + + +State 65 + + 16 MethodDecl: T_FUNC T_ID '(' IdTypeList ')' MethodType Block . + + $default reduce using rule 16 (MethodDecl) + + +State 66 + + 24 VarDecl: T_VAR . T_ID Type ';' + 25 | T_VAR . T_ID ArrayType ';' + + T_ID shift, and go to state 69 + + +State 67 + + 21 Block: '{' VarDecls . Statements '}' + + T_BREAK shift, and go to state 70 + T_CONTINUE shift, and go to state 71 + T_ID shift, and go to state 72 + T_IF shift, and go to state 73 + T_RETURN shift, and go to state 74 + T_WHILE shift, and go to state 75 + '{' shift, and go to state 64 + + $default reduce using rule 26 (Statements) + + Block go to state 76 + Statements go to state 77 + Statement go to state 78 + Assign go to state 79 + Lvalue go to state 80 + MethodCall go to state 81 + + +State 68 + + 23 VarDecls: VarDecl . VarDecls + + T_VAR shift, and go to state 66 + + $default reduce using rule 22 (VarDecls) + + VarDecls go to state 82 + VarDecl go to state 68 + + +State 69 + + 24 VarDecl: T_VAR T_ID . Type ';' + 25 | 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 83 + ArrayType go to state 84 + + +State 70 + + 46 Statement: T_BREAK . ';' + + ';' shift, and go to state 85 + + +State 71 + + 47 Statement: T_CONTINUE . ';' + + ';' shift, and go to state 86 + + +State 72 + + 31 Lvalue: T_ID . + 32 | T_ID . '[' Expr ']' + 34 MethodCall: T_ID . '(' MethodArgs ')' + + '(' shift, and go to state 87 + '[' shift, and go to state 88 + + $default reduce using rule 31 (Lvalue) + + +State 73 + + 40 Statement: T_IF . '(' Expr ')' Block T_ELSE Block + 41 | T_IF . '(' Expr ')' Block + + '(' shift, and go to state 89 + + +State 74 + + 43 Statement: T_RETURN . ';' + 44 | T_RETURN . '(' ')' ';' + 45 | T_RETURN . '(' Expr ')' ';' + + '(' shift, and go to state 90 + ';' shift, and go to state 91 + + +State 75 + + 42 Statement: T_WHILE . '(' Expr ')' Block + + '(' shift, and go to state 92 + + +State 76 + + 28 Statement: Block . + + $default reduce using rule 28 (Statement) + + +State 77 + + 21 Block: '{' VarDecls Statements . '}' + + '}' shift, and go to state 93 + + +State 78 + + 27 Statements: Statement . Statements + + T_BREAK shift, and go to state 70 + T_CONTINUE shift, and go to state 71 + T_ID shift, and go to state 72 + T_IF shift, and go to state 73 + T_RETURN shift, and go to state 74 + T_WHILE shift, and go to state 75 + '{' shift, and go to state 64 + + $default reduce using rule 26 (Statements) + + Block go to state 76 + Statements go to state 94 + Statement go to state 78 + Assign go to state 79 + Lvalue go to state 80 + MethodCall go to state 81 + + +State 79 + + 29 Statement: Assign . ';' + + ';' shift, and go to state 95 + + +State 80 + + 30 Assign: Lvalue . T_ASSIGN Expr + + T_ASSIGN shift, and go to state 96 + + +State 81 + + 33 Statement: MethodCall . ';' + + ';' shift, and go to state 97 + + +State 82 + + 23 VarDecls: VarDecl VarDecls . + + $default reduce using rule 23 (VarDecls) + + +State 83 + + 24 VarDecl: T_VAR T_ID Type . ';' + + ';' shift, and go to state 98 + + +State 84 + + 25 VarDecl: T_VAR T_ID ArrayType . ';' + + ';' shift, and go to state 99 + + +State 85 + + 46 Statement: T_BREAK ';' . + + $default reduce using rule 46 (Statement) + + +State 86 + + 47 Statement: T_CONTINUE ';' . + + $default reduce using rule 47 (Statement) + + +State 87 + + 34 MethodCall: T_ID '(' . MethodArgs ')' + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + $default reduce using rule 36 (MethodArgs) + + MethodCall go to state 104 + MethodArg go to state 105 + MethodArgs go to state 106 + FullMethodArgs go to state 107 + Expr go to state 108 + Simpleexpression go to state 109 + Additiveexpression go to state 110 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 88 + + 32 Lvalue: T_ID '[' . Expr ']' + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Expr go to state 114 + Simpleexpression go to state 109 + Additiveexpression go to state 110 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 89 + + 40 Statement: T_IF '(' . Expr ')' Block T_ELSE Block + 41 | T_IF '(' . Expr ')' Block + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Expr go to state 115 + Simpleexpression go to state 109 + Additiveexpression go to state 110 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 90 + + 44 Statement: T_RETURN '(' . ')' ';' + 45 | T_RETURN '(' . Expr ')' ';' + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + ')' shift, and go to state 116 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Expr go to state 117 + Simpleexpression go to state 109 + Additiveexpression go to state 110 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 91 + + 43 Statement: T_RETURN ';' . + + $default reduce using rule 43 (Statement) + + +State 92 + + 42 Statement: T_WHILE '(' . Expr ')' Block + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Expr go to state 118 + Simpleexpression go to state 109 + Additiveexpression go to state 110 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 93 + + 21 Block: '{' VarDecls Statements '}' . + + $default reduce using rule 21 (Block) + + +State 94 + + 27 Statements: Statement Statements . + + $default reduce using rule 27 (Statements) + + +State 95 + + 29 Statement: Assign ';' . + + $default reduce using rule 29 (Statement) + + +State 96 + + 30 Assign: Lvalue T_ASSIGN . Expr + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Expr go to state 119 + Simpleexpression go to state 109 + Additiveexpression go to state 110 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 97 + + 33 Statement: MethodCall ';' . + + $default reduce using rule 33 (Statement) + + +State 98 + + 24 VarDecl: T_VAR T_ID Type ';' . + + $default reduce using rule 24 (VarDecl) + + +State 99 + + 25 VarDecl: T_VAR T_ID ArrayType ';' . + + $default reduce using rule 25 (VarDecl) + + +State 100 + + 34 MethodCall: T_ID . '(' MethodArgs ')' + 70 Factor: T_ID . + 72 | T_ID . '[' Expr ']' + + '(' shift, and go to state 87 + '[' shift, and go to state 120 + + $default reduce using rule 70 (Factor) + + +State 101 + + 74 Factor: '(' . Expr ')' + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Expr go to state 121 + Simpleexpression go to state 109 + Additiveexpression go to state 110 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 102 + + 76 Factor: '-' . Factor + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Factor go to state 122 + BoolConstant go to state 52 + Constant go to state 113 + + +State 103 + + 75 Factor: '!' . Factor + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Factor go to state 123 + BoolConstant go to state 52 + Constant go to state 113 + + +State 104 + + 71 Factor: MethodCall . + + $default reduce using rule 71 (Factor) + + +State 105 + + 38 FullMethodArgs: MethodArg . + 39 | MethodArg . ',' MethodArgs + + ',' shift, and go to state 124 + + $default reduce using rule 38 (FullMethodArgs) + + +State 106 + + 34 MethodCall: T_ID '(' MethodArgs . ')' + + ')' shift, and go to state 125 + + +State 107 + + 37 MethodArgs: FullMethodArgs . + + $default reduce using rule 37 (MethodArgs) + + +State 108 + + 35 MethodArg: Expr . + + $default reduce using rule 35 (MethodArg) + + +State 109 + + 48 Expr: Simpleexpression . + 50 Simpleexpression: Simpleexpression . Relop Additiveexpression + + T_EQ shift, and go to state 126 + T_GEQ shift, and go to state 127 + T_GT shift, and go to state 128 + T_LEQ shift, and go to state 129 + T_NEQ shift, and go to state 130 + '<' shift, and go to state 131 + + $default reduce using rule 48 (Expr) + + Relop go to state 132 + + +State 110 + + 49 Simpleexpression: Additiveexpression . + 58 Additiveexpression: Additiveexpression . Addop Term + + '+' shift, and go to state 133 + '-' shift, and go to state 134 + + $default reduce using rule 49 (Simpleexpression) + + Addop go to state 135 + + +State 111 + + 57 Additiveexpression: Term . + 62 Term: Term . Multop Factor + + T_AND shift, and go to state 136 + T_LEFTSHIFT shift, and go to state 137 + T_OR shift, and go to state 138 + T_RIGHTSHIFT shift, and go to state 139 + '*' shift, and go to state 140 + '/' shift, and go to state 141 + '%' shift, and go to state 142 + + $default reduce using rule 57 (Additiveexpression) + + Multop go to state 143 + + +State 112 + + 61 Term: Factor . + + $default reduce using rule 61 (Term) + + +State 113 + + 73 Factor: Constant . + + $default reduce using rule 73 (Factor) + + +State 114 + + 32 Lvalue: T_ID '[' Expr . ']' + + ']' shift, and go to state 144 + + +State 115 + + 40 Statement: T_IF '(' Expr . ')' Block T_ELSE Block + 41 | T_IF '(' Expr . ')' Block + + ')' shift, and go to state 145 + + +State 116 + + 44 Statement: T_RETURN '(' ')' . ';' + + ';' shift, and go to state 146 + + +State 117 + + 45 Statement: T_RETURN '(' Expr . ')' ';' + + ')' shift, and go to state 147 + + +State 118 + + 42 Statement: T_WHILE '(' Expr . ')' Block + + ')' shift, and go to state 148 + + +State 119 + + 30 Assign: Lvalue T_ASSIGN Expr . + + $default reduce using rule 30 (Assign) + + +State 120 + + 72 Factor: T_ID '[' . Expr ']' + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Expr go to state 149 + Simpleexpression go to state 109 + Additiveexpression go to state 110 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 121 + + 74 Factor: '(' Expr . ')' + + ')' shift, and go to state 150 + + +State 122 + + 76 Factor: '-' Factor . + + $default reduce using rule 76 (Factor) + + +State 123 + + 75 Factor: '!' Factor . + + $default reduce using rule 75 (Factor) + + +State 124 + + 39 FullMethodArgs: MethodArg ',' . MethodArgs + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + $default reduce using rule 36 (MethodArgs) + + MethodCall go to state 104 + MethodArg go to state 105 + MethodArgs go to state 151 + FullMethodArgs go to state 107 + Expr go to state 108 + Simpleexpression go to state 109 + Additiveexpression go to state 110 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 125 + + 34 MethodCall: T_ID '(' MethodArgs ')' . + + $default reduce using rule 34 (MethodCall) + + +State 126 + + 55 Relop: T_EQ . + + $default reduce using rule 55 (Relop) + + +State 127 + + 54 Relop: T_GEQ . + + $default reduce using rule 54 (Relop) + + +State 128 + + 53 Relop: T_GT . + + $default reduce using rule 53 (Relop) + + +State 129 + + 51 Relop: T_LEQ . + + $default reduce using rule 51 (Relop) + + +State 130 + + 56 Relop: T_NEQ . + + $default reduce using rule 56 (Relop) + + +State 131 + + 52 Relop: '<' . + + $default reduce using rule 52 (Relop) + + +State 132 + + 50 Simpleexpression: Simpleexpression Relop . Additiveexpression + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Additiveexpression go to state 152 + Term go to state 111 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 133 + + 59 Addop: '+' . + + $default reduce using rule 59 (Addop) + + +State 134 + + 60 Addop: '-' . + + $default reduce using rule 60 (Addop) + + +State 135 + + 58 Additiveexpression: Additiveexpression Addop . Term + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Term go to state 153 + Factor go to state 112 + BoolConstant go to state 52 + Constant go to state 113 + + +State 136 + + 66 Multop: T_AND . + + $default reduce using rule 66 (Multop) + + +State 137 + + 68 Multop: T_LEFTSHIFT . + + $default reduce using rule 68 (Multop) + + +State 138 + + 67 Multop: T_OR . + + $default reduce using rule 67 (Multop) + + +State 139 + + 69 Multop: T_RIGHTSHIFT . + + $default reduce using rule 69 (Multop) + + +State 140 + + 63 Multop: '*' . + + $default reduce using rule 63 (Multop) + + +State 141 + + 64 Multop: '/' . + + $default reduce using rule 64 (Multop) + + +State 142 + + 65 Multop: '%' . + + $default reduce using rule 65 (Multop) + + +State 143 + + 62 Term: Term Multop . Factor + + T_CHARCONSTANT shift, and go to state 47 + T_FALSE shift, and go to state 48 + T_ID shift, and go to state 100 + T_INTCONSTANT shift, and go to state 49 + T_STRINGCONSTANT shift, and go to state 50 + T_TRUE shift, and go to state 51 + '(' shift, and go to state 101 + '-' shift, and go to state 102 + '!' shift, and go to state 103 + + MethodCall go to state 104 + Factor go to state 154 + BoolConstant go to state 52 + Constant go to state 113 + + +State 144 + + 32 Lvalue: T_ID '[' Expr ']' . + + $default reduce using rule 32 (Lvalue) + + +State 145 + + 40 Statement: T_IF '(' Expr ')' . Block T_ELSE Block + 41 | T_IF '(' Expr ')' . Block + + '{' shift, and go to state 64 + + Block go to state 155 + + +State 146 + + 44 Statement: T_RETURN '(' ')' ';' . + + $default reduce using rule 44 (Statement) + + +State 147 + + 45 Statement: T_RETURN '(' Expr ')' . ';' + + ';' shift, and go to state 156 + + +State 148 + + 42 Statement: T_WHILE '(' Expr ')' . Block + + '{' shift, and go to state 64 + + Block go to state 157 + + +State 149 + + 72 Factor: T_ID '[' Expr . ']' + + ']' shift, and go to state 158 + + +State 150 + + 74 Factor: '(' Expr ')' . + + $default reduce using rule 74 (Factor) + + +State 151 + + 39 FullMethodArgs: MethodArg ',' MethodArgs . + + $default reduce using rule 39 (FullMethodArgs) + + +State 152 + + 50 Simpleexpression: Simpleexpression Relop Additiveexpression . + 58 Additiveexpression: Additiveexpression . Addop Term + + '+' shift, and go to state 133 + '-' shift, and go to state 134 + + $default reduce using rule 50 (Simpleexpression) + + Addop go to state 135 + + +State 153 + + 58 Additiveexpression: Additiveexpression Addop Term . + 62 Term: Term . Multop Factor + + T_AND shift, and go to state 136 + T_LEFTSHIFT shift, and go to state 137 + T_OR shift, and go to state 138 + T_RIGHTSHIFT shift, and go to state 139 + '*' shift, and go to state 140 + '/' shift, and go to state 141 + '%' shift, and go to state 142 + + $default reduce using rule 58 (Additiveexpression) + + Multop go to state 143 + + +State 154 + + 62 Term: Term Multop Factor . + + $default reduce using rule 62 (Term) + + +State 155 + + 40 Statement: T_IF '(' Expr ')' Block . T_ELSE Block + 41 | T_IF '(' Expr ')' Block . + + T_ELSE shift, and go to state 159 + + $default reduce using rule 41 (Statement) + + +State 156 + + 45 Statement: T_RETURN '(' Expr ')' ';' . + + $default reduce using rule 45 (Statement) + + +State 157 + + 42 Statement: T_WHILE '(' Expr ')' Block . + + $default reduce using rule 42 (Statement) + + +State 158 + + 72 Factor: T_ID '[' Expr ']' . + + $default reduce using rule 72 (Factor) + + +State 159 + + 40 Statement: T_IF '(' Expr ')' Block T_ELSE . Block + + '{' shift, and go to state 64 + + Block go to state 160 + + +State 160 + + 40 Statement: T_IF '(' Expr ')' Block T_ELSE Block . + + $default reduce using rule 40 (Statement)