diff --git a/Code/a.txt b/Code/a.txt index fd963f490bcbe741f1b4a27eec18b514909225ec..35ee7937d0e0033679155fd384ccf72f686f0e36 100644 --- a/Code/a.txt +++ b/Code/a.txt @@ -1,64 +1,269 @@ +TYPE int +1: parent:0x55972fbd45a0 Specifier:--- child:0x55972fbd3510 TYPE:int--- +ID main +LP ( +RP ) +3: parent:0x55972fbd47a0 FunDec:--- child:0x55972fbd4620 ID:main--- 0x55972fbd46a0 LP:(--- 0x55972fbd4720 RP:)--- +LC { +TYPE int +1: parent:0x55972fbd4920 Specifier:--- child:0x55972fbd48a0 TYPE:int--- +ID i +1: parent:0x55972fbd4a20 VarDec:--- child:0x55972fbd49a0 ID:i--- +ASSIGNOP = +INT 0123 +1: parent:0x55972fbd4ba0 Exp:--- child:0x55972fbd4b20 INT:0123--- +SEMI ; +3: parent:0x55972fbd4ca0 Dec:--- child:0x55972fbd4a20 VarDec:--- 0x55972fbd4aa0 ASSIGNOP:=--- 0x55972fbd4ba0 Exp:--- +1: parent:0x55972fbd4d20 DecList:--- child:0x55972fbd4ca0 Dec:--- +3: parent:0x55972fbd4da0 Def:--- child:0x55972fbd4920 Specifier:--- 0x55972fbd4d20 DecList:--- 0x55972fbd4c20 SEMI:;--- +TYPE int +1: parent:0x55972fbd4ea0 Specifier:--- child:0x55972fbd4e20 TYPE:int--- +ID j +1: parent:0x55972fbd4fa0 VarDec:--- child:0x55972fbd4f20 ID:j--- +ASSIGNOP = +INT 0x3F +1: parent:0x55972fbd5120 Exp:--- child:0x55972fbd50a0 INT:0x3F--- +SEMI ; +3: parent:0x55972fbd5220 Dec:--- child:0x55972fbd4fa0 VarDec:--- 0x55972fbd5020 ASSIGNOP:=--- 0x55972fbd5120 Exp:--- +1: parent:0x55972fbd52a0 DecList:--- child:0x55972fbd5220 Dec:--- +3: parent:0x55972fbd5320 Def:--- child:0x55972fbd4ea0 Specifier:--- 0x55972fbd52a0 DecList:--- 0x55972fbd51a0 SEMI:;--- +RC } +2: parent:0x55972fbd5420 DefList:--- child:0x55972fbd5320 Def:--- a nullptr--- +2: parent:0x55972fbd54a0 DefList:--- child:0x55972fbd4da0 Def:--- 0x55972fbd5420 DefList:--- +4: parent:0x55972fbd5520 CompSt:--- child:0x55972fbd4820 LC:{--- 0x55972fbd54a0 DefList:--- a nullptr--- 0x55972fbd53a0 RC:}--- +3: parent:0x55972fbd55a0 ExtDef:--- child:0x55972fbd45a0 Specifier:--- 0x55972fbd47a0 FunDec:--- 0x55972fbd5520 CompSt:--- +2: parent:0x55972fbd5620 ExtDefList:--- child:0x55972fbd55a0 ExtDef:--- a nullptr--- +1: parent:0x55972fbd56a0 Program:--- child:0x55972fbd5620 ExtDefList:--- +../Test/test1.cmm: +Program (1) + ExtDefList (1) + ExtDef (1) + Specifier (1) + TYPE: int + FunDec (1) + ID: main + LP + RP + CompSt (2) + LC + DefList (3) + Def (3) + Specifier (3) + TYPE: int + DecList (3) + Dec (3) + VarDec (3) + ID: i + ASSIGNOP + Exp (3) + INT: 83 + SEMI + DefList (4) + Def (4) + Specifier (4) + TYPE: int + DecList (4) + Dec (4) + VarDec (4) + ID: j + ASSIGNOP + Exp (4) + INT: 63 + SEMI + RC + + + +TYPE int +1: parent:0x55972fbd57a0 Specifier:--- child:0x55972fbd5720 TYPE:int--- +ID main +LP ( +RP ) +3: parent:0x55972fbd59a0 FunDec:--- child:0x55972fbd5820 ID:main--- 0x55972fbd58a0 LP:(--- 0x55972fbd5920 RP:)--- +LC { +TYPE int +1: parent:0x55972fbd5b20 Specifier:--- child:0x55972fbd5aa0 TYPE:int--- +ID i +1: parent:0x55972fbd5c20 VarDec:--- child:0x55972fbd5ba0 ID:i--- +ASSIGNOP = +INT 0 +1: parent:0x55972fbd5da0 Exp:--- child:0x55972fbd5d20 INT:0--- +INT 9 +3: parent:0x55972fbd5ea0 Dec:--- child:0x55972fbd5c20 VarDec:--- 0x55972fbd5ca0 ASSIGNOP:=--- 0x55972fbd5da0 Exp:--- +SEMI ; +TYPE int +ID j +1: parent:0x55972fbd60a0 VarDec:--- child:0x55972fbd6020 ID:j--- +ASSIGNOP = +INT 0x3 +1: parent:0x55972fbd6220 Exp:--- child:0x55972fbd61a0 INT:0x3--- +ID G +3: parent:0x55972fbd6320 Dec:--- child:0x55972fbd60a0 VarDec:--- 0x55972fbd6120 ASSIGNOP:=--- 0x55972fbd6220 Exp:--- +1: parent:0x55972fbd63a0 VarDec:--- child:0x55972fbd62a0 ID:G--- +SEMI ; +1: parent:0x55972fbd64a0 Dec:--- child:0x55972fbd63a0 VarDec:--- +1: parent:0x55972fbd6520 DecList:--- child:0x55972fbd64a0 Dec:--- +3: parent:0x55972fbd65a0 Def:--- child:0x55972fbd5b20 Specifier:--- a nullptr--- 0x55972fbd6420 SEMI:;--- +RC } +2: parent:0x55972fbd66a0 DefList:--- child:0x55972fbd65a0 Def:--- a nullptr--- +4: parent:0x55972fbd6720 CompSt:--- child:0x55972fbd5a20 LC:{--- 0x55972fbd66a0 DefList:--- a nullptr--- 0x55972fbd6620 RC:}--- +3: parent:0x55972fbd67a0 ExtDef:--- child:0x55972fbd57a0 Specifier:--- 0x55972fbd59a0 FunDec:--- 0x55972fbd6720 CompSt:--- +2: parent:0x55972fbd6820 ExtDefList:--- child:0x55972fbd67a0 ExtDef:--- a nullptr--- +1: parent:0x55972fbd68a0 Program:--- child:0x55972fbd6820 ExtDefList:--- +../Test/test2.cmm: +Program (1) + ExtDefList (1) + ExtDef (1) + Specifier (1) + TYPE: int + FunDec (1) + ID: main + LP + RP + CompSt (2) + LC + DefList (3) + Def (3) + Specifier (3) + TYPE: int + SEMI + RC + + + +TYPE int +1: parent:0x55972fbd69a0 Specifier:--- child:0x55972fbd6920 TYPE:int--- +ID main +LP ( +RP ) +3: parent:0x55972fbd6ba0 FunDec:--- child:0x55972fbd6a20 ID:main--- 0x55972fbd6aa0 LP:(--- 0x55972fbd6b20 RP:)--- +LC { +TYPE float +1: parent:0x55972fbd6d20 Specifier:--- child:0x55972fbd6ca0 TYPE:float--- +ID i +1: parent:0x55972fbd6e20 VarDec:--- child:0x55972fbd6da0 ID:i--- +ASSIGNOP = +FLOAT 1.05 +1: parent:0x55972fbd6fa0 Exp:--- child:0x55972fbd6f20 FLOAT:1.05--- +ID e +3: parent:0x55972fbd70a0 Dec:--- child:0x55972fbd6e20 VarDec:--- 0x55972fbd6ea0 ASSIGNOP:=--- 0x55972fbd6fa0 Exp:--- +1: parent:0x55972fbd7120 VarDec:--- child:0x55972fbd7020 ID:e--- +SEMI ; +1: parent:0x55972fbd7220 Dec:--- child:0x55972fbd7120 VarDec:--- +1: parent:0x55972fbd72a0 DecList:--- child:0x55972fbd7220 Dec:--- +3: parent:0x55972fbd7320 Def:--- child:0x55972fbd6d20 Specifier:--- a nullptr--- 0x55972fbd71a0 SEMI:;--- +RC } +2: parent:0x55972fbd7420 DefList:--- child:0x55972fbd7320 Def:--- a nullptr--- +4: parent:0x55972fbd74a0 CompSt:--- child:0x55972fbd6c20 LC:{--- 0x55972fbd7420 DefList:--- a nullptr--- 0x55972fbd73a0 RC:}--- +3: parent:0x55972fbd7520 ExtDef:--- child:0x55972fbd69a0 Specifier:--- 0x55972fbd6ba0 FunDec:--- 0x55972fbd74a0 CompSt:--- +2: parent:0x55972fbd75a0 ExtDefList:--- child:0x55972fbd7520 ExtDef:--- a nullptr--- +1: parent:0x55972fbd7620 Program:--- child:0x55972fbd75a0 ExtDefList:--- +../Test/test4.cmm: Syntax error:1 +TYPE int +1: parent:0x55972fbd7720 Specifier:--- child:0x55972fbd76a0 TYPE:int--- +ID main +LP ( +RP ) +3: parent:0x55972fbd7920 FunDec:--- child:0x55972fbd77a0 ID:main--- 0x55972fbd7820 LP:(--- 0x55972fbd78a0 RP:)--- +LC { +TYPE float +1: parent:0x55972fbd7aa0 Specifier:--- child:0x55972fbd7a20 TYPE:float--- +ID i +1: parent:0x55972fbd7ba0 VarDec:--- child:0x55972fbd7b20 ID:i--- +ASSIGNOP = +FLOAT 1.05e-4 +1: parent:0x55972fbd7d20 Exp:--- child:0x55972fbd7ca0 FLOAT:1.05e-4--- +SEMI ; +3: parent:0x55972fbd7e20 Dec:--- child:0x55972fbd7ba0 VarDec:--- 0x55972fbd7c20 ASSIGNOP:=--- 0x55972fbd7d20 Exp:--- +1: parent:0x55972fbd7ea0 DecList:--- child:0x55972fbd7e20 Dec:--- +3: parent:0x55972fbd7f20 Def:--- child:0x55972fbd7aa0 Specifier:--- 0x55972fbd7ea0 DecList:--- 0x55972fbd7da0 SEMI:;--- +RC } +2: parent:0x55972fbd8020 DefList:--- child:0x55972fbd7f20 Def:--- a nullptr--- +4: parent:0x55972fbd80a0 CompSt:--- child:0x55972fbd79a0 LC:{--- 0x55972fbd8020 DefList:--- a nullptr--- 0x55972fbd7fa0 RC:}--- +3: parent:0x55972fbd8120 ExtDef:--- child:0x55972fbd7720 Specifier:--- 0x55972fbd7920 FunDec:--- 0x55972fbd80a0 CompSt:--- +2: parent:0x55972fbd81a0 ExtDefList:--- child:0x55972fbd8120 ExtDef:--- a nullptr--- +1: parent:0x55972fbd8220 Program:--- child:0x55972fbd81a0 ExtDefList:--- +../Test/test3.cmm: Program (1) ExtDefList (1) ExtDef (1) Specifier (1) - StructSpecifier (1) - STRUCT - OptTag (1) - ID: Complex - LC - DefList (3) - Def (3) - Specifier (3) - TYPE: float - DecList (3) - Dec (3) - VarDec (3) - ID: real - COMMA - DecList (3) - Dec (3) - VarDec (3) - ID: image - SEMI - RC - SEMI - ExtDefList (5) - ExtDef (5) - Specifier (5) - TYPE: int - FunDec (5) - ID: main - LP - RP - CompSt (6) - LC - DefList (7) - Def (7) - Specifier (7) - StructSpecifier (7) - STRUCT - Tag (7) - ID: Complex - DecList (7) - Dec (7) - VarDec (7) - ID: x - SEMI - StmtList (8) - Stmt (8) - Exp (8) - Exp (8) - Exp (8) - ID: y - DOT - ID: image + TYPE: int + FunDec (1) + ID: main + LP + RP + CompSt (2) + LC + DefList (3) + Def (3) + Specifier (3) + TYPE: float + DecList (3) + Dec (3) + VarDec (3) + ID: i ASSIGNOP - Exp (8) - FLOAT: 3.500000 - SEMI - RC + Exp (3) + FLOAT: 0.000105 + SEMI + RC + + + +TYPE int +1: parent:0x55972fbd8320 Specifier:--- child:0x55972fbd82a0 TYPE:int--- +ID main +LP ( +RP ) +3: parent:0x55972fbd8520 FunDec:--- child:0x55972fbd83a0 ID:main--- 0x55972fbd8420 LP:(--- 0x55972fbd84a0 RP:)--- +LC { +TYPE int +1: parent:0x55972fbd86a0 Specifier:--- child:0x55972fbd8620 TYPE:int--- +ID i +1: parent:0x55972fbd87a0 VarDec:--- child:0x55972fbd8720 ID:i--- +ASSIGNOP = +INT 1 +1: parent:0x55972fbd8920 Exp:--- child:0x55972fbd88a0 INT:1--- +SEMI ; +3: parent:0x55972fbd8a20 Dec:--- child:0x55972fbd87a0 VarDec:--- 0x55972fbd8820 ASSIGNOP:=--- 0x55972fbd8920 Exp:--- +1: parent:0x55972fbd8aa0 DecList:--- child:0x55972fbd8a20 Dec:--- +3: parent:0x55972fbd8b20 Def:--- child:0x55972fbd86a0 Specifier:--- 0x55972fbd8aa0 DecList:--- 0x55972fbd89a0 SEMI:;--- +RC } +2: parent:0x55972fbd8c20 DefList:--- child:0x55972fbd8b20 Def:--- a nullptr--- +4: parent:0x55972fbd8ca0 CompSt:--- child:0x55972fbd85a0 LC:{--- 0x55972fbd8c20 DefList:--- a nullptr--- 0x55972fbd8ba0 RC:}--- +3: parent:0x55972fbd8d20 ExtDef:--- child:0x55972fbd8320 Specifier:--- 0x55972fbd8520 FunDec:--- 0x55972fbd8ca0 CompSt:--- +2: parent:0x55972fbd8da0 ExtDefList:--- child:0x55972fbd8d20 ExtDef:--- a nullptr--- +1: parent:0x55972fbd8e20 Program:--- child:0x55972fbd8da0 ExtDefList:--- +../Test/test5.cmm: +Program (1) + ExtDefList (1) + ExtDef (1) + Specifier (1) + TYPE: int + FunDec (1) + ID: main + LP + RP + CompSt (2) + LC + DefList (7) + Def (7) + Specifier (7) + TYPE: int + DecList (7) + Dec (7) + VarDec (7) + ID: i + ASSIGNOP + Exp (7) + INT: 1 + SEMI + RC + + + diff --git a/Code/data.c b/Code/data.c index e9caf1637cfd2b910e35fd0a2b546a2e37e2eb82..096d8890207d880d6a08b69775285fe44c378859 100644 --- a/Code/data.c +++ b/Code/data.c @@ -109,17 +109,17 @@ MultiwayTree_t * tree = &__Multiwaytree; Node_t * Operator(Node_t * cur,char * content,int line,int argc,...) { cur = tree->Node_alloc(content,line); - // printf("%d: parent:%p %s:%s--- child:",argc,cur,cur->content,cur->text); + printf("%d: parent:%p %s:%s--- child:",argc,cur,cur->content,cur->text); va_list ap; va_start(ap,argc); for (int i = 0;i < argc;i++) { Node_t * temp = (Node_t*)va_arg(ap,Node_t*); - if(temp == NULL) continue; - // printf("%p %s:%s--- ",temp,temp->content,temp->text); + if(temp == NULL) {printf("a nullptr--- "); continue; }; + printf("%p %s:%s--- ",temp,temp->content,temp->text); tree->rminsert(cur,temp); } va_end(ap); - // printf("\n"); + printf("\n"); return cur; } diff --git a/Code/debug.h b/Code/debug.h index 77344d78b23d93a9281d6726e4e188b36779a1ca..3bebb1cfee1e2b5ad1fc628f25d98b9c962a8b7f 100644 --- a/Code/debug.h +++ b/Code/debug.h @@ -19,8 +19,8 @@ #define LexicalError(format, ...) _Log("Error type A at Line %d: Mysterious characters \'%s\'\n", yylineno, yytext) #else #define _Log(...) fprintf(stderr,__VA_ARGS__); - #define SyntaxError(format, ...) _Log("\33[1;31m row=%d col=%d, " format "\33[0m\n",yylloc.first_line,yycolumn, ## __VA_ARGS__) - #define LexicalError(format, ...) _Log("\33[1;32m row=%d col=%d, " format "\33[0m\n",yylloc.first_line,yycolumn, ## __VA_ARGS__) + #define SyntaxError(format, ...) _Log("\33[1;31m row=%d col=%d, Syntax Error: " format "\33[0m\n",yylloc.first_line,yycolumn, ## __VA_ARGS__) + #define LexicalError(format, ...) _Log("\33[1;32m row=%d col=%d, Lexical Error: " format "\33[0m\n",yylloc.first_line,yycolumn, ## __VA_ARGS__) #endif #define Log(format, ...) \ diff --git a/Code/lex.yy.c b/Code/lex.yy.c index caf81a3f5a643412dd0dc8dc39796f8e8bdbce6b..4a7a3c2b2406a05c08ecad9ddfccf830acc1629d 100644 --- a/Code/lex.yy.c +++ b/Code/lex.yy.c @@ -352,8 +352,8 @@ static void yynoreturn yy_fatal_error ( const char* msg ); (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 31 -#define YY_END_OF_BUFFER 32 +#define YY_NUM_RULES 33 +#define YY_END_OF_BUFFER 34 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -361,17 +361,17 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[86] = +static const flex_int16_t yy_accept[88] = { 0, - 0, 0, 32, 30, 28, 29, 27, 20, 30, 21, - 22, 15, 13, 11, 14, 19, 16, 30, 30, 10, + 0, 0, 34, 32, 28, 29, 27, 20, 32, 21, + 22, 15, 13, 11, 14, 19, 16, 32, 32, 10, 12, 9, 23, 24, 9, 9, 9, 9, 9, 9, - 25, 30, 26, 17, 0, 0, 0, 8, 7, 8, - 7, 7, 7, 7, 9, 9, 9, 9, 3, 9, - 9, 9, 9, 18, 0, 8, 0, 0, 7, 0, - 9, 9, 6, 9, 9, 9, 0, 8, 0, 0, - 8, 7, 4, 9, 9, 9, 9, 0, 8, 9, - 9, 5, 2, 1, 0 + 25, 32, 26, 17, 0, 0, 0, 8, 31, 30, + 7, 8, 7, 7, 7, 7, 9, 9, 9, 9, + 3, 9, 9, 9, 9, 18, 0, 8, 0, 0, + 7, 0, 9, 9, 6, 9, 9, 9, 0, 8, + 0, 0, 8, 7, 4, 9, 9, 9, 9, 0, + 8, 9, 9, 5, 2, 1, 0 } ; static const YY_CHAR yy_ec[256] = @@ -415,98 +415,102 @@ static const YY_CHAR yy_meta[44] = 1, 1, 1 } ; -static const flex_int16_t yy_base[90] = +static const flex_int16_t yy_base[92] = { 0, - 0, 0, 209, 232, 232, 232, 232, 232, 201, 232, - 232, 232, 31, 232, 36, 39, 232, 44, 49, 232, - 232, 53, 232, 232, 65, 163, 41, 43, 12, 52, - 232, 153, 232, 232, 71, 79, 84, 87, 232, 90, - 97, 105, 0, 110, 0, 160, 91, 82, 151, 25, - 96, 97, 99, 232, 125, 128, 136, 143, 148, 153, - 121, 144, 122, 139, 146, 114, 171, 174, 182, 185, - 188, 0, 105, 129, 103, 178, 179, 198, 201, 142, - 186, 76, 60, 51, 232, 224, 226, 71, 228 + 0, 0, 211, 234, 234, 234, 234, 234, 203, 234, + 234, 234, 31, 234, 36, 39, 36, 44, 49, 234, + 234, 53, 234, 234, 65, 165, 41, 43, 25, 52, + 234, 155, 234, 234, 71, 79, 84, 87, 234, 234, + 234, 90, 97, 105, 0, 110, 0, 162, 91, 82, + 153, 96, 97, 100, 99, 234, 127, 130, 138, 145, + 150, 155, 123, 146, 124, 141, 148, 116, 173, 176, + 184, 187, 190, 0, 107, 131, 105, 180, 181, 200, + 203, 144, 188, 76, 60, 51, 234, 226, 228, 71, + 230 + } ; -static const flex_int16_t yy_def[90] = +static const flex_int16_t yy_def[92] = { 0, - 85, 1, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 86, 86, 85, - 85, 87, 85, 85, 87, 25, 25, 25, 25, 25, - 85, 85, 85, 85, 85, 86, 86, 85, 85, 85, - 85, 86, 88, 86, 89, 25, 25, 25, 25, 25, - 25, 25, 25, 85, 85, 85, 85, 85, 86, 86, - 25, 25, 25, 25, 25, 25, 85, 85, 85, 85, - 85, 60, 25, 25, 25, 25, 25, 85, 85, 25, - 25, 25, 25, 25, 0, 85, 85, 85, 85 + 87, 1, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 88, 88, 87, + 87, 89, 87, 87, 89, 25, 25, 25, 25, 25, + 87, 87, 87, 87, 87, 88, 88, 87, 87, 87, + 87, 87, 87, 88, 90, 88, 91, 25, 25, 25, + 25, 25, 25, 25, 25, 87, 87, 87, 87, 87, + 88, 88, 25, 25, 25, 25, 25, 25, 87, 87, + 87, 87, 87, 62, 25, 25, 25, 25, 25, 87, + 87, 25, 25, 25, 25, 25, 0, 87, 87, 87, + 87 + } ; -static const flex_int16_t yy_nxt[276] = +static const flex_int16_t yy_nxt[278] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 22, 22, 22, 23, 4, 24, 22, 22, 25, 26, 22, 27, 22, 22, 22, 28, 29, 22, 22, 30, - 31, 32, 33, 35, 46, 36, 37, 37, 35, 52, - 36, 37, 37, 38, 38, 38, 40, 46, 41, 42, - 41, 40, 63, 44, 44, 44, 43, 45, 45, 45, - 49, 51, 60, 46, 50, 46, 45, 45, 45, 45, - 45, 45, 53, 46, 46, 38, 38, 38, 45, 45, - 45, 40, 46, 41, 41, 41, 40, 47, 44, 44, - - 44, 38, 38, 38, 56, 56, 56, 55, 46, 40, - 57, 58, 58, 58, 46, 55, 62, 40, 57, 59, - 59, 41, 40, 46, 44, 44, 44, 61, 46, 46, - 66, 46, 65, 64, 67, 46, 67, 46, 80, 68, - 68, 68, 56, 56, 56, 70, 77, 70, 69, 73, - 71, 71, 71, 46, 46, 40, 69, 58, 58, 58, - 40, 46, 59, 59, 41, 85, 63, 72, 72, 72, - 74, 46, 72, 72, 46, 83, 46, 75, 46, 72, - 72, 72, 72, 46, 76, 68, 68, 68, 68, 68, - 68, 78, 46, 78, 54, 48, 79, 79, 79, 71, - - 71, 71, 71, 71, 71, 81, 34, 82, 85, 85, - 46, 46, 79, 79, 79, 79, 79, 79, 46, 85, - 85, 85, 85, 84, 39, 39, 39, 46, 46, 45, - 45, 3, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85 + 31, 32, 33, 35, 39, 36, 37, 37, 35, 40, + 36, 37, 37, 38, 38, 38, 42, 48, 43, 44, + 43, 42, 54, 46, 46, 46, 45, 47, 47, 47, + 51, 53, 62, 48, 52, 48, 47, 47, 47, 47, + 47, 47, 55, 48, 48, 38, 38, 38, 47, 47, + 47, 42, 48, 43, 43, 43, 42, 49, 46, 46, + + 46, 38, 38, 38, 58, 58, 58, 57, 48, 42, + 59, 60, 60, 60, 48, 57, 64, 42, 59, 61, + 61, 43, 42, 48, 46, 46, 46, 63, 48, 48, + 68, 48, 48, 65, 66, 67, 69, 48, 69, 48, + 82, 70, 70, 70, 58, 58, 58, 72, 79, 72, + 71, 75, 73, 73, 73, 48, 48, 42, 71, 60, + 60, 60, 42, 48, 61, 61, 43, 87, 65, 74, + 74, 74, 76, 48, 74, 74, 48, 85, 48, 77, + 48, 74, 74, 74, 74, 48, 78, 70, 70, 70, + 70, 70, 70, 80, 48, 80, 56, 50, 81, 81, + + 81, 73, 73, 73, 73, 73, 73, 83, 34, 84, + 87, 87, 48, 48, 81, 81, 81, 81, 81, 81, + 48, 87, 87, 87, 87, 86, 41, 41, 41, 48, + 48, 47, 47, 3, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87 } ; -static const flex_int16_t yy_chk[276] = +static const flex_int16_t yy_chk[278] = { 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, 1, 1, - 1, 1, 1, 13, 29, 13, 13, 13, 15, 29, - 15, 15, 15, 16, 16, 16, 18, 50, 18, 18, - 18, 19, 50, 19, 19, 19, 18, 22, 22, 22, - 27, 28, 88, 27, 27, 28, 22, 22, 22, 25, - 25, 25, 30, 84, 30, 35, 35, 35, 25, 25, - 25, 36, 83, 36, 36, 36, 37, 25, 37, 37, - - 37, 38, 38, 38, 40, 40, 40, 38, 82, 41, - 40, 41, 41, 41, 48, 38, 48, 42, 40, 42, - 42, 42, 44, 47, 44, 44, 44, 47, 51, 52, - 53, 53, 52, 51, 55, 75, 55, 73, 75, 55, - 55, 55, 56, 56, 56, 57, 66, 57, 56, 61, - 57, 57, 57, 61, 63, 58, 56, 58, 58, 58, - 59, 74, 59, 59, 59, 60, 74, 60, 60, 60, - 62, 64, 60, 60, 80, 80, 62, 64, 65, 60, - 60, 60, 60, 49, 65, 67, 67, 67, 68, 68, - 68, 69, 46, 69, 32, 26, 69, 69, 69, 70, - - 70, 70, 71, 71, 71, 76, 9, 77, 3, 0, - 76, 77, 78, 78, 78, 79, 79, 79, 81, 0, - 0, 0, 0, 81, 86, 86, 86, 87, 87, 89, - 89, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, - 85, 85, 85, 85, 85 + 1, 1, 1, 13, 17, 13, 13, 13, 15, 17, + 15, 15, 15, 16, 16, 16, 18, 29, 18, 18, + 18, 19, 29, 19, 19, 19, 18, 22, 22, 22, + 27, 28, 90, 27, 27, 28, 22, 22, 22, 25, + 25, 25, 30, 86, 30, 35, 35, 35, 25, 25, + 25, 36, 85, 36, 36, 36, 37, 25, 37, 37, + + 37, 38, 38, 38, 42, 42, 42, 38, 84, 43, + 42, 43, 43, 43, 50, 38, 50, 44, 42, 44, + 44, 44, 46, 49, 46, 46, 46, 49, 52, 53, + 55, 55, 54, 52, 53, 54, 57, 77, 57, 75, + 77, 57, 57, 57, 58, 58, 58, 59, 68, 59, + 58, 63, 59, 59, 59, 63, 65, 60, 58, 60, + 60, 60, 61, 76, 61, 61, 61, 62, 76, 62, + 62, 62, 64, 66, 62, 62, 82, 82, 64, 66, + 67, 62, 62, 62, 62, 51, 67, 69, 69, 69, + 70, 70, 70, 71, 48, 71, 32, 26, 71, 71, + + 71, 72, 72, 72, 73, 73, 73, 78, 9, 79, + 3, 0, 78, 79, 80, 80, 80, 81, 81, 81, + 83, 0, 0, 0, 0, 83, 88, 88, 88, 89, + 89, 91, 91, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 87, 87, 87, 87, 87, 87, 87 } ; static yy_state_type yy_last_accepting_state; @@ -531,9 +535,10 @@ char *yytext; #include "data.h" #include <string.h> + int Iscomments = 0; static Node_t* add_node_text(char * content,char *text,int len); -#line 535 "./lex.yy.c" -#line 536 "./lex.yy.c" +#line 540 "./lex.yy.c" +#line 541 "./lex.yy.c" #define INITIAL 0 @@ -750,9 +755,9 @@ YY_DECL } { -#line 39 "./lexical.l" +#line 42 "./lexical.l" -#line 755 "./lex.yy.c" +#line 760 "./lex.yy.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -779,13 +784,13 @@ yy_match: 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 >= 86 ) + if ( yy_current_state >= 88 ) 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] != 232 ); + while ( yy_base[yy_current_state] != 234 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -811,162 +816,190 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 40 "./lexical.l" +#line 43 "./lexical.l" { ELEMENT("STRUCT"); return STRUCT; } YY_BREAK case 2: YY_RULE_SETUP -#line 41 "./lexical.l" +#line 44 "./lexical.l" { ELEMENT("RETURN"); return RETURN; } YY_BREAK case 3: YY_RULE_SETUP -#line 42 "./lexical.l" +#line 45 "./lexical.l" { ELEMENT("IF"); return IF; } YY_BREAK case 4: YY_RULE_SETUP -#line 43 "./lexical.l" +#line 46 "./lexical.l" { ELEMENT("ELSE"); return ELSE; } YY_BREAK case 5: YY_RULE_SETUP -#line 44 "./lexical.l" +#line 47 "./lexical.l" { ELEMENT("WHILE"); return WHILE; } YY_BREAK case 6: YY_RULE_SETUP -#line 45 "./lexical.l" +#line 48 "./lexical.l" { ELEMENT("TYPE"); return TYPE; } YY_BREAK case 7: /* rule 7 can match eol */ YY_RULE_SETUP -#line 46 "./lexical.l" +#line 49 "./lexical.l" { unput(yytext[yyleng-1]); yycolumn--,yytext[yyleng-1] = 0;ELEMENT("INT"); return INT;} YY_BREAK case 8: YY_RULE_SETUP -#line 47 "./lexical.l" +#line 50 "./lexical.l" { ELEMENT("FLOAT"); return FLOAT;} YY_BREAK case 9: YY_RULE_SETUP -#line 48 "./lexical.l" +#line 51 "./lexical.l" { ELEMENT("ID"); return ID; } YY_BREAK case 10: YY_RULE_SETUP -#line 49 "./lexical.l" +#line 52 "./lexical.l" { ELEMENT("SEMI"); return SEMI;} YY_BREAK case 11: YY_RULE_SETUP -#line 50 "./lexical.l" +#line 53 "./lexical.l" { ELEMENT("COMMA"); return COMMA;} YY_BREAK case 12: YY_RULE_SETUP -#line 51 "./lexical.l" +#line 54 "./lexical.l" { ELEMENT("ASSIGNOP"); return ASSIGNOP;} YY_BREAK case 13: YY_RULE_SETUP -#line 52 "./lexical.l" +#line 55 "./lexical.l" { ELEMENT("PLUS"); return PLUS;} YY_BREAK case 14: YY_RULE_SETUP -#line 53 "./lexical.l" +#line 56 "./lexical.l" { ELEMENT("MINUS"); return MINUS;} YY_BREAK case 15: YY_RULE_SETUP -#line 54 "./lexical.l" +#line 57 "./lexical.l" { ELEMENT("STAR"); return STAR;} YY_BREAK case 16: YY_RULE_SETUP -#line 55 "./lexical.l" +#line 58 "./lexical.l" { ELEMENT("DIV"); return DIV;} YY_BREAK case 17: YY_RULE_SETUP -#line 56 "./lexical.l" +#line 59 "./lexical.l" { ELEMENT("AND"); return AND;} YY_BREAK case 18: YY_RULE_SETUP -#line 57 "./lexical.l" +#line 60 "./lexical.l" { ELEMENT("OR"); return OR;} YY_BREAK case 19: YY_RULE_SETUP -#line 58 "./lexical.l" +#line 61 "./lexical.l" { ELEMENT("DOT"); return DOT;} YY_BREAK case 20: YY_RULE_SETUP -#line 59 "./lexical.l" +#line 62 "./lexical.l" { ELEMENT("NOT"); return NOT;} YY_BREAK case 21: YY_RULE_SETUP -#line 60 "./lexical.l" +#line 63 "./lexical.l" { ELEMENT("LP"); return LP;} YY_BREAK case 22: YY_RULE_SETUP -#line 61 "./lexical.l" +#line 64 "./lexical.l" { ELEMENT("RP"); return RP;} YY_BREAK case 23: YY_RULE_SETUP -#line 62 "./lexical.l" +#line 65 "./lexical.l" { ELEMENT("LB"); return LB;} YY_BREAK case 24: YY_RULE_SETUP -#line 63 "./lexical.l" +#line 66 "./lexical.l" { ELEMENT("RB"); return RB;} YY_BREAK case 25: YY_RULE_SETUP -#line 64 "./lexical.l" +#line 67 "./lexical.l" { ELEMENT("LC"); return LC;} YY_BREAK case 26: YY_RULE_SETUP -#line 65 "./lexical.l" +#line 68 "./lexical.l" { ELEMENT("RC"); return RC;} YY_BREAK case 27: YY_RULE_SETUP -#line 66 "./lexical.l" +#line 69 "./lexical.l" { strcat(linetext," ");} YY_BREAK case 28: YY_RULE_SETUP -#line 67 "./lexical.l" +#line 70 "./lexical.l" { yycolumn += 3; strcat(linetext,"\t");} YY_BREAK case 29: /* rule 29 can match eol */ YY_RULE_SETUP -#line 68 "./lexical.l" +#line 71 "./lexical.l" { yycolumn = 1; yylineno += 1; linetext[0] = '\0'; } YY_BREAK case 30: YY_RULE_SETUP -#line 69 "./lexical.l" -{ LexicalError("Lexical Error: %s",yytext); } +#line 72 "./lexical.l" +{ char c = input(); while(c != '\n') { c = input(); } yylineno += 1; } YY_BREAK case 31: YY_RULE_SETUP -#line 71 "./lexical.l" +#line 73 "./lexical.l" +{ + char c1 = input(),c2 = input(); + if (c1 == '\n') { + yylineno += 1; + yycolumn = 1; + } else { + yycolumn += 1; + } + while (c1 != '*' || c2 != '/') { + if (c2 == '\n') { + yylineno += 1; + yycolumn = 1; + } else { + yycolumn += 1; + } + c1 = c2; + c2 = input(); + } + } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 92 "./lexical.l" +{ LexicalError("%s",yytext); } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 94 "./lexical.l" ECHO; YY_BREAK -#line 969 "./lex.yy.c" +#line 1002 "./lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1263,7 +1296,7 @@ static int yy_get_next_buffer (void) 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 >= 86 ) + if ( yy_current_state >= 88 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1291,11 +1324,11 @@ static int yy_get_next_buffer (void) 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 >= 86 ) + if ( yy_current_state >= 88 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 85); + yy_is_jam = (yy_current_state == 87); return yy_is_jam ? 0 : yy_current_state; } @@ -1971,20 +2004,20 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 71 "./lexical.l" +#line 94 "./lexical.l" extern int syntax; void yyerror(char* msg) { syntax++; - SyntaxError("%s : %s\n\t%s\n", msg,yytext,linetext); + SyntaxError("%s\n\t%s\n",yytext,linetext); } static Node_t* add_node_text(char * content,char *text,int len) { Node_t * cur = tree->Node_alloc(content,yylloc.first_line); strncpy(cur->text,text,len); - // printf("%s %s\n",content,text); + printf("%s %s\n",content,text); return cur; } diff --git a/Code/lexical.l b/Code/lexical.l index b0f1fafb1800866d0ca20e95dbd721f4f28d04d5..d2e06158cc2ca893bcde985205d34a696bc8941b 100755 --- a/Code/lexical.l +++ b/Code/lexical.l @@ -5,6 +5,7 @@ #include "data.h" #include <string.h> + int Iscomments = 0; static Node_t* add_node_text(char * content,char *text,int len); %} @@ -35,6 +36,8 @@ RETURN return IF if ELSE else WHILE while +LINECOMMENT "//" +LCOMMENTS "/*" %% {STRUCT} { ELEMENT("STRUCT"); return STRUCT; } @@ -66,7 +69,27 @@ WHILE while [ ] { strcat(linetext," ");} [\t] { yycolumn += 3; strcat(linetext,"\t");} [\n] { yycolumn = 1; yylineno += 1; linetext[0] = '\0'; } -. { LexicalError("Lexical Error: %s",yytext); } +{LINECOMMENT} { char c = input(); while(c != '\n') { c = input(); } yylineno += 1; } +{LCOMMENTS} { + char c1 = input(),c2 = input(); + if (c1 == '\n') { + yylineno += 1; + yycolumn = 1; + } else { + yycolumn += 1; + } + while (c1 != '*' || c2 != '/') { + if (c2 == '\n') { + yylineno += 1; + yycolumn = 1; + } else { + yycolumn += 1; + } + c1 = c2; + c2 = input(); + } + } +. { LexicalError("%s",yytext); } %% @@ -74,13 +97,13 @@ extern int syntax; void yyerror(char* msg) { syntax++; - SyntaxError("%s : %s\n\t%s\n", msg,yytext,linetext); + SyntaxError("%s\n\t%s\n",yytext,linetext); } static Node_t* add_node_text(char * content,char *text,int len) { Node_t * cur = tree->Node_alloc(content,yylloc.first_line); strncpy(cur->text,text,len); - // printf("%s %s\n",content,text); + printf("%s %s\n",content,text); return cur; } diff --git a/Code/main.c b/Code/main.c index 5c493f2bd851c2e462bbe4d1b556b47693a67727..7f9d5889726809277fd98e53252921daae0843f8 100755 --- a/Code/main.c +++ b/Code/main.c @@ -15,6 +15,7 @@ int main(int argc,char *argv[]) { printf("Usage:%s $FILE\n",argv[0]); } for (int i = 1;i < argc;i++) { + Log("%s:\n\n\n",argv[i]); syntax = 0; yycolumn = 1; yylineno = 1; @@ -26,14 +27,19 @@ int main(int argc,char *argv[]) { yyrestart(f); yyparse(); fclose(f); + #ifndef FINAL + printf("%s:\n",argv[i]); + #endif if (syntax == 1) { #ifndef FINAL printf("Syntax error:%d\n",syntax); - printf("\n\n\n"); #endif } else { tree->traverse(tree->root,0); } + #ifndef FINAL + printf("\n\n\n"); + #endif } return 0; } diff --git a/Code/parser b/Code/parser index 744cd3321bbe9debcc238ecefb365dafe3c93c1b..cef33f2d9779ca3391845be764cfc8047b96b55a 100755 Binary files a/Code/parser and b/Code/parser differ diff --git a/Code/syntax.output b/Code/syntax.output index dbcb518c2babb9f6b1dd98473db01cda8c48feef..641fc2540494d1972e877fa2aaead0399bc57201 100644 --- a/Code/syntax.output +++ b/Code/syntax.output @@ -57,59 +57,60 @@ 37 DecList: Dec 38 | Dec COMMA DecList - - 39 Dec: VarDec - 40 | VarDec ASSIGNOP Exp - - 41 Exp: Exp ASSIGNOP Exp - 42 | Exp AND Exp - 43 | Exp OR Exp - 44 | Exp RELOP Exp - 45 | Exp PLUS Exp - 46 | Exp MINUS Exp - 47 | Exp STAR Exp - 48 | Exp DIV Exp - 49 | LP Exp RP - 50 | MINUS Exp - 51 | NOT Exp - 52 | ID LP Args RP - 53 | ID LP RP - 54 | Exp LB Exp RB - 55 | Exp DOT ID - 56 | ID - 57 | INT - 58 | FLOAT - 59 | Exp PLUS error - - 60 Args: Exp COMMA Args - 61 | Exp - 62 | error Args + 39 | Dec error DecList + + 40 Dec: VarDec + 41 | VarDec ASSIGNOP Exp + + 42 Exp: Exp ASSIGNOP Exp + 43 | Exp AND Exp + 44 | Exp OR Exp + 45 | Exp RELOP Exp + 46 | Exp PLUS Exp + 47 | Exp MINUS Exp + 48 | Exp STAR Exp + 49 | Exp DIV Exp + 50 | LP Exp RP + 51 | MINUS Exp + 52 | NOT Exp + 53 | ID LP Args RP + 54 | ID LP RP + 55 | Exp LB Exp RB + 56 | Exp DOT ID + 57 | ID + 58 | INT + 59 | FLOAT + 60 | Exp PLUS error + + 61 Args: Exp COMMA Args + 62 | Exp + 63 | error Args 缁堢粨璇瘝锛岄檮鏈夊畠浠嚭鐜板鐨勮鍒� $end (0) 0 - error <node> (256) 24 33 59 62 - INT <node> (258) 17 57 - FLOAT <node> (259) 58 - ID <node> (260) 13 15 16 18 19 52 53 55 56 + error <node> (256) 24 33 39 60 63 + INT <node> (258) 17 58 + FLOAT <node> (259) 59 + ID <node> (260) 13 15 16 18 19 53 54 56 57 SEMI <node> (261) 4 5 27 29 33 36 - COMMA <node> (262) 8 20 38 60 - ASSIGNOP <node> (263) 40 41 - RELOP <node> (264) 44 - PLUS <node> (265) 45 59 - MINUS <node> (266) 46 50 - STAR <node> (267) 47 - DIV <node> (268) 48 - AND <node> (269) 42 - OR <node> (270) 43 - DOT <node> (271) 55 - NOT <node> (272) 51 + COMMA <node> (262) 8 20 38 61 + ASSIGNOP <node> (263) 41 42 + RELOP <node> (264) 45 + PLUS <node> (265) 46 60 + MINUS <node> (266) 47 51 + STAR <node> (267) 48 + DIV <node> (268) 49 + AND <node> (269) 43 + OR <node> (270) 44 + DOT <node> (271) 56 + NOT <node> (272) 52 TYPE <node> (273) 9 - LP <node> (274) 18 19 30 31 32 49 52 53 - RP <node> (275) 18 19 30 31 32 49 52 53 - LB <node> (276) 17 54 - RB <node> (277) 17 54 + LP <node> (274) 18 19 30 31 32 50 53 54 + RP <node> (275) 18 19 30 31 32 50 53 54 + LB <node> (276) 17 55 + RB <node> (277) 17 55 LC <node> (278) 11 23 RC <node> (279) 11 23 24 STRUCT <node> (280) 11 12 @@ -150,7 +151,7 @@ on right: 12 VarDec <node> (40) on left: 16 17 - on right: 7 8 17 22 39 40 + on right: 7 8 17 22 40 41 FunDec <node> (41) on left: 18 19 on right: 6 @@ -176,17 +177,17 @@ on left: 36 on right: 34 DecList <node> (49) - on left: 37 38 - on right: 36 38 + on left: 37 38 39 + on right: 36 38 39 Dec <node> (50) - on left: 39 40 - on right: 37 38 + on left: 40 41 + on right: 37 38 39 Exp <node> (51) - on left: 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 - on right: 27 29 30 31 32 40 41 42 43 44 45 46 47 48 49 50 51 54 55 59 60 61 + on left: 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 + on right: 27 29 30 31 32 41 42 43 44 45 46 47 48 49 50 51 52 55 56 60 61 62 Args <node> (52) - on left: 60 61 62 - on right: 52 60 62 + on left: 61 62 63 + on right: 53 61 63 鐘舵€� 0 @@ -563,13 +564,13 @@ 鐘舵€� 38 17 VarDec: VarDec 鈥� LB INT RB - 39 Dec: VarDec 鈥� - 40 | VarDec 鈥� ASSIGNOP Exp + 40 Dec: VarDec 鈥� + 41 | VarDec 鈥� ASSIGNOP Exp ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 61 LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 22 - $default 浣跨敤瑙勫垯 39 浠ュ綊绾� (Dec) + $default 浣跨敤瑙勫垯 40 浠ュ綊绾� (Dec) 鐘舵€� 39 @@ -583,10 +584,12 @@ 37 DecList: Dec 鈥� 38 | Dec 鈥� COMMA DecList + 39 | Dec 鈥� error DecList - COMMA 鍋忕Щ锛屽苟杩涘叆鐘舵€� 63 + error 鍋忕Щ锛屽苟杩涘叆鐘舵€� 63 + COMMA 鍋忕Щ锛屽苟杩涘叆鐘舵€� 64 - $default 浣跨敤瑙勫垯 37 浠ュ綊绾� (DecList) + SEMI 浣跨敤瑙勫垯 37 浠ュ綊绾� (DecList) 鐘舵€� 41 @@ -629,7 +632,7 @@ Specifier 杞埌鐘舵€� 30 StructSpecifier 杞埌鐘舵€� 7 - VarList 杞埌鐘舵€� 64 + VarList 杞埌鐘舵€� 65 ParamDec 杞埌鐘舵€� 32 @@ -645,38 +648,38 @@ 24 CompSt: error 鈥� RC 33 Stmt: error 鈥� SEMI - SEMI 鍋忕Щ锛屽苟杩涘叆鐘舵€� 65 + SEMI 鍋忕Щ锛屽苟杩涘叆鐘舵€� 66 RC 鍋忕Щ锛屽苟杩涘叆鐘舵€� 36 鐘舵€� 48 - 57 Exp: INT 鈥� + 58 Exp: INT 鈥� - $default 浣跨敤瑙勫垯 57 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 58 浠ュ綊绾� (Exp) 鐘舵€� 49 - 58 Exp: FLOAT 鈥� + 59 Exp: FLOAT 鈥� - $default 浣跨敤瑙勫垯 58 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 59 浠ュ綊绾� (Exp) 鐘舵€� 50 - 52 Exp: ID 鈥� LP Args RP - 53 | ID 鈥� LP RP - 56 | ID 鈥� + 53 Exp: ID 鈥� LP Args RP + 54 | ID 鈥� LP RP + 57 | ID 鈥� - LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 66 + LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 67 - $default 浣跨敤瑙勫垯 56 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 57 浠ュ綊绾� (Exp) 鐘舵€� 51 - 50 Exp: MINUS 鈥� Exp + 51 Exp: MINUS 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -685,12 +688,12 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 67 + Exp 杞埌鐘舵€� 68 鐘舵€� 52 - 51 Exp: NOT 鈥� Exp + 52 Exp: NOT 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -699,12 +702,12 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 68 + Exp 杞埌鐘舵€� 69 鐘舵€� 53 - 49 Exp: LP 鈥� Exp RP + 50 Exp: LP 鈥� Exp RP INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -713,7 +716,7 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 69 + Exp 杞埌鐘舵€� 70 鐘舵€� 54 @@ -727,7 +730,7 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 70 + Exp 杞埌鐘舵€� 71 鐘舵€� 55 @@ -735,14 +738,14 @@ 30 Stmt: IF 鈥� LP Exp RP Stmt 31 | IF 鈥� LP Exp RP Stmt ELSE Stmt - LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 71 + LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 72 鐘舵€� 56 32 Stmt: WHILE 鈥� LP Exp RP Stmt - LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 72 + LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 73 鐘舵€� 57 @@ -756,7 +759,7 @@ 23 CompSt: LC DefList StmtList 鈥� RC - RC 鍋忕Щ锛屽苟杩涘叆鐘舵€� 73 + RC 鍋忕Щ锛屽苟杩涘叆鐘舵€� 74 鐘舵€� 59 @@ -778,7 +781,7 @@ RC 浣跨敤瑙勫垯 26 浠ュ綊绾� (StmtList) CompSt 杞埌鐘舵€� 57 - StmtList 杞埌鐘舵€� 74 + StmtList 杞埌鐘舵€� 75 Stmt 杞埌鐘舵€� 59 Exp 杞埌鐘舵€� 60 @@ -786,34 +789,34 @@ 鐘舵€� 60 27 Stmt: Exp 鈥� SEMI - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - SEMI 鍋忕Щ锛屽苟杩涘叆鐘舵€� 75 - ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + SEMI 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 + ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 鐘舵€� 61 - 40 Dec: VarDec ASSIGNOP 鈥� Exp + 41 Dec: VarDec ASSIGNOP 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -822,7 +825,7 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 86 + Exp 杞埌鐘舵€� 87 鐘舵€� 62 @@ -834,149 +837,160 @@ 鐘舵€� 63 - 38 DecList: Dec COMMA 鈥� DecList + 39 DecList: Dec error 鈥� DecList ID 鍋忕Щ锛屽苟杩涘叆鐘舵€� 33 VarDec 杞埌鐘舵€� 38 - DecList 杞埌鐘舵€� 87 + DecList 杞埌鐘舵€� 88 Dec 杞埌鐘舵€� 40 鐘舵€� 64 + 38 DecList: Dec COMMA 鈥� DecList + + ID 鍋忕Щ锛屽苟杩涘叆鐘舵€� 33 + + VarDec 杞埌鐘舵€� 38 + DecList 杞埌鐘舵€� 89 + Dec 杞埌鐘舵€� 40 + + +鐘舵€� 65 + 20 VarList: ParamDec COMMA VarList 鈥� $default 浣跨敤瑙勫垯 20 浠ュ綊绾� (VarList) -鐘舵€� 65 +鐘舵€� 66 33 Stmt: error SEMI 鈥� $default 浣跨敤瑙勫垯 33 浠ュ綊绾� (Stmt) -鐘舵€� 66 +鐘舵€� 67 - 52 Exp: ID LP 鈥� Args RP - 53 | ID LP 鈥� RP + 53 Exp: ID LP 鈥� Args RP + 54 | ID LP 鈥� RP - error 鍋忕Щ锛屽苟杩涘叆鐘舵€� 88 + error 鍋忕Щ锛屽苟杩涘叆鐘舵€� 90 INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 ID 鍋忕Щ锛屽苟杩涘叆鐘舵€� 50 MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 51 NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 89 - - Exp 杞埌鐘舵€� 90 - Args 杞埌鐘舵€� 91 - - -鐘舵€� 67 - - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 50 | MINUS Exp 鈥� - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 91 - $default 浣跨敤瑙勫垯 50 浠ュ綊绾� (Exp) + Exp 杞埌鐘舵€� 92 + Args 杞埌鐘舵€� 93 鐘舵€� 68 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 51 | NOT Exp 鈥� - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 51 | MINUS Exp 鈥� + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 $default 浣跨敤瑙勫垯 51 浠ュ綊绾� (Exp) 鐘舵€� 69 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 49 | LP Exp 鈥� RP - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 92 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 52 | NOT Exp 鈥� + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 + + $default 浣跨敤瑙勫垯 52 浠ュ綊绾� (Exp) 鐘舵€� 70 - 29 Stmt: RETURN Exp 鈥� SEMI - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - SEMI 鍋忕Щ锛屽苟杩涘叆鐘舵€� 93 - ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 50 | LP Exp 鈥� RP + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 94 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 鐘舵€� 71 + 29 Stmt: RETURN Exp 鈥� SEMI + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + SEMI 鍋忕Щ锛屽苟杩涘叆鐘舵€� 95 + ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 + + +鐘舵€� 72 + 30 Stmt: IF LP 鈥� Exp RP Stmt 31 | IF LP 鈥� Exp RP Stmt ELSE Stmt @@ -987,10 +1001,10 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 94 + Exp 杞埌鐘舵€� 96 -鐘舵€� 72 +鐘舵€� 73 32 Stmt: WHILE LP 鈥� Exp RP Stmt @@ -1001,33 +1015,33 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 95 + Exp 杞埌鐘舵€� 97 -鐘舵€� 73 +鐘舵€� 74 23 CompSt: LC DefList StmtList RC 鈥� $default 浣跨敤瑙勫垯 23 浠ュ綊绾� (CompSt) -鐘舵€� 74 +鐘舵€� 75 25 StmtList: Stmt StmtList 鈥� $default 浣跨敤瑙勫垯 25 浠ュ綊绾� (StmtList) -鐘舵€� 75 +鐘舵€� 76 27 Stmt: Exp SEMI 鈥� $default 浣跨敤瑙勫垯 27 浠ュ綊绾� (Stmt) -鐘舵€� 76 +鐘舵€� 77 - 41 Exp: Exp ASSIGNOP 鈥� Exp + 42 Exp: Exp ASSIGNOP 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -1036,12 +1050,12 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 96 + Exp 杞埌鐘舵€� 98 -鐘舵€� 77 +鐘舵€� 78 - 44 Exp: Exp RELOP 鈥� Exp + 45 Exp: Exp RELOP 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -1050,15 +1064,15 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 97 + Exp 杞埌鐘舵€� 99 -鐘舵€� 78 +鐘舵€� 79 - 45 Exp: Exp PLUS 鈥� Exp - 59 | Exp PLUS 鈥� error + 46 Exp: Exp PLUS 鈥� Exp + 60 | Exp PLUS 鈥� error - error 鍋忕Щ锛屽苟杩涘叆鐘舵€� 98 + error 鍋忕Щ锛屽苟杩涘叆鐘舵€� 100 INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 ID 鍋忕Щ锛屽苟杩涘叆鐘舵€� 50 @@ -1066,12 +1080,12 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 99 + Exp 杞埌鐘舵€� 101 -鐘舵€� 79 +鐘舵€� 80 - 46 Exp: Exp MINUS 鈥� Exp + 47 Exp: Exp MINUS 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -1080,12 +1094,12 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 100 + Exp 杞埌鐘舵€� 102 -鐘舵€� 80 +鐘舵€� 81 - 47 Exp: Exp STAR 鈥� Exp + 48 Exp: Exp STAR 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -1094,12 +1108,12 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 101 + Exp 杞埌鐘舵€� 103 -鐘舵€� 81 +鐘舵€� 82 - 48 Exp: Exp DIV 鈥� Exp + 49 Exp: Exp DIV 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -1108,12 +1122,12 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 102 + Exp 杞埌鐘舵€� 104 -鐘舵€� 82 +鐘舵€� 83 - 42 Exp: Exp AND 鈥� Exp + 43 Exp: Exp AND 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -1122,12 +1136,12 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 103 + Exp 杞埌鐘舵€� 105 -鐘舵€� 83 +鐘舵€� 84 - 43 Exp: Exp OR 鈥� Exp + 44 Exp: Exp OR 鈥� Exp INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -1136,19 +1150,19 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 104 + Exp 杞埌鐘舵€� 106 -鐘舵€� 84 +鐘舵€� 85 - 55 Exp: Exp DOT 鈥� ID + 56 Exp: Exp DOT 鈥� ID - ID 鍋忕Щ锛屽苟杩涘叆鐘舵€� 105 + ID 鍋忕Щ锛屽苟杩涘叆鐘舵€� 107 -鐘舵€� 85 +鐘舵€� 86 - 54 Exp: Exp LB 鈥� Exp RB + 55 Exp: Exp LB 鈥� Exp RB INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 @@ -1157,50 +1171,57 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 106 + Exp 杞埌鐘舵€� 108 -鐘舵€� 86 +鐘舵€� 87 - 40 Dec: VarDec ASSIGNOP Exp 鈥� - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 41 Dec: VarDec ASSIGNOP Exp 鈥� + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 + + $default 浣跨敤瑙勫垯 41 浠ュ綊绾� (Dec) - $default 浣跨敤瑙勫垯 40 浠ュ綊绾� (Dec) +鐘舵€� 88 + + 39 DecList: Dec error DecList 鈥� + + $default 浣跨敤瑙勫垯 39 浠ュ綊绾� (DecList) -鐘舵€� 87 + +鐘舵€� 89 38 DecList: Dec COMMA DecList 鈥� $default 浣跨敤瑙勫垯 38 浠ュ綊绾� (DecList) -鐘舵€� 88 +鐘舵€� 90 - 62 Args: error 鈥� Args + 63 Args: error 鈥� Args - error 鍋忕Щ锛屽苟杩涘叆鐘舵€� 88 + error 鍋忕Щ锛屽苟杩涘叆鐘舵€� 90 INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 ID 鍋忕Щ锛屽苟杩涘叆鐘舵€� 50 @@ -1208,378 +1229,378 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 90 - Args 杞埌鐘舵€� 107 - - -鐘舵€� 89 - - 53 Exp: ID LP RP 鈥� - - $default 浣跨敤瑙勫垯 53 浠ュ綊绾� (Exp) - - -鐘舵€� 90 - - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - 60 Args: Exp 鈥� COMMA Args - 61 | Exp 鈥� - - COMMA 鍋忕Щ锛屽苟杩涘叆鐘舵€� 108 - ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 - - $default 浣跨敤瑙勫垯 61 浠ュ綊绾� (Args) + Exp 杞埌鐘舵€� 92 + Args 杞埌鐘舵€� 109 鐘舵€� 91 - 52 Exp: ID LP Args 鈥� RP + 54 Exp: ID LP RP 鈥� - RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 109 + $default 浣跨敤瑙勫垯 54 浠ュ綊绾� (Exp) 鐘舵€� 92 - 49 Exp: LP Exp RP 鈥� + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + 61 Args: Exp 鈥� COMMA Args + 62 | Exp 鈥� + + COMMA 鍋忕Щ锛屽苟杩涘叆鐘舵€� 110 + ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 - $default 浣跨敤瑙勫垯 49 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 62 浠ュ綊绾� (Args) 鐘舵€� 93 - 29 Stmt: RETURN Exp SEMI 鈥� + 53 Exp: ID LP Args 鈥� RP - $default 浣跨敤瑙勫垯 29 浠ュ綊绾� (Stmt) + RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 111 鐘舵€� 94 - 30 Stmt: IF LP Exp 鈥� RP Stmt - 31 | IF LP Exp 鈥� RP Stmt ELSE Stmt - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 110 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 50 Exp: LP Exp RP 鈥� + + $default 浣跨敤瑙勫垯 50 浠ュ綊绾� (Exp) 鐘舵€� 95 - 32 Stmt: WHILE LP Exp 鈥� RP Stmt - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 111 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 29 Stmt: RETURN Exp SEMI 鈥� + + $default 浣跨敤瑙勫垯 29 浠ュ綊绾� (Stmt) 鐘舵€� 96 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 41 | Exp ASSIGNOP Exp 鈥� - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 - - $default 浣跨敤瑙勫垯 41 浠ュ綊绾� (Exp) + 30 Stmt: IF LP Exp 鈥� RP Stmt + 31 | IF LP Exp 鈥� RP Stmt ELSE Stmt + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 112 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 鐘舵€� 97 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 44 | Exp RELOP Exp 鈥� - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 - - $default 浣跨敤瑙勫垯 44 浠ュ綊绾� (Exp) + 32 Stmt: WHILE LP Exp 鈥� RP Stmt + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + RP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 113 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 鐘舵€� 98 - 59 Exp: Exp PLUS error 鈥� + 42 Exp: Exp 鈥� ASSIGNOP Exp + 42 | Exp ASSIGNOP Exp 鈥� + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 - $default 浣跨敤瑙勫垯 59 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 42 浠ュ綊绾� (Exp) 鐘舵€� 99 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 45 | Exp PLUS Exp 鈥� - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 45 | Exp RELOP Exp 鈥� + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 $default 浣跨敤瑙勫垯 45 浠ュ綊绾� (Exp) 鐘舵€� 100 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 46 | Exp MINUS Exp 鈥� - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 60 Exp: Exp PLUS error 鈥� - $default 浣跨敤瑙勫垯 46 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 60 浠ュ綊绾� (Exp) 鐘舵€� 101 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 47 | Exp STAR Exp 鈥� - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 46 | Exp PLUS Exp 鈥� + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 - $default 浣跨敤瑙勫垯 47 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 46 浠ュ綊绾� (Exp) 鐘舵€� 102 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 48 | Exp DIV Exp 鈥� - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 47 | Exp MINUS Exp 鈥� + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 - $default 浣跨敤瑙勫垯 48 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 47 浠ュ綊绾� (Exp) 鐘舵€� 103 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 42 | Exp AND Exp 鈥� - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 48 | Exp STAR Exp 鈥� + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 - $default 浣跨敤瑙勫垯 42 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 48 浠ュ綊绾� (Exp) 鐘舵€� 104 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 43 | Exp OR Exp 鈥� - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 49 | Exp DIV Exp 鈥� + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 - $default 浣跨敤瑙勫垯 43 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 49 浠ュ綊绾� (Exp) 鐘舵€� 105 - 55 Exp: Exp DOT ID 鈥� + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 43 | Exp AND Exp 鈥� + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 - $default 浣跨敤瑙勫垯 55 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 43 浠ュ綊绾� (Exp) 鐘舵€� 106 - 41 Exp: Exp 鈥� ASSIGNOP Exp - 42 | Exp 鈥� AND Exp - 43 | Exp 鈥� OR Exp - 44 | Exp 鈥� RELOP Exp - 45 | Exp 鈥� PLUS Exp - 46 | Exp 鈥� MINUS Exp - 47 | Exp 鈥� STAR Exp - 48 | Exp 鈥� DIV Exp - 54 | Exp 鈥� LB Exp RB - 54 | Exp LB Exp 鈥� RB - 55 | Exp 鈥� DOT ID - 59 | Exp 鈥� PLUS error - - ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 76 - RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 - PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 - MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 - STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 - DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 - AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 - OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 - DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 - LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 - RB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 112 + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 44 | Exp OR Exp 鈥� + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 + + $default 浣跨敤瑙勫垯 44 浠ュ綊绾� (Exp) 鐘舵€� 107 - 62 Args: error Args 鈥� + 56 Exp: Exp DOT ID 鈥� - $default 浣跨敤瑙勫垯 62 浠ュ綊绾� (Args) + $default 浣跨敤瑙勫垯 56 浠ュ綊绾� (Exp) 鐘舵€� 108 - 60 Args: Exp COMMA 鈥� Args + 42 Exp: Exp 鈥� ASSIGNOP Exp + 43 | Exp 鈥� AND Exp + 44 | Exp 鈥� OR Exp + 45 | Exp 鈥� RELOP Exp + 46 | Exp 鈥� PLUS Exp + 47 | Exp 鈥� MINUS Exp + 48 | Exp 鈥� STAR Exp + 49 | Exp 鈥� DIV Exp + 55 | Exp 鈥� LB Exp RB + 55 | Exp LB Exp 鈥� RB + 56 | Exp 鈥� DOT ID + 60 | Exp 鈥� PLUS error + + ASSIGNOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 77 + RELOP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 78 + PLUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 79 + MINUS 鍋忕Щ锛屽苟杩涘叆鐘舵€� 80 + STAR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 81 + DIV 鍋忕Щ锛屽苟杩涘叆鐘舵€� 82 + AND 鍋忕Щ锛屽苟杩涘叆鐘舵€� 83 + OR 鍋忕Щ锛屽苟杩涘叆鐘舵€� 84 + DOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 85 + LB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 86 + RB 鍋忕Щ锛屽苟杩涘叆鐘舵€� 114 + + +鐘舵€� 109 + + 63 Args: error Args 鈥� + + $default 浣跨敤瑙勫垯 63 浠ュ綊绾� (Args) - error 鍋忕Щ锛屽苟杩涘叆鐘舵€� 88 + +鐘舵€� 110 + + 61 Args: Exp COMMA 鈥� Args + + error 鍋忕Щ锛屽苟杩涘叆鐘舵€� 90 INT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 48 FLOAT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 49 ID 鍋忕Щ锛屽苟杩涘叆鐘舵€� 50 @@ -1587,18 +1608,18 @@ NOT 鍋忕Щ锛屽苟杩涘叆鐘舵€� 52 LP 鍋忕Щ锛屽苟杩涘叆鐘舵€� 53 - Exp 杞埌鐘舵€� 90 - Args 杞埌鐘舵€� 113 + Exp 杞埌鐘舵€� 92 + Args 杞埌鐘舵€� 115 -鐘舵€� 109 +鐘舵€� 111 - 52 Exp: ID LP Args RP 鈥� + 53 Exp: ID LP Args RP 鈥� - $default 浣跨敤瑙勫垯 52 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 53 浠ュ綊绾� (Exp) -鐘舵€� 110 +鐘舵€� 112 30 Stmt: IF LP Exp RP 鈥� Stmt 31 | IF LP Exp RP 鈥� Stmt ELSE Stmt @@ -1616,11 +1637,11 @@ WHILE 鍋忕Щ锛屽苟杩涘叆鐘舵€� 56 CompSt 杞埌鐘舵€� 57 - Stmt 杞埌鐘舵€� 114 + Stmt 杞埌鐘舵€� 116 Exp 杞埌鐘舵€� 60 -鐘舵€� 111 +鐘舵€� 113 32 Stmt: WHILE LP Exp RP 鈥� Stmt @@ -1637,42 +1658,42 @@ WHILE 鍋忕Щ锛屽苟杩涘叆鐘舵€� 56 CompSt 杞埌鐘舵€� 57 - Stmt 杞埌鐘舵€� 115 + Stmt 杞埌鐘舵€� 117 Exp 杞埌鐘舵€� 60 -鐘舵€� 112 +鐘舵€� 114 - 54 Exp: Exp LB Exp RB 鈥� + 55 Exp: Exp LB Exp RB 鈥� - $default 浣跨敤瑙勫垯 54 浠ュ綊绾� (Exp) + $default 浣跨敤瑙勫垯 55 浠ュ綊绾� (Exp) -鐘舵€� 113 +鐘舵€� 115 - 60 Args: Exp COMMA Args 鈥� + 61 Args: Exp COMMA Args 鈥� - $default 浣跨敤瑙勫垯 60 浠ュ綊绾� (Args) + $default 浣跨敤瑙勫垯 61 浠ュ綊绾� (Args) -鐘舵€� 114 +鐘舵€� 116 30 Stmt: IF LP Exp RP Stmt 鈥� 31 | IF LP Exp RP Stmt 鈥� ELSE Stmt - ELSE 鍋忕Щ锛屽苟杩涘叆鐘舵€� 116 + ELSE 鍋忕Щ锛屽苟杩涘叆鐘舵€� 118 $default 浣跨敤瑙勫垯 30 浠ュ綊绾� (Stmt) -鐘舵€� 115 +鐘舵€� 117 32 Stmt: WHILE LP Exp RP Stmt 鈥� $default 浣跨敤瑙勫垯 32 浠ュ綊绾� (Stmt) -鐘舵€� 116 +鐘舵€� 118 31 Stmt: IF LP Exp RP Stmt ELSE 鈥� Stmt @@ -1689,11 +1710,11 @@ WHILE 鍋忕Щ锛屽苟杩涘叆鐘舵€� 56 CompSt 杞埌鐘舵€� 57 - Stmt 杞埌鐘舵€� 117 + Stmt 杞埌鐘舵€� 119 Exp 杞埌鐘舵€� 60 -鐘舵€� 117 +鐘舵€� 119 31 Stmt: IF LP Exp RP Stmt ELSE Stmt 鈥� diff --git a/Code/syntax.tab.c b/Code/syntax.tab.c index da6e58f4893fd4ea2c3ce8feecd8db7430e16f15..3d632ec3e35bf7bb8e3ae5f1b14acd72456f53bd 100644 --- a/Code/syntax.tab.c +++ b/Code/syntax.tab.c @@ -76,7 +76,9 @@ yylloc.first_column = yycolumn; \ yylloc.last_column = yycolumn + yyleng - 1; \ yycolumn += yyleng; -#line 13 "./syntax.y" + //#define YYDEBUG 1 + //int yydebug = 1; +#line 15 "./syntax.y" #include <stdio.h> #include "lex.yy.c" @@ -89,9 +91,9 @@ Node_t * Operator(Node_t * cur,char * content,int line,int argc,...); extern int syntax; - -#line 95 "./syntax.tab.c" + +#line 97 "./syntax.tab.c" # ifndef YY_CAST # ifdef __cplusplus @@ -502,16 +504,16 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 11 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 270 +#define YYLAST 278 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 31 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 22 /* YYNRULES -- Number of rules. */ -#define YYNRULES 63 +#define YYNRULES 64 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 118 +#define YYNSTATES 120 /* YYMAXUTOK -- Last valid token kind. */ #define YYMAXUTOK 285 @@ -563,13 +565,13 @@ static const yytype_int8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 108, 108, 110, 111, 113, 114, 115, 117, 118, - 123, 124, 126, 127, 129, 130, 132, 136, 137, 139, - 140, 142, 143, 145, 150, 151, 153, 154, 156, 157, - 158, 159, 160, 161, 162, 167, 168, 170, 172, 173, - 175, 176, 181, 182, 183, 184, 185, 186, 187, 188, - 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, - 199, 201, 202, 203 + 0, 110, 110, 112, 113, 115, 116, 117, 119, 120, + 125, 126, 128, 129, 131, 132, 134, 138, 139, 141, + 142, 144, 145, 147, 152, 153, 155, 156, 158, 159, + 160, 161, 162, 163, 164, 169, 170, 172, 174, 175, + 176, 178, 179, 184, 185, 186, 187, 188, 189, 190, + 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, + 201, 202, 204, 205, 206 }; #endif @@ -602,12 +604,12 @@ yysymbol_name (yysymbol_kind_t yysymbol) } #endif -#define YYPACT_NINF (-67) +#define YYPACT_NINF (-102) #define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF (-28) +#define YYTABLE_NINF (-39) #define yytable_value_is_error(Yyn) \ 0 @@ -616,18 +618,18 @@ yysymbol_name (yysymbol_kind_t yysymbol) STATE-NUM. */ static const yytype_int16 yypact[] = { - 51, -67, 9, 18, -67, 51, 11, -67, 10, 60, - -67, -67, -67, 22, -67, 49, -2, 12, 51, 57, - -67, 69, 77, 72, 51, -67, 69, 80, 51, -67, - 69, 87, 103, -67, -67, 90, -67, 35, 39, 108, - 120, -67, -67, 107, -67, 51, -67, 0, -67, -67, - 122, 98, 98, 98, 98, 123, 125, -67, 105, 35, - 110, 98, -67, 69, -67, -67, 67, 247, 247, 168, - 124, 98, 98, -67, -67, -67, 98, 98, 89, 98, - 98, 98, 98, 98, 138, 98, 210, -67, 94, -67, - 139, 136, -67, -67, 182, 196, 210, 243, -67, 249, - 247, 32, 247, 236, 223, -67, 153, -67, 94, -67, - 62, 62, -67, -67, 129, -67, 62, -67 + 27, -102, 9, 47, -102, 27, 73, -102, 30, 32, + -102, -102, -102, 38, -102, 76, 29, 14, 27, 26, + -102, 93, 103, 85, 27, -102, 93, 88, 27, -102, + 93, 94, 109, -102, -102, 107, -102, 37, -1, 124, + 70, -102, -102, 110, -102, 27, -102, 0, -102, -102, + 125, 100, 100, 100, 100, 127, 139, -102, 119, 37, + 112, 100, -102, 93, 93, -102, -102, 69, -3, -3, + 170, 126, 100, 100, -102, -102, -102, 100, 100, 91, + 100, 100, 100, 100, 100, 140, 100, 212, -102, -102, + 96, -102, 141, 152, -102, -102, 184, 198, 212, 245, + -102, 251, -3, 257, -3, 238, 225, -102, 155, -102, + 96, -102, 64, 64, -102, -102, 131, -102, 64, -102 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -638,31 +640,31 @@ static const yytype_int8 yydefact[] = 4, 10, 15, 0, 2, 4, 0, 11, 16, 0, 13, 1, 3, 17, 6, 0, 8, 0, 36, 0, 5, 0, 0, 0, 36, 7, 0, 0, 36, 20, - 0, 0, 22, 17, 9, 0, 25, 0, 40, 0, - 38, 12, 35, 23, 19, 0, 18, 0, 58, 59, - 57, 0, 0, 0, 0, 0, 0, 29, 0, 0, - 0, 0, 37, 0, 21, 34, 0, 51, 52, 0, - 0, 0, 0, 24, 26, 28, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 41, 39, 0, 54, - 62, 0, 50, 30, 0, 0, 42, 45, 60, 46, - 47, 48, 49, 43, 44, 56, 0, 63, 0, 53, - 0, 0, 55, 61, 31, 33, 0, 32 + 0, 0, 22, 17, 9, 0, 25, 0, 41, 0, + 0, 12, 35, 23, 19, 0, 18, 0, 59, 60, + 58, 0, 0, 0, 0, 0, 0, 29, 0, 0, + 0, 0, 37, 0, 0, 21, 34, 0, 52, 53, + 0, 0, 0, 0, 24, 26, 28, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 42, 40, 39, + 0, 55, 63, 0, 51, 30, 0, 0, 43, 46, + 61, 47, 48, 49, 50, 44, 45, 57, 0, 64, + 0, 54, 0, 0, 56, 62, 31, 33, 0, 32 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -67, -67, 154, -67, 137, 4, -67, -67, -67, -19, - -67, 126, -67, 155, 111, -60, -16, -67, 150, -67, - -51, -66 + -102, -102, 156, -102, 153, 4, -102, -102, -102, 13, + -102, 115, -102, 158, 114, -101, 34, -102, 21, -102, + -51, -85 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - 0, 3, 4, 5, 15, 26, 7, 9, 10, 16, + 0, 3, 4, 5, 15, 26, 7, 9, 10, 38, 17, 31, 32, 57, 58, 59, 27, 28, 39, 40, - 60, 91 + 60, 93 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -670,66 +672,66 @@ static const yytype_int8 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int8 yytable[] = { - 67, 68, 69, 70, 6, 21, 65, 38, 37, 6, - 86, 43, 42, 23, 8, 90, 13, 14, 11, 22, - 94, 95, 107, 30, 36, 96, 97, 99, 100, 101, - 102, 103, 104, -14, 106, 24, 47, 90, 48, 49, - 50, 19, 113, 79, 38, 81, 51, 61, 84, 30, - 114, 115, 52, 85, 53, 20, 117, 90, 24, -27, - 22, 54, 55, 47, 56, 48, 49, 50, 88, 1, - 48, 49, 50, 51, 33, 1, 2, 29, 51, 52, - 35, 53, 2, 18, 52, 24, 53, 89, 54, 55, - 98, 56, 48, 49, 50, 88, 36, 48, 49, 50, - 51, 48, 49, 50, 41, 51, 52, 44, 53, 51, - 45, 52, 46, 53, 62, 52, 75, 53, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 63, 22, 73, - 93, 85, 76, 77, 78, 79, 80, 81, 82, 83, - 84, 66, 71, 105, 72, 85, 108, 76, 77, 78, - 79, 80, 81, 82, 83, 84, 109, 116, 34, 12, - 85, 76, 77, 78, 79, 80, 81, 82, 83, 84, - 74, 64, 25, 0, 85, 112, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 0, 0, 0, 92, 85, - 76, 77, 78, 79, 80, 81, 82, 83, 84, 0, - 0, 0, 110, 85, 76, 77, 78, 79, 80, 81, - 82, 83, 84, 87, 0, 0, 111, 85, 76, 77, - 78, 79, 80, 81, 82, 83, 84, 0, 0, 0, - 0, 85, 77, 78, 79, 80, 81, 82, 0, 84, - 0, 0, 0, 0, 85, 77, 78, 79, 80, 81, - 0, 0, 84, 78, 79, 80, 81, 85, 79, 84, - 79, 80, 81, 84, 85, 84, 0, 0, 85, 0, - 85 + 68, 69, 70, 71, 6, 109, 66, 61, 80, 6, + 87, 116, 117, 85, 8, 23, 92, 119, 86, 16, + 22, 96, 97, 30, 36, 115, 98, 99, 101, 102, + 103, 104, 105, 106, 16, 108, 21, 24, 47, 92, + 48, 49, 50, 43, 1, 1, 29, 11, 51, 30, + 22, 2, 2, -14, 52, 18, 53, 19, 37, 92, + 24, -27, 42, 54, 55, 47, 56, 48, 49, 50, + 90, 63, 48, 49, 50, 51, -38, 64, 13, 14, + 51, 52, 20, 53, 88, 89, 52, 24, 53, 91, + 54, 55, 100, 56, 48, 49, 50, 90, 33, 48, + 49, 50, 51, 48, 49, 50, 35, 51, 52, 36, + 53, 51, 41, 52, 44, 53, 45, 52, 76, 53, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 46, + 62, 22, 95, 86, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 74, 67, 107, 72, 86, 110, 77, + 78, 79, 80, 81, 82, 83, 84, 85, 73, 118, + 65, 12, 86, 77, 78, 79, 80, 81, 82, 83, + 84, 85, 111, 75, 34, 25, 86, 114, 77, 78, + 79, 80, 81, 82, 83, 84, 85, 0, 0, 0, + 94, 86, 77, 78, 79, 80, 81, 82, 83, 84, + 85, 0, 0, 0, 112, 86, 77, 78, 79, 80, + 81, 82, 83, 84, 85, 0, 0, 0, 113, 86, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 0, + 0, 0, 0, 86, 78, 79, 80, 81, 82, 83, + 0, 85, 0, 0, 0, 0, 86, 78, 79, 80, + 81, 82, 0, 0, 85, 79, 80, 81, 82, 86, + 0, 85, 80, 81, 82, 0, 86, 85, 80, 0, + 82, 0, 86, 85, 0, 0, 0, 0, 86 }; static const yytype_int8 yycheck[] = { - 51, 52, 53, 54, 0, 7, 6, 26, 24, 5, - 61, 30, 28, 1, 5, 66, 5, 6, 0, 21, - 71, 72, 88, 19, 24, 76, 77, 78, 79, 80, - 81, 82, 83, 23, 85, 23, 1, 88, 3, 4, - 5, 19, 108, 11, 63, 13, 11, 8, 16, 45, - 110, 111, 17, 21, 19, 6, 116, 108, 23, 24, - 21, 26, 27, 1, 29, 3, 4, 5, 1, 18, - 3, 4, 5, 11, 5, 18, 25, 20, 11, 17, - 3, 19, 25, 23, 17, 23, 19, 20, 26, 27, - 1, 29, 3, 4, 5, 1, 24, 3, 4, 5, - 11, 3, 4, 5, 24, 11, 17, 20, 19, 11, - 7, 17, 22, 19, 6, 17, 6, 19, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 7, 21, 24, - 6, 21, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 19, 19, 5, 19, 21, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 20, 28, 21, 5, - 21, 8, 9, 10, 11, 12, 13, 14, 15, 16, - 59, 45, 17, -1, 21, 22, 8, 9, 10, 11, + 51, 52, 53, 54, 0, 90, 6, 8, 11, 5, + 61, 112, 113, 16, 5, 1, 67, 118, 21, 6, + 21, 72, 73, 19, 24, 110, 77, 78, 79, 80, + 81, 82, 83, 84, 21, 86, 7, 23, 1, 90, + 3, 4, 5, 30, 18, 18, 20, 0, 11, 45, + 21, 25, 25, 23, 17, 23, 19, 19, 24, 110, + 23, 24, 28, 26, 27, 1, 29, 3, 4, 5, + 1, 1, 3, 4, 5, 11, 6, 7, 5, 6, + 11, 17, 6, 19, 63, 64, 17, 23, 19, 20, + 26, 27, 1, 29, 3, 4, 5, 1, 5, 3, + 4, 5, 11, 3, 4, 5, 3, 11, 17, 24, + 19, 11, 24, 17, 20, 19, 7, 17, 6, 19, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 22, + 6, 21, 6, 21, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 24, 19, 5, 19, 21, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 19, 28, + 45, 5, 21, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 20, 59, 21, 17, 21, 22, 8, 9, + 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, + 20, 21, 8, 9, 10, 11, 12, 13, 14, 15, + 16, -1, -1, -1, 20, 21, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, 20, 21, 8, 9, 10, 11, 12, 13, 14, 15, 16, -1, - -1, -1, 20, 21, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 63, -1, -1, 20, 21, 8, 9, - 10, 11, 12, 13, 14, 15, 16, -1, -1, -1, - -1, 21, 9, 10, 11, 12, 13, 14, -1, 16, - -1, -1, -1, -1, 21, 9, 10, 11, 12, 13, - -1, -1, 16, 10, 11, 12, 13, 21, 11, 16, - 11, 12, 13, 16, 21, 16, -1, -1, 21, -1, - 21 + -1, -1, -1, 21, 9, 10, 11, 12, 13, 14, + -1, 16, -1, -1, -1, -1, 21, 9, 10, 11, + 12, 13, -1, -1, 16, 10, 11, 12, 13, 21, + -1, 16, 11, 12, 13, -1, 21, 16, 11, -1, + 13, -1, 21, 16, -1, -1, -1, -1, 21 }; /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of @@ -742,12 +744,12 @@ static const yytype_int8 yystos[] = 36, 42, 43, 5, 35, 3, 24, 47, 40, 49, 50, 24, 47, 40, 20, 7, 22, 1, 3, 4, 5, 11, 17, 19, 26, 27, 29, 44, 45, 46, - 51, 8, 6, 7, 42, 6, 19, 51, 51, 51, - 51, 19, 19, 24, 45, 6, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 21, 51, 49, 1, 20, - 51, 52, 20, 6, 51, 51, 51, 51, 1, 51, - 51, 51, 51, 51, 51, 5, 51, 52, 7, 20, - 20, 20, 22, 52, 46, 46, 28, 46 + 51, 8, 6, 1, 7, 42, 6, 19, 51, 51, + 51, 51, 19, 19, 24, 45, 6, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 21, 51, 49, 49, + 1, 20, 51, 52, 20, 6, 51, 51, 51, 51, + 1, 51, 51, 51, 51, 51, 51, 5, 51, 52, + 7, 20, 20, 20, 22, 52, 46, 46, 28, 46 }; /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ @@ -757,9 +759,9 @@ static const yytype_int8 yyr1[] = 36, 36, 37, 37, 38, 38, 39, 40, 40, 41, 41, 42, 42, 43, 44, 44, 45, 45, 46, 46, 46, 46, 46, 46, 46, 47, 47, 48, 49, 49, - 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, + 49, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, - 51, 52, 52, 52 + 51, 51, 52, 52, 52 }; /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ @@ -769,9 +771,9 @@ static const yytype_int8 yyr2[] = 1, 1, 5, 2, 1, 0, 1, 1, 4, 4, 3, 3, 1, 2, 4, 2, 2, 0, 2, 1, 3, 5, 7, 5, 2, 2, 0, 3, 1, 3, - 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 2, 2, 4, 3, 4, 3, 1, 1, 1, - 3, 3, 1, 2 + 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 2, 2, 4, 3, 4, 3, 1, 1, + 1, 3, 3, 1, 2 }; @@ -1348,379 +1350,385 @@ yyreduce: switch (yyn) { case 2: /* Program: ExtDefList */ -#line 108 "./syntax.y" +#line 110 "./syntax.y" { tree->root = (yyval.node) = Operator((yyval.node),"Program",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1354 "./syntax.tab.c" +#line 1356 "./syntax.tab.c" break; case 3: /* ExtDefList: ExtDef ExtDefList */ -#line 110 "./syntax.y" +#line 112 "./syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDefList",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1360 "./syntax.tab.c" +#line 1362 "./syntax.tab.c" break; case 4: /* ExtDefList: %empty */ -#line 111 "./syntax.y" +#line 113 "./syntax.y" { (yyval.node) = NULL; } -#line 1366 "./syntax.tab.c" +#line 1368 "./syntax.tab.c" break; case 5: /* ExtDef: Specifier ExtDecList SEMI */ -#line 113 "./syntax.y" +#line 115 "./syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDef",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1372 "./syntax.tab.c" +#line 1374 "./syntax.tab.c" break; case 6: /* ExtDef: Specifier SEMI */ -#line 114 "./syntax.y" +#line 116 "./syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDef",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1378 "./syntax.tab.c" +#line 1380 "./syntax.tab.c" break; case 7: /* ExtDef: Specifier FunDec CompSt */ -#line 115 "./syntax.y" +#line 117 "./syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDef",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1384 "./syntax.tab.c" +#line 1386 "./syntax.tab.c" break; case 8: /* ExtDecList: VarDec */ -#line 117 "./syntax.y" +#line 119 "./syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDecList",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1390 "./syntax.tab.c" +#line 1392 "./syntax.tab.c" break; case 9: /* ExtDecList: VarDec COMMA ExtDecList */ -#line 118 "./syntax.y" +#line 120 "./syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDecList",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1396 "./syntax.tab.c" +#line 1398 "./syntax.tab.c" break; case 10: /* Specifier: TYPE */ -#line 123 "./syntax.y" +#line 125 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Specifier",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1402 "./syntax.tab.c" +#line 1404 "./syntax.tab.c" break; case 11: /* Specifier: StructSpecifier */ -#line 124 "./syntax.y" +#line 126 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Specifier",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1408 "./syntax.tab.c" +#line 1410 "./syntax.tab.c" break; case 12: /* StructSpecifier: STRUCT OptTag LC DefList RC */ -#line 126 "./syntax.y" +#line 128 "./syntax.y" { (yyval.node) = Operator((yyval.node),"StructSpecifier",(yyloc).first_line,5,(yyvsp[-4].node),(yyvsp[-3].node),(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1414 "./syntax.tab.c" +#line 1416 "./syntax.tab.c" break; case 13: /* StructSpecifier: STRUCT Tag */ -#line 127 "./syntax.y" +#line 129 "./syntax.y" { (yyval.node) = Operator((yyval.node),"StructSpecifier",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1420 "./syntax.tab.c" +#line 1422 "./syntax.tab.c" break; case 14: /* OptTag: ID */ -#line 129 "./syntax.y" +#line 131 "./syntax.y" { (yyval.node) = Operator((yyval.node),"OptTag",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1426 "./syntax.tab.c" +#line 1428 "./syntax.tab.c" break; case 15: /* OptTag: %empty */ -#line 130 "./syntax.y" +#line 132 "./syntax.y" { (yyval.node) = NULL; } -#line 1432 "./syntax.tab.c" +#line 1434 "./syntax.tab.c" break; case 16: /* Tag: ID */ -#line 132 "./syntax.y" +#line 134 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Tag",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1438 "./syntax.tab.c" +#line 1440 "./syntax.tab.c" break; case 17: /* VarDec: ID */ -#line 136 "./syntax.y" +#line 138 "./syntax.y" { (yyval.node) = Operator((yyval.node),"VarDec",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1444 "./syntax.tab.c" +#line 1446 "./syntax.tab.c" break; case 18: /* VarDec: VarDec LB INT RB */ -#line 137 "./syntax.y" +#line 139 "./syntax.y" { (yyval.node) = Operator((yyval.node),"VarDec",(yyloc).first_line,4,(yyvsp[-3].node),(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1450 "./syntax.tab.c" +#line 1452 "./syntax.tab.c" break; case 19: /* FunDec: ID LP VarList RP */ -#line 139 "./syntax.y" +#line 141 "./syntax.y" { (yyval.node) = Operator((yyval.node),"FunDec",(yyloc).first_line,4,(yyvsp[-3].node),(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1456 "./syntax.tab.c" +#line 1458 "./syntax.tab.c" break; case 20: /* FunDec: ID LP RP */ -#line 140 "./syntax.y" +#line 142 "./syntax.y" { (yyval.node) = Operator((yyval.node),"FunDec",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1462 "./syntax.tab.c" +#line 1464 "./syntax.tab.c" break; case 21: /* VarList: ParamDec COMMA VarList */ -#line 142 "./syntax.y" +#line 144 "./syntax.y" { (yyval.node) = Operator((yyval.node),"VarList",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1468 "./syntax.tab.c" +#line 1470 "./syntax.tab.c" break; case 22: /* VarList: ParamDec */ -#line 143 "./syntax.y" +#line 145 "./syntax.y" { (yyval.node) = Operator((yyval.node),"ParamDec",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1474 "./syntax.tab.c" +#line 1476 "./syntax.tab.c" break; case 23: /* ParamDec: Specifier VarDec */ -#line 145 "./syntax.y" +#line 147 "./syntax.y" { (yyval.node) = Operator((yyval.node),"ParamDec",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1480 "./syntax.tab.c" +#line 1482 "./syntax.tab.c" break; case 24: /* CompSt: LC DefList StmtList RC */ -#line 150 "./syntax.y" +#line 152 "./syntax.y" { (yyval.node) = Operator((yyval.node),"CompSt",(yyloc).first_line,4,(yyvsp[-3].node),(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1486 "./syntax.tab.c" +#line 1488 "./syntax.tab.c" break; case 25: /* CompSt: error RC */ -#line 151 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"CompSt",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node));/* error */ } -#line 1492 "./syntax.tab.c" +#line 153 "./syntax.y" + { (yyval.node) = NULL;SyntaxError("CompSt:%d %d %s",(yylsp[0]).first_line,(yylsp[0]).last_column,(yyvsp[0].node)->text); } +#line 1494 "./syntax.tab.c" break; case 26: /* StmtList: Stmt StmtList */ -#line 153 "./syntax.y" +#line 155 "./syntax.y" { (yyval.node) = Operator((yyval.node),"StmtList",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1498 "./syntax.tab.c" +#line 1500 "./syntax.tab.c" break; case 27: /* StmtList: %empty */ -#line 154 "./syntax.y" +#line 156 "./syntax.y" { (yyval.node) = NULL; } -#line 1504 "./syntax.tab.c" +#line 1506 "./syntax.tab.c" break; case 28: /* Stmt: Exp SEMI */ -#line 156 "./syntax.y" +#line 158 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1510 "./syntax.tab.c" +#line 1512 "./syntax.tab.c" break; case 29: /* Stmt: CompSt */ -#line 157 "./syntax.y" +#line 159 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1516 "./syntax.tab.c" +#line 1518 "./syntax.tab.c" break; case 30: /* Stmt: RETURN Exp SEMI */ -#line 158 "./syntax.y" +#line 160 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1522 "./syntax.tab.c" +#line 1524 "./syntax.tab.c" break; case 31: /* Stmt: IF LP Exp RP Stmt */ -#line 159 "./syntax.y" +#line 161 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,5,(yyvsp[-4].node),(yyvsp[-3].node),(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1528 "./syntax.tab.c" +#line 1530 "./syntax.tab.c" break; case 32: /* Stmt: IF LP Exp RP Stmt ELSE Stmt */ -#line 160 "./syntax.y" +#line 162 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,7,(yyvsp[-6].node),(yyvsp[-5].node),(yyvsp[-4].node),(yyvsp[-3].node),(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1534 "./syntax.tab.c" +#line 1536 "./syntax.tab.c" break; case 33: /* Stmt: WHILE LP Exp RP Stmt */ -#line 161 "./syntax.y" +#line 163 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,5,(yyvsp[-4].node),(yyvsp[-3].node),(yyvsp[-2].node),(yyvsp[-2].node),(yyvsp[-1].node)); } -#line 1540 "./syntax.tab.c" +#line 1542 "./syntax.tab.c" break; case 34: /* Stmt: error SEMI */ -#line 162 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node));/* error */ } -#line 1546 "./syntax.tab.c" +#line 164 "./syntax.y" + { (yyval.node) = NULL;SyntaxError("Stmt:%d %d %s",(yylsp[0]).first_line,(yylsp[0]).last_column,(yyvsp[0].node)->text); } +#line 1548 "./syntax.tab.c" break; case 35: /* DefList: Def DefList */ -#line 167 "./syntax.y" +#line 169 "./syntax.y" { (yyval.node) = Operator((yyval.node),"DefList",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1552 "./syntax.tab.c" +#line 1554 "./syntax.tab.c" break; case 36: /* DefList: %empty */ -#line 168 "./syntax.y" +#line 170 "./syntax.y" { (yyval.node) = NULL; } -#line 1558 "./syntax.tab.c" +#line 1560 "./syntax.tab.c" break; case 37: /* Def: Specifier DecList SEMI */ -#line 170 "./syntax.y" +#line 172 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Def",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1564 "./syntax.tab.c" +#line 1566 "./syntax.tab.c" break; case 38: /* DecList: Dec */ -#line 172 "./syntax.y" +#line 174 "./syntax.y" { (yyval.node) = Operator((yyval.node),"DecList",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1570 "./syntax.tab.c" +#line 1572 "./syntax.tab.c" break; case 39: /* DecList: Dec COMMA DecList */ -#line 173 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"DecList",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1576 "./syntax.tab.c" - break; - - case 40: /* Dec: VarDec */ #line 175 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Dec",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1582 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"DecList",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1578 "./syntax.tab.c" break; - case 41: /* Dec: VarDec ASSIGNOP Exp */ + case 40: /* DecList: Dec error DecList */ #line 176 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Dec",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1588 "./syntax.tab.c" + { (yyval.node) = NULL;SyntaxError("%d %d",(yylsp[-2]).first_line,(yylsp[-2]).last_column); } +#line 1584 "./syntax.tab.c" break; - case 42: /* Exp: Exp ASSIGNOP Exp */ -#line 181 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1594 "./syntax.tab.c" - break; - - case 43: /* Exp: Exp AND Exp */ -#line 182 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1600 "./syntax.tab.c" + case 41: /* Dec: VarDec */ +#line 178 "./syntax.y" + { (yyval.node) = Operator((yyval.node),"Dec",(yyloc).first_line,1,(yyvsp[0].node)); } +#line 1590 "./syntax.tab.c" break; - case 44: /* Exp: Exp OR Exp */ -#line 183 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1606 "./syntax.tab.c" + case 42: /* Dec: VarDec ASSIGNOP Exp */ +#line 179 "./syntax.y" + { (yyval.node) = Operator((yyval.node),"Dec",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1596 "./syntax.tab.c" break; - case 45: /* Exp: Exp RELOP Exp */ + case 43: /* Exp: Exp ASSIGNOP Exp */ #line 184 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1612 "./syntax.tab.c" +#line 1602 "./syntax.tab.c" break; - case 46: /* Exp: Exp PLUS Exp */ + case 44: /* Exp: Exp AND Exp */ #line 185 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1618 "./syntax.tab.c" +#line 1608 "./syntax.tab.c" break; - case 47: /* Exp: Exp MINUS Exp */ + case 45: /* Exp: Exp OR Exp */ #line 186 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1624 "./syntax.tab.c" +#line 1614 "./syntax.tab.c" break; - case 48: /* Exp: Exp STAR Exp */ + case 46: /* Exp: Exp RELOP Exp */ #line 187 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1630 "./syntax.tab.c" +#line 1620 "./syntax.tab.c" break; - case 49: /* Exp: Exp DIV Exp */ + case 47: /* Exp: Exp PLUS Exp */ #line 188 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1636 "./syntax.tab.c" +#line 1626 "./syntax.tab.c" break; - case 50: /* Exp: LP Exp RP */ + case 48: /* Exp: Exp MINUS Exp */ #line 189 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1642 "./syntax.tab.c" +#line 1632 "./syntax.tab.c" break; - case 51: /* Exp: MINUS Exp */ + case 49: /* Exp: Exp STAR Exp */ #line 190 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1648 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1638 "./syntax.tab.c" break; - case 52: /* Exp: NOT Exp */ + case 50: /* Exp: Exp DIV Exp */ #line 191 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1654 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1644 "./syntax.tab.c" break; - case 53: /* Exp: ID LP Args RP */ + case 51: /* Exp: LP Exp RP */ #line 192 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,4,(yyvsp[-3].node),(yyvsp[-3].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1660 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1650 "./syntax.tab.c" break; - case 54: /* Exp: ID LP RP */ + case 52: /* Exp: MINUS Exp */ #line 193 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1666 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1656 "./syntax.tab.c" break; - case 55: /* Exp: Exp LB Exp RB */ + case 53: /* Exp: NOT Exp */ #line 194 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,4,(yyvsp[-3].node),(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1672 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1662 "./syntax.tab.c" break; - case 56: /* Exp: Exp DOT ID */ + case 54: /* Exp: ID LP Args RP */ #line 195 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1678 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,4,(yyvsp[-3].node),(yyvsp[-3].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1668 "./syntax.tab.c" break; - case 57: /* Exp: ID */ + case 55: /* Exp: ID LP RP */ #line 196 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1684 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1674 "./syntax.tab.c" break; - case 58: /* Exp: INT */ + case 56: /* Exp: Exp LB Exp RB */ #line 197 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1690 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,4,(yyvsp[-3].node),(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1680 "./syntax.tab.c" break; - case 59: /* Exp: FLOAT */ + case 57: /* Exp: Exp DOT ID */ #line 198 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1696 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1686 "./syntax.tab.c" break; - case 60: /* Exp: Exp PLUS error */ + case 58: /* Exp: ID */ #line 199 "./syntax.y" - { (yyval.node) = NULL; } -#line 1702 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,1,(yyvsp[0].node)); } +#line 1692 "./syntax.tab.c" break; - case 61: /* Args: Exp COMMA Args */ + case 59: /* Exp: INT */ +#line 200 "./syntax.y" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,1,(yyvsp[0].node)); } +#line 1698 "./syntax.tab.c" + break; + + case 60: /* Exp: FLOAT */ #line 201 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Args",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1708 "./syntax.tab.c" + { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,1,(yyvsp[0].node)); } +#line 1704 "./syntax.tab.c" break; - case 62: /* Args: Exp */ + case 61: /* Exp: Exp PLUS error */ #line 202 "./syntax.y" + { (yyval.node) = NULL;SyntaxError("Exp:%d %d %s",(yylsp[-1]).first_line,(yylsp[-1]).last_column,(yyvsp[-1].node)->text); } +#line 1710 "./syntax.tab.c" + break; + + case 62: /* Args: Exp COMMA Args */ +#line 204 "./syntax.y" + { (yyval.node) = Operator((yyval.node),"Args",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } +#line 1716 "./syntax.tab.c" + break; + + case 63: /* Args: Exp */ +#line 205 "./syntax.y" { (yyval.node) = Operator((yyval.node),"Args",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1714 "./syntax.tab.c" +#line 1722 "./syntax.tab.c" break; - case 63: /* Args: error Args */ -#line 203 "./syntax.y" - { (yyval.node) = Operator((yyval.node),"Args",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node));/* error */ } -#line 1720 "./syntax.tab.c" + case 64: /* Args: error Args */ +#line 206 "./syntax.y" + { (yyval.node) = NULL;SyntaxError("Args:%d %d %s",(yylsp[0]).first_line,(yylsp[0]).last_column,(yyvsp[0].node)->text); } +#line 1728 "./syntax.tab.c" break; -#line 1724 "./syntax.tab.c" +#line 1732 "./syntax.tab.c" default: break; } @@ -1918,6 +1926,6 @@ yyreturnlab: return yyresult; } -#line 206 "./syntax.y" +#line 209 "./syntax.y" diff --git a/Code/syntax.tab.h b/Code/syntax.tab.h index b5aacb8c507371b3dc8a8ce2d0a3b2b63984ad05..dd409e52fa127afba8e84dcb45687d99cd730e0f 100644 --- a/Code/syntax.tab.h +++ b/Code/syntax.tab.h @@ -90,7 +90,7 @@ extern int yydebug; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED union YYSTYPE { -#line 29 "./syntax.y" +#line 31 "./syntax.y" struct __Tree_node_t * node; diff --git a/Code/syntax.y b/Code/syntax.y index 325c18e6cf45d4c017bfd273bc89903c8e4297c3..bc2c73609328ffe98451a4e0a2791b77ff5eb0c8 100755 --- a/Code/syntax.y +++ b/Code/syntax.y @@ -8,6 +8,8 @@ yylloc.first_column = yycolumn; \ yylloc.last_column = yycolumn + yyleng - 1; \ yycolumn += yyleng; + //#define YYDEBUG 1 + //int yydebug = 1; %} %{ @@ -22,7 +24,7 @@ Node_t * Operator(Node_t * cur,char * content,int line,int argc,...); extern int syntax; - + %} /* declared types */ @@ -148,7 +150,7 @@ ParamDec : Specifier VarDec { $$ = Operator($$,"ParamDec",@$.first_line, /*Statements */ CompSt : LC DefList StmtList RC { $$ = Operator($$,"CompSt",@$.first_line,4,$1,$2,$3,$4); } - | error RC { $$ = Operator($$,"CompSt",@$.first_line,2,$1,$2);/* error */ } + | error RC { $$ = NULL;SyntaxError("CompSt:%d %d %s",@2.first_line,@2.last_column,$2->text); } ; StmtList : Stmt StmtList { $$ = Operator($$,"StmtList",@$.first_line,2,$1,$2); } | { $$ = NULL; } @@ -159,7 +161,7 @@ Stmt : Exp SEMI { $$ = Operator($$,"Stmt",@$.first_line,2,$1 | IF LP Exp RP Stmt %prec LOWER_THAN_ELSE { $$ = Operator($$,"Stmt",@$.first_line,5,$1,$2,$3,$4,$5); } | IF LP Exp RP Stmt ELSE Stmt { $$ = Operator($$,"Stmt",@$.first_line,7,$1,$2,$3,$4,$5,$6,$7); } | WHILE LP Exp RP Stmt { $$ = Operator($$,"Stmt",@$.first_line,5,$1,$2,$3,$3,$4); } - | error SEMI { $$ = Operator($$,"Stmt",@$.first_line,2,$1,$2);/* error */ } + | error SEMI { $$ = NULL;SyntaxError("Stmt:%d %d %s",@2.first_line,@2.last_column,$2->text); } ; /*Local Definitions */ @@ -171,6 +173,7 @@ Def : Specifier DecList SEMI { $$ = Operator($$,"Def",@$.first_line,3,$1, ; DecList : Dec { $$ = Operator($$,"DecList",@$.first_line,1,$1); } | Dec COMMA DecList { $$ = Operator($$,"DecList",@$.first_line,3,$1,$2,$3); } + | Dec error DecList { $$ = NULL;SyntaxError("%d %d",@1.first_line,@1.last_column); } ; Dec : VarDec { $$ = Operator($$,"Dec",@$.first_line,1,$1); } | VarDec ASSIGNOP Exp { $$ = Operator($$,"Dec",@$.first_line,3,$1,$2,$3); } @@ -196,11 +199,11 @@ Exp : Exp ASSIGNOP Exp { $$ = Operator($$,"Exp",@$.first_line,3,$1, | ID { $$ = Operator($$,"Exp",@$.first_line,1,$1); } | INT { $$ = Operator($$,"Exp",@$.first_line,1,$1); } | FLOAT { $$ = Operator($$,"Exp",@$.first_line,1,$1); } - | Exp PLUS error { $$ = NULL; } + | Exp PLUS error { $$ = NULL;SyntaxError("Exp:%d %d %s",@2.first_line,@2.last_column,$2->text); } ; Args : Exp COMMA Args { $$ = Operator($$,"Args",@$.first_line,3,$1,$2,$3); } | Exp { $$ = Operator($$,"Args",@$.first_line,1,$1); } - | error Args { $$ = Operator($$,"Args",@$.first_line,2,$1,$2);/* error */ } + | error Args { $$ = NULL;SyntaxError("Args:%d %d %s",@2.first_line,@2.last_column,$2->text); } ; %% diff --git a/Test/test1.cmm b/Test/test1.cmm index aee0c73dcd8037da16773d66a1b4c304184fa3c3..df18ea72213e72405285a8518b4197e9af1037b0 100644 --- a/Test/test1.cmm +++ b/Test/test1.cmm @@ -1,5 +1,5 @@ -int inc() +int main() { int i = 0123; - int j = 0x3F -=; + int j = 0x3F; } diff --git a/Test/test2.cmm b/Test/test2.cmm index 2abde19abbf5d46928cc91ef63d9567ae8fcddb0..5c0255e2782899c6843fbfab4248f46913cbd0aa 100644 --- a/Test/test2.cmm +++ b/Test/test2.cmm @@ -1,9 +1,5 @@ -struct Complex -{ - float real, image; -}; int main() { - struct Complex x; - y.image = 3.5; + int i = 09; + int j = 0x3G; } diff --git a/Test/test3.cmm b/Test/test3.cmm new file mode 100644 index 0000000000000000000000000000000000000000..96703ed8cd39c5cc36efd37bbbff172210fbdfd5 --- /dev/null +++ b/Test/test3.cmm @@ -0,0 +1,4 @@ +int main() +{ + float i = 1.05e-4; +} \ No newline at end of file diff --git a/Test/test4.cmm b/Test/test4.cmm new file mode 100644 index 0000000000000000000000000000000000000000..70c149ddd83107dd31a51e65b39294054fa9dd65 --- /dev/null +++ b/Test/test4.cmm @@ -0,0 +1,4 @@ +int main() +{ + float i = 1.05e; +} \ No newline at end of file diff --git a/Test/test5.cmm b/Test/test5.cmm new file mode 100644 index 0000000000000000000000000000000000000000..eb7033216339b3936dc18e0db38eb30deb49f660 --- /dev/null +++ b/Test/test5.cmm @@ -0,0 +1,8 @@ +int main() +{ + // line comment + /* + block comment + */ + int i = 1; +} \ No newline at end of file