diff --git a/Code/a.txt b/Code/a.txt index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0bd7d668c910cc810f9d6e0a649dcb639c75049f 100644 --- a/Code/a.txt +++ b/Code/a.txt @@ -0,0 +1,105 @@ +Program (1) + ExtDefList (1) + ExtDef (1) + Specifier (1) + TYPE: int + FunDec (1) + ID: main + LP + RP + CompSt (1) + LC + DefList (2) + Def (2) + Specifier (2) + TYPE: int + DecList (2) + Dec (2) + VarDec (2) + ID: a + COMMA + DecList (2) + Dec (2) + VarDec (2) + ID: b + COMMA + DecList (2) + Dec (2) + VarDec (2) + ID: c + SEMI + StmtList (3) + Stmt (3) + IF + LP + Exp (3) + Exp (3) + Exp (3) + Exp (3) + ID: a + RELOP + Exp (3) + INT: 1 + OR + Exp (3) + Exp (3) + ID: b + RELOP + Exp (3) + INT: 2 + AND + Exp (3) + Exp (3) + ID: c + RELOP + Exp (3) + INT: 3 + RP + Stmt (3) + CompSt (3) + LC + StmtList (4) + Stmt (4) + RETURN + Exp (4) + INT: 0 + SEMI + RC + StmtList (6) + Stmt (6) + IF + LP + Exp (6) + Exp (6) + Exp (6) + Exp (6) + ID: a + RELOP + Exp (6) + INT: 1 + AND + Exp (6) + Exp (6) + ID: b + RELOP + Exp (6) + INT: 2 + OR + Exp (6) + Exp (6) + ID: c + RELOP + Exp (6) + INT: 3 + RP + Stmt (6) + CompSt (6) + LC + StmtList (7) + Stmt (7) + RETURN + Exp (7) + INT: 0 + SEMI + RC + RC \ No newline at end of file diff --git a/Code/debug.h b/Code/debug.h index f716219846b68b2be566d120d7f4b3ac536ccb26..ed992e478fc763788860feee858f20cdb8110abc 100644 --- a/Code/debug.h +++ b/Code/debug.h @@ -50,13 +50,16 @@ #define Treedebug(format, ...) {;} #endif -#define panic_on(A,expr) \ - do { \ - if(!(expr)) { break;} \ - Log(A); \ - assert(0); \ - } while(1) - +#ifndef FINAL + #define panic_on(A,expr) \ + do { \ + if(!(expr)) { break;} \ + Log(A); \ + assert(0); \ + } while(1) +#else + #define panic_on(A,expr) (expr); +#endif #define panic(A) panic_on(A,1) diff --git a/Code/main.c b/Code/main.c index 5181c1f1e80b858edace4dc80c0f4729d2b7c4af..14ff2c54ab0bd242ed5ef62eae26da282f17cf51 100755 --- a/Code/main.c +++ b/Code/main.c @@ -32,7 +32,7 @@ int main(int argc,char *argv[]) { fclose(f); semantic_check->init(); if (syntax == 0) { - //tree->traverse(tree->root,0); + tree->traverse(tree->root,0); semantic_check->main(tree->root); //test->main(); @@ -55,6 +55,7 @@ static void free_Traverse(Node_t * cur) { } static void end_free() { +#ifndef FINAL //yylex bison鑷繁浼氱敵璇风┖闂达紝浣嗘槸涓嶉噴鏀撅紝鍏辫3娆� 16458 bytes symbol_stack->pop();//鍏坧op for(int i = 0;i < symbol_table->table_size;i++) { @@ -65,4 +66,5 @@ static void end_free() { free(symbol_table->table); free_Traverse(tree->root); panic_on("Error",symbol_table->cnt != 0); +#endif } diff --git a/Code/parser b/Code/parser index 0ca0d700810e7864ab845acd78e95fa62c45e033..3f0977a0326d525de22670bcd839f61eef72ee1e 100755 Binary files a/Code/parser and b/Code/parser differ diff --git a/Code/semantic.c b/Code/semantic.c index 0ed83ffcddba33cff92ea2efa9f8ee246592a5f5..7a609e0e9c60de9a90831df39004c3f9ef5a6dbb 100644 --- a/Code/semantic.c +++ b/Code/semantic.c @@ -127,13 +127,13 @@ static unit_t * Semantic_Check_Creat_Node(char * name,Type * type,int line) {// static int Semantic_Check_Insert_Node(unit_t * cur) { unit_t * find = symbol_table->find(cur->name); if(nodeop->IsStructDef(cur)) { - cur->deep = 1; - if(find) { +// cur->deep = 1; + if(find && find->deep == symbol_stack->stack_size) { ErrorHandling(16,cur->line,cur->name); nodeop->delete(cur,INFONODE); return 0; } else { - symbol_table->insert_struct(cur); + symbol_table->insert(cur); return 1; } } else if(find && find->deep == symbol_stack->stack_size) { @@ -195,7 +195,7 @@ static Type * Semantic_Check_Specifier(Node_t * root) { } else if(type(root->lchild->lchild,"STRUCT")) { if(type(root->lchild->rchild,"RC")) {//鏄粨鏋勪綋鐨勫畾涔� ret = Semantic_Check_StructSpecifier(root->lchild); - panic_on("Wrong struct",ret != NULL && ret->kind != STRUCTURE); + //panic_on("Wrong struct",ret != NULL && ret->kind != STRUCTURE); } else { unit_t * temp = symbol_table->find(root->lchild->lchild->right->lchild->text); if(temp != NULL && nodeop->IsStructDef(temp)) { @@ -255,6 +255,13 @@ static void Semantic_Check_ExtDef(Node_t * root) { while (temp) { unit_t * var = Semantic_Check_Creat_Node(temp->name,type_ops->type_copy(temp->type),temp->line); Semantic_Check_Insert_Node(var); + if(temp->type->kind == STRUCTURE) { + unit_t * find_struct = symbol_table->find(temp->type->u.structure->name); + if(!find_struct) { + unit_t * type_struct = Semantic_Check_Creat_Node(temp->type->u.structure->name,type_ops->type_copy(temp->type),temp->line); + Semantic_Check_Insert_Node(type_struct); + } + } temp = temp->tail; }//灏嗗嚱鏁板弬鏁板姞鍏ョ鍙疯〃 Semantic_Check_CompSt(root->rchild); @@ -510,8 +517,7 @@ static void Semantic_Check_Exp(Node_t * root) { if((!type_ops->type_equal(left_type,&Int_Type) && !type_ops->type_equal(left_type,&Float_Type)) || (!type_ops->type_equal(right_type,&Int_Type) && !type_ops->type_equal(right_type,&Float_Type))) { ErrorHandling(7,mid->line,empty); - } - if(!type_ops->type_equal(right_type,left_type)) { + } else if(!type_ops->type_equal(right_type,left_type)) { ErrorHandling(7,mid->line,empty); } ret = left_type; diff --git a/Code/syntax.tab.c b/Code/syntax.tab.c index e31f9bc4f5a2b4141b72a3ed6dfe89eaca61158a..c129f5940b90ddab1d83a33bc489f912c1e0680f 100644 --- a/Code/syntax.tab.c +++ b/Code/syntax.tab.c @@ -504,7 +504,7 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 13 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 290 +#define YYLAST 303 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 32 @@ -565,14 +565,14 @@ static const yytype_int8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 104, 104, 106, 107, 109, 110, 111, 112, 113, - 114, 115, 116, 118, 119, 124, 125, 127, 128, 130, - 131, 133, 137, 138, 139, 141, 142, 143, 144, 146, - 147, 149, 154, 155, 157, 158, 160, 161, 162, 163, - 164, 165, 166, 167, 168, 169, 170, 175, 176, 178, - 179, 180, 182, 183, 185, 186, 191, 192, 193, 194, - 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, - 205, 206, 207, 208, 210, 211, 212 + 0, 105, 105, 107, 108, 110, 111, 112, 113, 114, + 115, 116, 117, 119, 120, 125, 126, 128, 129, 131, + 132, 134, 138, 139, 140, 142, 143, 144, 145, 147, + 148, 150, 155, 156, 158, 159, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 176, 177, 179, + 180, 181, 183, 184, 186, 187, 192, 193, 194, 195, + 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, + 206, 207, 208, 209, 211, 212, 213 }; #endif @@ -631,7 +631,7 @@ static const yytype_int16 yypact[] = 195, -119, -119, -119, 186, 186, 186, 186, 186, 186, 186, 186, 197, 186, 256, -119, -119, 168, -119, 199, 196, -119, -119, -119, -119, 142, 242, 256, 183, 165, - 165, 83, 83, 269, 269, -119, 213, -119, 168, -119, + 165, 83, 83, 282, 269, -119, 213, -119, 168, -119, 198, 86, 86, -119, -119, 86, 189, -119, -119, 86, -119 }; @@ -707,8 +707,9 @@ static const yytype_int16 yytable[] = 94, 95, 96, 97, 98, 99, 100, 101, 102, 0, 0, 0, 132, 103, 94, 95, 96, 97, 98, 99, 100, 101, 102, 0, 0, 0, 0, 103, 95, 96, - 97, 98, 99, 0, 0, 102, 0, 0, 0, 0, - 103 + 97, 98, 99, 100, 0, 102, 0, 0, 0, 0, + 103, 95, 96, 97, 98, 99, 0, 0, 102, 0, + 0, 0, 0, 103 }; static const yytype_int16 yycheck[] = @@ -741,8 +742,9 @@ static const yytype_int16 yycheck[] = 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, -1, 21, 9, 10, - 11, 12, 13, -1, -1, 16, -1, -1, -1, -1, - 21 + 11, 12, 13, 14, -1, 16, -1, -1, -1, -1, + 21, 9, 10, 11, 12, 13, -1, -1, 16, -1, + -1, -1, -1, 21 }; /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of @@ -1366,457 +1368,457 @@ yyreduce: switch (yyn) { case 2: /* Program: ExtDefList */ -#line 104 "syntax.y" +#line 105 "syntax.y" { tree->root = (yyval.node) = Operator((yyval.node),"Program",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1372 "syntax.tab.c" +#line 1374 "syntax.tab.c" break; case 3: /* ExtDefList: ExtDef ExtDefList */ -#line 106 "syntax.y" +#line 107 "syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDefList",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1378 "syntax.tab.c" +#line 1380 "syntax.tab.c" break; case 4: /* ExtDefList: %empty */ -#line 107 "syntax.y" +#line 108 "syntax.y" { (yyval.node) = NULL; } -#line 1384 "syntax.tab.c" +#line 1386 "syntax.tab.c" break; case 5: /* ExtDef: Specifier ExtDecList SEMI */ -#line 109 "syntax.y" +#line 110 "syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDef",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1390 "syntax.tab.c" +#line 1392 "syntax.tab.c" break; case 6: /* ExtDef: Specifier SEMI */ -#line 110 "syntax.y" +#line 111 "syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDef",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1396 "syntax.tab.c" +#line 1398 "syntax.tab.c" break; case 7: /* ExtDef: Specifier FunDec CompSt */ -#line 111 "syntax.y" +#line 112 "syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDef",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1402 "syntax.tab.c" +#line 1404 "syntax.tab.c" break; case 8: /* ExtDef: Specifier FunDec SEMI */ -#line 112 "syntax.y" +#line 113 "syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDef",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1408 "syntax.tab.c" +#line 1410 "syntax.tab.c" break; case 9: /* ExtDef: error SEMI */ -#line 113 "syntax.y" +#line 114 "syntax.y" { (yyval.node) = NULL;yyerror("ExtDef"); } -#line 1414 "syntax.tab.c" +#line 1416 "syntax.tab.c" break; case 10: /* ExtDef: Specifier error */ -#line 114 "syntax.y" +#line 115 "syntax.y" { (yyval.node) = NULL;yyerror("ExtDef,missing ;"); } -#line 1420 "syntax.tab.c" +#line 1422 "syntax.tab.c" break; case 11: /* ExtDef: Specifier error SEMI */ -#line 115 "syntax.y" +#line 116 "syntax.y" { (yyval.node) = NULL;yyerror("ExtDef"); } -#line 1426 "syntax.tab.c" +#line 1428 "syntax.tab.c" break; case 12: /* ExtDef: Specifier error CompSt */ -#line 116 "syntax.y" +#line 117 "syntax.y" { (yyval.node) = NULL;yyerror("ExtDef"); } -#line 1432 "syntax.tab.c" +#line 1434 "syntax.tab.c" break; case 13: /* ExtDecList: VarDec */ -#line 118 "syntax.y" +#line 119 "syntax.y" { (yyval.node) = Operator((yyval.node),"ExtDecList",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1438 "syntax.tab.c" +#line 1440 "syntax.tab.c" break; case 14: /* ExtDecList: VarDec COMMA ExtDecList */ -#line 119 "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 1444 "syntax.tab.c" +#line 1446 "syntax.tab.c" break; case 15: /* Specifier: TYPE */ -#line 124 "syntax.y" +#line 125 "syntax.y" { (yyval.node) = Operator((yyval.node),"Specifier",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1450 "syntax.tab.c" +#line 1452 "syntax.tab.c" break; case 16: /* Specifier: StructSpecifier */ -#line 125 "syntax.y" +#line 126 "syntax.y" { (yyval.node) = Operator((yyval.node),"Specifier",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1456 "syntax.tab.c" +#line 1458 "syntax.tab.c" break; case 17: /* StructSpecifier: STRUCT OptTag LC DefList RC */ -#line 127 "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 1462 "syntax.tab.c" +#line 1464 "syntax.tab.c" break; case 18: /* StructSpecifier: STRUCT Tag */ -#line 128 "syntax.y" +#line 129 "syntax.y" { (yyval.node) = Operator((yyval.node),"StructSpecifier",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1468 "syntax.tab.c" +#line 1470 "syntax.tab.c" break; case 19: /* OptTag: ID */ -#line 130 "syntax.y" +#line 131 "syntax.y" { (yyval.node) = Operator((yyval.node),"OptTag",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1474 "syntax.tab.c" +#line 1476 "syntax.tab.c" break; case 20: /* OptTag: %empty */ -#line 131 "syntax.y" +#line 132 "syntax.y" { (yyval.node) = NULL; } -#line 1480 "syntax.tab.c" +#line 1482 "syntax.tab.c" break; case 21: /* Tag: ID */ -#line 133 "syntax.y" +#line 134 "syntax.y" { (yyval.node) = Operator((yyval.node),"Tag",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1486 "syntax.tab.c" +#line 1488 "syntax.tab.c" break; case 22: /* VarDec: ID */ -#line 137 "syntax.y" +#line 138 "syntax.y" { (yyval.node) = Operator((yyval.node),"VarDec",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1492 "syntax.tab.c" +#line 1494 "syntax.tab.c" break; case 23: /* VarDec: VarDec LB INT RB */ -#line 138 "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 1498 "syntax.tab.c" +#line 1500 "syntax.tab.c" break; case 24: /* VarDec: VarDec LB error RB */ -#line 139 "syntax.y" +#line 140 "syntax.y" { (yyval.node) = NULL; yyerror("VarDec"); } -#line 1504 "syntax.tab.c" +#line 1506 "syntax.tab.c" break; case 25: /* FunDec: ID LP VarList RP */ -#line 141 "syntax.y" +#line 142 "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 1510 "syntax.tab.c" +#line 1512 "syntax.tab.c" break; case 26: /* FunDec: ID LP RP */ -#line 142 "syntax.y" +#line 143 "syntax.y" { (yyval.node) = Operator((yyval.node),"FunDec",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1516 "syntax.tab.c" +#line 1518 "syntax.tab.c" break; case 27: /* FunDec: ID LP error RP */ -#line 143 "syntax.y" +#line 144 "syntax.y" { (yyval.node) = NULL; yyerror("FunDec"); } -#line 1522 "syntax.tab.c" +#line 1524 "syntax.tab.c" break; case 28: /* FunDec: error LP VarList RP */ -#line 144 "syntax.y" +#line 145 "syntax.y" { (yyval.node) = NULL; yyerror("FunDec"); } -#line 1528 "syntax.tab.c" +#line 1530 "syntax.tab.c" break; case 29: /* VarList: ParamDec COMMA VarList */ -#line 146 "syntax.y" +#line 147 "syntax.y" { (yyval.node) = Operator((yyval.node),"VarList",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1534 "syntax.tab.c" +#line 1536 "syntax.tab.c" break; case 30: /* VarList: ParamDec */ -#line 147 "syntax.y" +#line 148 "syntax.y" { (yyval.node) = Operator((yyval.node),"VarList",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1540 "syntax.tab.c" +#line 1542 "syntax.tab.c" break; case 31: /* ParamDec: Specifier VarDec */ -#line 149 "syntax.y" +#line 150 "syntax.y" { (yyval.node) = Operator((yyval.node),"ParamDec",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1546 "syntax.tab.c" +#line 1548 "syntax.tab.c" break; case 32: /* CompSt: LC DefList StmtList RC */ -#line 154 "syntax.y" +#line 155 "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 1552 "syntax.tab.c" +#line 1554 "syntax.tab.c" break; case 33: /* CompSt: LC DefList error RC */ -#line 155 "syntax.y" +#line 156 "syntax.y" { (yyval.node) = NULL; yyerror("CompSt"); } -#line 1558 "syntax.tab.c" +#line 1560 "syntax.tab.c" break; case 34: /* StmtList: Stmt StmtList */ -#line 157 "syntax.y" +#line 158 "syntax.y" { (yyval.node) = Operator((yyval.node),"StmtList",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1564 "syntax.tab.c" +#line 1566 "syntax.tab.c" break; case 35: /* StmtList: %empty */ -#line 158 "syntax.y" +#line 159 "syntax.y" { (yyval.node) = NULL; } -#line 1570 "syntax.tab.c" +#line 1572 "syntax.tab.c" break; case 36: /* Stmt: Exp SEMI */ -#line 160 "syntax.y" +#line 161 "syntax.y" { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1576 "syntax.tab.c" +#line 1578 "syntax.tab.c" break; case 37: /* Stmt: CompSt */ -#line 161 "syntax.y" +#line 162 "syntax.y" { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1582 "syntax.tab.c" +#line 1584 "syntax.tab.c" break; case 38: /* Stmt: RETURN Exp SEMI */ -#line 162 "syntax.y" +#line 163 "syntax.y" { (yyval.node) = Operator((yyval.node),"Stmt",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1588 "syntax.tab.c" +#line 1590 "syntax.tab.c" break; case 39: /* Stmt: IF LP Exp RP Stmt */ -#line 163 "syntax.y" +#line 164 "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 1594 "syntax.tab.c" +#line 1596 "syntax.tab.c" break; case 40: /* Stmt: IF LP Exp RP Stmt ELSE Stmt */ -#line 164 "syntax.y" +#line 165 "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 1600 "syntax.tab.c" +#line 1602 "syntax.tab.c" break; case 41: /* Stmt: WHILE LP Exp RP Stmt */ -#line 165 "syntax.y" +#line 166 "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 1606 "syntax.tab.c" +#line 1608 "syntax.tab.c" break; case 42: /* Stmt: error SEMI */ -#line 166 "syntax.y" +#line 167 "syntax.y" { (yyval.node) = NULL; yyerror("1Stmt"); } -#line 1612 "syntax.tab.c" +#line 1614 "syntax.tab.c" break; case 43: /* Stmt: Exp error */ -#line 167 "syntax.y" +#line 168 "syntax.y" { (yyval.node) = NULL; yyerror("2Stmt"); } -#line 1618 "syntax.tab.c" +#line 1620 "syntax.tab.c" break; case 44: /* Stmt: IF LP Exp error RP Stmt */ -#line 168 "syntax.y" +#line 169 "syntax.y" { (yyval.node) = NULL; yyerror("3Stmt"); } -#line 1624 "syntax.tab.c" +#line 1626 "syntax.tab.c" break; case 45: /* Stmt: RETURN error SEMI */ -#line 169 "syntax.y" +#line 170 "syntax.y" { (yyval.node) = NULL; yyerror("4Stmt"); } -#line 1630 "syntax.tab.c" +#line 1632 "syntax.tab.c" break; case 46: /* Stmt: RETURN Exp error */ -#line 170 "syntax.y" +#line 171 "syntax.y" { (yyval.node) = NULL; yyerror("5Stmt"); } -#line 1636 "syntax.tab.c" +#line 1638 "syntax.tab.c" break; case 47: /* DefList: Def DefList */ -#line 175 "syntax.y" +#line 176 "syntax.y" { (yyval.node) = Operator((yyval.node),"DefList",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1642 "syntax.tab.c" +#line 1644 "syntax.tab.c" break; case 48: /* DefList: %empty */ -#line 176 "syntax.y" +#line 177 "syntax.y" { (yyval.node) = NULL; } -#line 1648 "syntax.tab.c" +#line 1650 "syntax.tab.c" break; case 49: /* Def: Specifier DecList SEMI */ -#line 178 "syntax.y" +#line 179 "syntax.y" { (yyval.node) = Operator((yyval.node),"Def",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1654 "syntax.tab.c" +#line 1656 "syntax.tab.c" break; case 50: /* Def: Specifier error SEMI */ -#line 179 "syntax.y" +#line 180 "syntax.y" { (yyval.node) = NULL; yyerror("Def"); } -#line 1660 "syntax.tab.c" +#line 1662 "syntax.tab.c" break; case 51: /* Def: Specifier DecList error SEMI */ -#line 180 "syntax.y" +#line 181 "syntax.y" { (yyval.node) = NULL; yyerror("Def"); } -#line 1666 "syntax.tab.c" +#line 1668 "syntax.tab.c" break; case 52: /* DecList: Dec */ -#line 182 "syntax.y" +#line 183 "syntax.y" { (yyval.node) = Operator((yyval.node),"DecList",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1672 "syntax.tab.c" +#line 1674 "syntax.tab.c" break; case 53: /* DecList: Dec COMMA DecList */ -#line 183 "syntax.y" +#line 184 "syntax.y" { (yyval.node) = Operator((yyval.node),"DecList",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1678 "syntax.tab.c" +#line 1680 "syntax.tab.c" break; case 54: /* Dec: VarDec */ -#line 185 "syntax.y" +#line 186 "syntax.y" { (yyval.node) = Operator((yyval.node),"Dec",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1684 "syntax.tab.c" +#line 1686 "syntax.tab.c" break; case 55: /* Dec: VarDec ASSIGNOP Exp */ -#line 186 "syntax.y" +#line 187 "syntax.y" { (yyval.node) = Operator((yyval.node),"Dec",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1690 "syntax.tab.c" +#line 1692 "syntax.tab.c" break; case 56: /* Exp: Exp ASSIGNOP Exp */ -#line 191 "syntax.y" +#line 192 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1696 "syntax.tab.c" +#line 1698 "syntax.tab.c" break; case 57: /* Exp: Exp AND Exp */ -#line 192 "syntax.y" +#line 193 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1702 "syntax.tab.c" +#line 1704 "syntax.tab.c" break; case 58: /* Exp: Exp OR Exp */ -#line 193 "syntax.y" +#line 194 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1708 "syntax.tab.c" +#line 1710 "syntax.tab.c" break; case 59: /* Exp: Exp RELOP Exp */ -#line 194 "syntax.y" +#line 195 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1714 "syntax.tab.c" +#line 1716 "syntax.tab.c" break; case 60: /* Exp: Exp PLUS Exp */ -#line 195 "syntax.y" +#line 196 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1720 "syntax.tab.c" +#line 1722 "syntax.tab.c" break; case 61: /* Exp: Exp MINUS Exp */ -#line 196 "syntax.y" +#line 197 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1726 "syntax.tab.c" +#line 1728 "syntax.tab.c" break; case 62: /* Exp: Exp STAR Exp */ -#line 197 "syntax.y" +#line 198 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1732 "syntax.tab.c" +#line 1734 "syntax.tab.c" break; case 63: /* Exp: Exp DIV Exp */ -#line 198 "syntax.y" +#line 199 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1738 "syntax.tab.c" +#line 1740 "syntax.tab.c" break; case 64: /* Exp: LP Exp RP */ -#line 199 "syntax.y" +#line 200 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1744 "syntax.tab.c" +#line 1746 "syntax.tab.c" break; case 65: /* Exp: MINUS Exp */ -#line 200 "syntax.y" +#line 201 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1750 "syntax.tab.c" +#line 1752 "syntax.tab.c" break; case 66: /* Exp: NOT Exp */ -#line 201 "syntax.y" +#line 202 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,2,(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1756 "syntax.tab.c" +#line 1758 "syntax.tab.c" break; case 67: /* Exp: ID LP Args RP */ -#line 202 "syntax.y" +#line 203 "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 1762 "syntax.tab.c" +#line 1764 "syntax.tab.c" break; case 68: /* Exp: ID LP RP */ -#line 203 "syntax.y" +#line 204 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1768 "syntax.tab.c" +#line 1770 "syntax.tab.c" break; case 69: /* Exp: Exp LB Exp RB */ -#line 204 "syntax.y" +#line 205 "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 1774 "syntax.tab.c" +#line 1776 "syntax.tab.c" break; case 70: /* Exp: Exp DOT ID */ -#line 205 "syntax.y" +#line 206 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1780 "syntax.tab.c" +#line 1782 "syntax.tab.c" break; case 71: /* Exp: ID */ -#line 206 "syntax.y" +#line 207 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1786 "syntax.tab.c" +#line 1788 "syntax.tab.c" break; case 72: /* Exp: INT */ -#line 207 "syntax.y" +#line 208 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1792 "syntax.tab.c" +#line 1794 "syntax.tab.c" break; case 73: /* Exp: FLOAT */ -#line 208 "syntax.y" +#line 209 "syntax.y" { (yyval.node) = Operator((yyval.node),"Exp",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1798 "syntax.tab.c" +#line 1800 "syntax.tab.c" break; case 74: /* Args: Exp COMMA Args */ -#line 210 "syntax.y" +#line 211 "syntax.y" { (yyval.node) = Operator((yyval.node),"Args",(yyloc).first_line,3,(yyvsp[-2].node),(yyvsp[-1].node),(yyvsp[0].node)); } -#line 1804 "syntax.tab.c" +#line 1806 "syntax.tab.c" break; case 75: /* Args: Exp */ -#line 211 "syntax.y" +#line 212 "syntax.y" { (yyval.node) = Operator((yyval.node),"Args",(yyloc).first_line,1,(yyvsp[0].node)); } -#line 1810 "syntax.tab.c" +#line 1812 "syntax.tab.c" break; case 76: /* Args: error Args */ -#line 212 "syntax.y" +#line 213 "syntax.y" { (yyval.node) = NULL; yyerror("Wrong Args"); } -#line 1816 "syntax.tab.c" +#line 1818 "syntax.tab.c" break; -#line 1820 "syntax.tab.c" +#line 1822 "syntax.tab.c" default: break; } @@ -2014,7 +2016,7 @@ yyreturnlab: return yyresult; } -#line 215 "syntax.y" +#line 216 "syntax.y" diff --git a/Code/syntax.y b/Code/syntax.y index 5f832bc2fb24089673c72ff2fd430e4dcafca5b1..2d74048d299f22316c5288a3fd4425d5762cfa31 100755 --- a/Code/syntax.y +++ b/Code/syntax.y @@ -61,7 +61,8 @@ %right ASSIGNOP -%left OR AND +%left OR +%left AND %left RELOP %left PLUS MINUS diff --git a/Test/senamic_test/jlj_test/test1.cmm b/Test/senamic_test/jlj_test/test1.cmm new file mode 100755 index 0000000000000000000000000000000000000000..b6f0df3e92d40ca374d83379db227516f8d7000c --- /dev/null +++ b/Test/senamic_test/jlj_test/test1.cmm @@ -0,0 +1,34 @@ +// test compst +int main(){ + int i; + i = 1; + while(i == 1){ + float i; + i = 0.5; + while(i == 5){ // error 7 + int i[4][3]; + while(i[4][3] == 3){ + struct{ + int i; + }i; + while(i.i == 0.5){ // error 7 + int i; + } + } + } + }i = 0.5; // error 5 + { + int i;{ + float i; + { + struct i{ + int i; + }j; + } + } + } + { + float i; + } + +}int i; \ No newline at end of file diff --git a/Test/senamic_test/jlj_test/test1.output b/Test/senamic_test/jlj_test/test1.output new file mode 100644 index 0000000000000000000000000000000000000000..0e55645bb7a25cedb12451f858b6167f905967f3 --- /dev/null +++ b/Test/senamic_test/jlj_test/test1.output @@ -0,0 +1,3 @@ +Error type 7 at Line 8: Type mismatched for operands "==" +Error type 7 at Line 14: Type mismatched for operands "==" +Error type 5 at Line 19: Type mismatched for assignment "=" diff --git a/Test/senamic_test/jlj_test/test2.cmm b/Test/senamic_test/jlj_test/test2.cmm new file mode 100755 index 0000000000000000000000000000000000000000..a23fa635fca5215735e48941614ef318797766ec --- /dev/null +++ b/Test/senamic_test/jlj_test/test2.cmm @@ -0,0 +1,61 @@ +int a, b; + +struct A{ + int a; + int b; +}; + +int func1(int a); +int func2(int b); +int func3(int a); // error 18 +int func4(struct A b); +int func5(int a); // error 18 +int func6(int a); // error 18 +int func7(int b); // error 18 +int func10(struct A{int a, b;} c){ + int d; +} +int func11(struct A{int a[9], b;} c){ + d = 1; // error 1; +} + +int main(){ + struct A c; + func1(a); + func8(a); // error 2 + func4(c); + func5(b); + func6(c); // error 9; + func10(c); + func11(c); // error 9; +} + +int func1(int a){ + int b; int c; +} + +int func2(int b){ + int a; int c; +} + +int func3(struct A a){ // error 19 + int c; +} + +int func4(struct A a){ + int c; +} + + +int func5(int a); +int func5(int a); + +int func8(int a){ + int a, b; //error 3 +} + +int func9(int a){ + int c, d; +} + + diff --git a/Test/senamic_test/jlj_test/test2.output b/Test/senamic_test/jlj_test/test2.output new file mode 100644 index 0000000000000000000000000000000000000000..723104e15a1fb8962cf4e991a2d359bd8e28924a --- /dev/null +++ b/Test/senamic_test/jlj_test/test2.output @@ -0,0 +1,11 @@ +Error type 1 at Line 19: Undefined variable "d" +Error type 5 at Line 19: Type mismatched for assignment "=" +Error type 2 at Line 25: Undefined function "func8" +Error type 9 at Line 28: Function is not applicable for arguments "" +Error type 9 at Line 30: Function is not applicable for arguments "" +Error type 19 at Line 41: Inconsistent declaration of function "func3" +Error type 3 at Line 54: Redefined variable "a" +Error type 18 at Line 14: Undefined function "func7" +Error type 18 at Line 13: Undefined function "func6" +Error type 18 at Line 12: Undefined function "func5" +Error type 18 at Line 10: Undefined function "func3" diff --git a/Test/senamic_test/jlj_test/test3.cmm b/Test/senamic_test/jlj_test/test3.cmm new file mode 100755 index 0000000000000000000000000000000000000000..68946c48c065b175c5f8cfa5bd414ec61be48506 --- /dev/null +++ b/Test/senamic_test/jlj_test/test3.cmm @@ -0,0 +1,32 @@ +// test array; +int func(int a[10][10][10][10]){ + int b[2][50]; + a[10][10] = b; + a[10][10][10] = b; // error 5; +} + +struct A{ + int b[10][10][10][10]; +}; + +int func2(struct A{int b[10][10][10][10];} a){ + return 2; +} + +int main(){ + struct A a; + int b[20][5][10][10]; + int c[20][5][10]; + int d[20][5][5][5][5]; + int e[2][10][10][10][10]; + func(b); + func(b[10]); // error 9; + c + b; // error 7; + c + b[20]; // error 7; + c[1][1][1] + b[1][1][1][1]; + func(d[1]); // error 9; + func(e[0]); + func(a.b); + func(a.b[0]); // error 9; + func2(a); +} \ No newline at end of file diff --git a/Test/senamic_test/jlj_test/test3.output b/Test/senamic_test/jlj_test/test3.output new file mode 100644 index 0000000000000000000000000000000000000000..5f4a22360a952aa2f432e71cb643fd55fab7d99c --- /dev/null +++ b/Test/senamic_test/jlj_test/test3.output @@ -0,0 +1,5 @@ +Error type 5 at Line 5: Type mismatched for assignment "=" +Error type 9 at Line 23: Function is not applicable for arguments "" +Error type 7 at Line 24: Type mismatched for operands "" +Error type 7 at Line 25: Type mismatched for operands "" +Error type 9 at Line 30: Function is not applicable for arguments "" diff --git a/Test/senamic_test/simple_test/test1.cmm b/Test/senamic_test/simple_test/test1.cmm new file mode 100755 index 0000000000000000000000000000000000000000..98e885cca4ab1efb834528ebe7f2bb8fd1de719f --- /dev/null +++ b/Test/senamic_test/simple_test/test1.cmm @@ -0,0 +1,5 @@ +int main() +{ + int i = 0; + j = i + 1; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test1.output b/Test/senamic_test/simple_test/test1.output new file mode 100644 index 0000000000000000000000000000000000000000..10219f64c7432a12d44bf474d393f002d23df255 --- /dev/null +++ b/Test/senamic_test/simple_test/test1.output @@ -0,0 +1,2 @@ +Error type 1 at Line 4: Undefined variable "j" +Error type 5 at Line 4: Type mismatched for assignment "=" diff --git a/Test/senamic_test/simple_test/test10.cmm b/Test/senamic_test/simple_test/test10.cmm new file mode 100755 index 0000000000000000000000000000000000000000..d2e0e6953d35393a1b5f118fbe162472053ff199 --- /dev/null +++ b/Test/senamic_test/simple_test/test10.cmm @@ -0,0 +1,5 @@ +int main() +{ + int i; + i[0]; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test10.output b/Test/senamic_test/simple_test/test10.output new file mode 100644 index 0000000000000000000000000000000000000000..b2f51d6369f56e6d30100ec91456f77c166eb301 --- /dev/null +++ b/Test/senamic_test/simple_test/test10.output @@ -0,0 +1 @@ +Error type 10 at Line 4: Variable is not an array "[" diff --git a/Test/senamic_test/simple_test/test11.cmm b/Test/senamic_test/simple_test/test11.cmm new file mode 100755 index 0000000000000000000000000000000000000000..dbfd00ecfcbbd58119f5cd1a6ef0c7ab3e95f680 --- /dev/null +++ b/Test/senamic_test/simple_test/test11.cmm @@ -0,0 +1,5 @@ +int main() +{ + int i; + i(10); +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test11.output b/Test/senamic_test/simple_test/test11.output new file mode 100644 index 0000000000000000000000000000000000000000..44b107261551785f36469a6c9deccbe9224fb20c --- /dev/null +++ b/Test/senamic_test/simple_test/test11.output @@ -0,0 +1 @@ +Error type 11 at Line 4: Not a function "i" diff --git a/Test/senamic_test/simple_test/test12.cmm b/Test/senamic_test/simple_test/test12.cmm new file mode 100755 index 0000000000000000000000000000000000000000..4fb179ed20f9b63a301cc782d0ffc3e1cccd3d60 --- /dev/null +++ b/Test/senamic_test/simple_test/test12.cmm @@ -0,0 +1,5 @@ +int main() +{ + int i[10]; + i[1.5] = 10; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test12.output b/Test/senamic_test/simple_test/test12.output new file mode 100644 index 0000000000000000000000000000000000000000..991b07420e481a7d50c8d835f82ae58a8cba1200 --- /dev/null +++ b/Test/senamic_test/simple_test/test12.output @@ -0,0 +1 @@ +Error type 12 at Line 4: Not an integer "[" diff --git a/Test/senamic_test/simple_test/test13.cmm b/Test/senamic_test/simple_test/test13.cmm new file mode 100755 index 0000000000000000000000000000000000000000..dea840634c530b23b9afcb9c6594a390fdd1c6bd --- /dev/null +++ b/Test/senamic_test/simple_test/test13.cmm @@ -0,0 +1,10 @@ +struct Position +{ + float x, y; +}; + +int main() +{ + int i; + i.x; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test13.output b/Test/senamic_test/simple_test/test13.output new file mode 100644 index 0000000000000000000000000000000000000000..418049d43e492aa2d679d12efb44eb6c1b97a639 --- /dev/null +++ b/Test/senamic_test/simple_test/test13.output @@ -0,0 +1 @@ +Error type 13 at Line 9: Illegal use of "." diff --git a/Test/senamic_test/simple_test/test14.cmm b/Test/senamic_test/simple_test/test14.cmm new file mode 100755 index 0000000000000000000000000000000000000000..83c7f6f1fae27032b75c2a9c9433bc69e557a068 --- /dev/null +++ b/Test/senamic_test/simple_test/test14.cmm @@ -0,0 +1,11 @@ +struct Position +{ + float x, y; +}; + +int main() +{ + struct Position p; + if(p.n == 3.7) + return 0; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test14.output b/Test/senamic_test/simple_test/test14.output new file mode 100644 index 0000000000000000000000000000000000000000..de02fa0a00733658481fed203a53d5111efed898 --- /dev/null +++ b/Test/senamic_test/simple_test/test14.output @@ -0,0 +1,2 @@ +Error type 14 at Line 9: Non-existent field "n" +Error type 7 at Line 9: Type mismatched for operands "==" diff --git a/Test/senamic_test/simple_test/test15.cmm b/Test/senamic_test/simple_test/test15.cmm new file mode 100755 index 0000000000000000000000000000000000000000..b1b27e26bad6581f37451c532ae7c79bd5984a15 --- /dev/null +++ b/Test/senamic_test/simple_test/test15.cmm @@ -0,0 +1,9 @@ +struct Position +{ + float x, y; + int x; +}; + +int main() +{ +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test15.output b/Test/senamic_test/simple_test/test15.output new file mode 100644 index 0000000000000000000000000000000000000000..dcc3b02fef8e8cfd64ecdebc547a5c6ee69cb035 --- /dev/null +++ b/Test/senamic_test/simple_test/test15.output @@ -0,0 +1 @@ +Error type 15 at Line 4: Struct redefined field or assign "x" diff --git a/Test/senamic_test/simple_test/test16.cmm b/Test/senamic_test/simple_test/test16.cmm new file mode 100755 index 0000000000000000000000000000000000000000..77e3fb25c0e10b68d7d12712528d474bd81c9198 --- /dev/null +++ b/Test/senamic_test/simple_test/test16.cmm @@ -0,0 +1,9 @@ +struct Position +{ + float x; +}; + +struct Position +{ + int y; +}; \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test16.output b/Test/senamic_test/simple_test/test16.output new file mode 100644 index 0000000000000000000000000000000000000000..e39eed6aef131eb198ee7841621e6c01da38220c --- /dev/null +++ b/Test/senamic_test/simple_test/test16.output @@ -0,0 +1 @@ +Error type 16 at Line 6: Duplicated name struct "Position" diff --git a/Test/senamic_test/simple_test/test17.cmm b/Test/senamic_test/simple_test/test17.cmm new file mode 100755 index 0000000000000000000000000000000000000000..5ed3ee975787279673247240adc7775c9786e9a4 --- /dev/null +++ b/Test/senamic_test/simple_test/test17.cmm @@ -0,0 +1,4 @@ +int main() +{ + struct Position pos; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test17.output b/Test/senamic_test/simple_test/test17.output new file mode 100644 index 0000000000000000000000000000000000000000..e6c9899ddac1db1b760ade807d43a5b34ec3bdd3 --- /dev/null +++ b/Test/senamic_test/simple_test/test17.output @@ -0,0 +1 @@ +Error type 17 at Line 3: None Defined Struct "Position" diff --git a/Test/senamic_test/simple_test/test2.cmm b/Test/senamic_test/simple_test/test2.cmm new file mode 100755 index 0000000000000000000000000000000000000000..88d715f079954a754d0cfbf6de2603e91db0f8ea --- /dev/null +++ b/Test/senamic_test/simple_test/test2.cmm @@ -0,0 +1,5 @@ +int main() +{ + int i = 0; + inc(i); +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test2.output b/Test/senamic_test/simple_test/test2.output new file mode 100644 index 0000000000000000000000000000000000000000..45b9e89aa9e68e6f5a98d7b9ee12b2b9f4e4b677 --- /dev/null +++ b/Test/senamic_test/simple_test/test2.output @@ -0,0 +1 @@ +Error type 2 at Line 4: Undefined function "inc" diff --git a/Test/senamic_test/simple_test/test3.cmm b/Test/senamic_test/simple_test/test3.cmm new file mode 100755 index 0000000000000000000000000000000000000000..4adc2a643dccd8994d5aee469c7353d6c06a8b0e --- /dev/null +++ b/Test/senamic_test/simple_test/test3.cmm @@ -0,0 +1,5 @@ +int main() +{ + int i, j; + int i; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test3.output b/Test/senamic_test/simple_test/test3.output new file mode 100644 index 0000000000000000000000000000000000000000..9ffd7fc3801d081248594454a7b6c7be15c31fda --- /dev/null +++ b/Test/senamic_test/simple_test/test3.output @@ -0,0 +1 @@ +Error type 3 at Line 4: Redefined variable "i" diff --git a/Test/senamic_test/simple_test/test4.cmm b/Test/senamic_test/simple_test/test4.cmm new file mode 100755 index 0000000000000000000000000000000000000000..e952aedda354dc6993f6c4225c23098fae592213 --- /dev/null +++ b/Test/senamic_test/simple_test/test4.cmm @@ -0,0 +1,14 @@ +int func(int i) +{ + return i; +} + +int func() +{ + return 0; +} + +int main() +{ + +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test4.output b/Test/senamic_test/simple_test/test4.output new file mode 100644 index 0000000000000000000000000000000000000000..0a07bd5086fe47ce2178b9d289dad2e5f423af9c --- /dev/null +++ b/Test/senamic_test/simple_test/test4.output @@ -0,0 +1 @@ +Error type 4 at Line 6: Redefined function "func" diff --git a/Test/senamic_test/simple_test/test5.cmm b/Test/senamic_test/simple_test/test5.cmm new file mode 100755 index 0000000000000000000000000000000000000000..674c1ea0d1caa4d235b92b0bcbf69aaff907288d --- /dev/null +++ b/Test/senamic_test/simple_test/test5.cmm @@ -0,0 +1,5 @@ +int main() +{ + int i; + i = 3.7; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test5.output b/Test/senamic_test/simple_test/test5.output new file mode 100644 index 0000000000000000000000000000000000000000..6f7faa6042a1008c45e92cd0a017abbba1881949 --- /dev/null +++ b/Test/senamic_test/simple_test/test5.output @@ -0,0 +1 @@ +Error type 5 at Line 4: Type mismatched for assignment "=" diff --git a/Test/senamic_test/simple_test/test6.cmm b/Test/senamic_test/simple_test/test6.cmm new file mode 100755 index 0000000000000000000000000000000000000000..a18c6f95dd03513f2d461255f3b4267898f81c57 --- /dev/null +++ b/Test/senamic_test/simple_test/test6.cmm @@ -0,0 +1,5 @@ +int main() +{ + int i; + 10 = i; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test6.output b/Test/senamic_test/simple_test/test6.output new file mode 100644 index 0000000000000000000000000000000000000000..366f4587c1d02bf951d89504c90a5e22304ffbc7 --- /dev/null +++ b/Test/senamic_test/simple_test/test6.output @@ -0,0 +1 @@ +Error type 6 at Line 4: The left-hand side of an assignment must be a variable "=" diff --git a/Test/senamic_test/simple_test/test7.cmm b/Test/senamic_test/simple_test/test7.cmm new file mode 100755 index 0000000000000000000000000000000000000000..cf2430394ea45093789ac81496809934b98f5491 --- /dev/null +++ b/Test/senamic_test/simple_test/test7.cmm @@ -0,0 +1,5 @@ +int main() +{ + float j; + 10 + j; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test7.output b/Test/senamic_test/simple_test/test7.output new file mode 100644 index 0000000000000000000000000000000000000000..65461aecc3ca95fefe69199af7016bc99187f790 --- /dev/null +++ b/Test/senamic_test/simple_test/test7.output @@ -0,0 +1 @@ +Error type 7 at Line 4: Type mismatched for operands "" diff --git a/Test/senamic_test/simple_test/test8.cmm b/Test/senamic_test/simple_test/test8.cmm new file mode 100755 index 0000000000000000000000000000000000000000..3c34b7710e8951eee16d5226e1cdb1072355d92e --- /dev/null +++ b/Test/senamic_test/simple_test/test8.cmm @@ -0,0 +1,5 @@ +int main() +{ + float j = 1.7; + return j; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test8.output b/Test/senamic_test/simple_test/test8.output new file mode 100644 index 0000000000000000000000000000000000000000..c262973ad78910f1bfe25ee557b95644babd1178 --- /dev/null +++ b/Test/senamic_test/simple_test/test8.output @@ -0,0 +1 @@ +Error type 8 at Line 4: Type mismatched for return "return" diff --git a/Test/senamic_test/simple_test/test9.cmm b/Test/senamic_test/simple_test/test9.cmm new file mode 100755 index 0000000000000000000000000000000000000000..2351f2f93f49fb6d5e7ff7c2f7fb68bbe2c9bee0 --- /dev/null +++ b/Test/senamic_test/simple_test/test9.cmm @@ -0,0 +1,9 @@ +int func(int i) +{ + return i; +} + +int main() +{ + func(1, 2); +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test9.output b/Test/senamic_test/simple_test/test9.output new file mode 100644 index 0000000000000000000000000000000000000000..e5f25a7589a56d0a40acf827d3b6551203b68f0d --- /dev/null +++ b/Test/senamic_test/simple_test/test9.output @@ -0,0 +1 @@ +Error type 9 at Line 8: Function is not applicable for arguments "" diff --git a/Test/senamic_test/simple_test/test_op1.cmm b/Test/senamic_test/simple_test/test_op1.cmm new file mode 100755 index 0000000000000000000000000000000000000000..617d927ef2b70154b4a9dd97b6389a5e9375a1b3 --- /dev/null +++ b/Test/senamic_test/simple_test/test_op1.cmm @@ -0,0 +1,10 @@ +int func(int a); + +int func(int a) +{ + return 1; +} + +int main() +{ +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test_op1.output b/Test/senamic_test/simple_test/test_op1.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/senamic_test/simple_test/test_op2.cmm b/Test/senamic_test/simple_test/test_op2.cmm new file mode 100755 index 0000000000000000000000000000000000000000..b6799821ddb5d82f7907d6e97d587b80c4cb8638 --- /dev/null +++ b/Test/senamic_test/simple_test/test_op2.cmm @@ -0,0 +1,13 @@ +struct Position +{ + float x, y; +}; + +int func(int a); + +int func(struct Position p); + +int main() +{ + +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test_op2.output b/Test/senamic_test/simple_test/test_op2.output new file mode 100644 index 0000000000000000000000000000000000000000..231d33c8ebee502f07090f86a32215cb2db126b7 --- /dev/null +++ b/Test/senamic_test/simple_test/test_op2.output @@ -0,0 +1,2 @@ +Error type 19 at Line 8: Inconsistent declaration of function "func" +Error type 18 at Line 6: Undefined function "func" diff --git a/Test/senamic_test/simple_test/test_op3.cmm b/Test/senamic_test/simple_test/test_op3.cmm new file mode 100755 index 0000000000000000000000000000000000000000..a3506a1d24d5e1e961f7915c6bf0c54aaae272ac --- /dev/null +++ b/Test/senamic_test/simple_test/test_op3.cmm @@ -0,0 +1,11 @@ +int func() +{ + int i = 10; + return i; +} + +int main() +{ + int i; + i = func(); +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test_op3.output b/Test/senamic_test/simple_test/test_op3.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/senamic_test/simple_test/test_op4.cmm b/Test/senamic_test/simple_test/test_op4.cmm new file mode 100755 index 0000000000000000000000000000000000000000..768175551af6b6c7fe5492a010dcef71d5d38893 --- /dev/null +++ b/Test/senamic_test/simple_test/test_op4.cmm @@ -0,0 +1,12 @@ +int func() +{ + int i = 10; + return i; +} + +int main() +{ + int i; + int i, j; + i = func(); +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test_op4.output b/Test/senamic_test/simple_test/test_op4.output new file mode 100644 index 0000000000000000000000000000000000000000..b0e87ea5e193415566dcf9c08ad96ad3d01a696a --- /dev/null +++ b/Test/senamic_test/simple_test/test_op4.output @@ -0,0 +1 @@ +Error type 3 at Line 10: Redefined variable "i" diff --git a/Test/senamic_test/simple_test/test_op5.cmm b/Test/senamic_test/simple_test/test_op5.cmm new file mode 100755 index 0000000000000000000000000000000000000000..b15e7ff82b1a54130f72bc786cfd8820254f03e6 --- /dev/null +++ b/Test/senamic_test/simple_test/test_op5.cmm @@ -0,0 +1,18 @@ +struct Temp1 +{ + int i; + float j; +}; + +struct Temp2 +{ + int x; + float y; +}; + +int main() +{ + struct Temp1 t1; + struct Temp2 t2; + t1 = t2; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test_op5.output b/Test/senamic_test/simple_test/test_op5.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/senamic_test/simple_test/test_op6.cmm b/Test/senamic_test/simple_test/test_op6.cmm new file mode 100755 index 0000000000000000000000000000000000000000..2e08b83654afefc55eb3d1855890a0a44a816dfe --- /dev/null +++ b/Test/senamic_test/simple_test/test_op6.cmm @@ -0,0 +1,17 @@ +struct Temp1 +{ + int i; + float j; +}; + +struct Temp2 +{ + int x; +}; + +int main() +{ + struct Temp1 t1; + struct Temp2 t2; + t1 = t2; +} \ No newline at end of file diff --git a/Test/senamic_test/simple_test/test_op6.output b/Test/senamic_test/simple_test/test_op6.output new file mode 100644 index 0000000000000000000000000000000000000000..83cbeac3f97a763cd379d4d8a70408d4c77fe141 --- /dev/null +++ b/Test/senamic_test/simple_test/test_op6.output @@ -0,0 +1 @@ +Error type 5 at Line 16: Type mismatched for assignment "=" diff --git a/Test/senamic_test/zzm_test/test1.cmm b/Test/senamic_test/zzm_test/test1.cmm new file mode 100755 index 0000000000000000000000000000000000000000..a959811d1bf34977c04c86776d0cc98849c4cee1 --- /dev/null +++ b/Test/senamic_test/zzm_test/test1.cmm @@ -0,0 +1,27 @@ +// 1-10 +struct A{ + int aa; + +}; + +struct A func1(){return 1.0;} // 8 + +struct A func1(){return 1;} // 8 4 + +int Func(){ + return 1; +} + +int main(){ + + struct A a1; + int a1; //3 + float f = 1 + 100; //5 + int ai[100]; + float fi[100]; + variable = func(); //1 2 + 101 = f; // 6 + if (a + 100 == 1) //7 + Func(); + Func(a1[100]); //9 10 +} diff --git a/Test/senamic_test/zzm_test/test1.output b/Test/senamic_test/zzm_test/test1.output new file mode 100644 index 0000000000000000000000000000000000000000..02f788ffc0fa8661daf6ffdd1daf637f41edba92 --- /dev/null +++ b/Test/senamic_test/zzm_test/test1.output @@ -0,0 +1,13 @@ +Error type 8 at Line 7: Type mismatched for return "return" +Error type 4 at Line 9: Redefined function "func1" +Error type 8 at Line 9: Type mismatched for return "return" +Error type 3 at Line 18: Redefined variable "a1" +Error type 5 at Line 19: Type mismatched for assignment "=" +Error type 1 at Line 22: Undefined variable "variable" +Error type 2 at Line 22: Undefined function "func" +Error type 5 at Line 23: Type mismatched for assignment "=" +Error type 6 at Line 23: The left-hand side of an assignment must be a variable "=" +Error type 1 at Line 24: Undefined variable "a" +Error type 7 at Line 24: Type mismatched for operands "" +Error type 7 at Line 24: Type mismatched for operands "==" +Error type 9 at Line 26: Function is not applicable for arguments "Func" diff --git a/Test/senamic_test/zzm_test/test10.cmm b/Test/senamic_test/zzm_test/test10.cmm new file mode 100755 index 0000000000000000000000000000000000000000..514a4b0adaff53624cc380acb99e1c5b25b64e25 --- /dev/null +++ b/Test/senamic_test/zzm_test/test10.cmm @@ -0,0 +1,26 @@ + + + +int main(int a[2][2], int b[2][4]){ + int a1[4][5], b1[6][7]; + int a2[10][4], b2[5][4]; + a[0][0] = b[1][3]; + + a[1] = b[2]; // 5 + + + + a[1][2] = b1[4][5]; + + b1[2][3] = b1[3][2]; + + b1[2] = b1[0]; + + + + a2[4] = b2[1]; + + + + return 1; +} diff --git a/Test/senamic_test/zzm_test/test10.output b/Test/senamic_test/zzm_test/test10.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/senamic_test/zzm_test/test2.cmm b/Test/senamic_test/zzm_test/test2.cmm new file mode 100755 index 0000000000000000000000000000000000000000..e3ba0deaae6375031d1f59db64c5efbaa8b4d78e --- /dev/null +++ b/Test/senamic_test/zzm_test/test2.cmm @@ -0,0 +1,29 @@ +struct A{ + int i; + float f; +}; + +struct B{ + int aa = 123; +}; // 15 + +struct C{ + int aaa; + float aaa; +}; // 15 + +int main(){ + int arr[2][3][4]; + int a1; + struct A sa; + struct A a1; //16 + struct D d1; //17 + arr[1][2][1.0] = 1; // 12 + a1(); // 11 + a1.a; // 13 + sa.i = 1; + sa.f = 1.0; + sa.j = 123; // 14 + + return 1; +} diff --git a/Test/senamic_test/zzm_test/test2.output b/Test/senamic_test/zzm_test/test2.output new file mode 100644 index 0000000000000000000000000000000000000000..039be99d58828f580880566f6f0bcf1dcdbcba07 --- /dev/null +++ b/Test/senamic_test/zzm_test/test2.output @@ -0,0 +1,9 @@ +Error type 15 at Line 7: Struct redefined field or assign "=" +Error type 15 at Line 12: Struct redefined field or assign "aaa" +Error type 3 at Line 19: Redefined variable "a1" +Error type 17 at Line 20: None Defined Struct "D" +Error type 12 at Line 21: Not an integer "[" +Error type 11 at Line 22: Not a function "a1" +Error type 13 at Line 23: Illegal use of "." +Error type 14 at Line 26: Non-existent field "j" +Error type 5 at Line 26: Type mismatched for assignment "=" diff --git a/Test/senamic_test/zzm_test/test3.cmm b/Test/senamic_test/zzm_test/test3.cmm new file mode 100755 index 0000000000000000000000000000000000000000..08403af5f2b90230b4973f129842bb0d0a831bc1 --- /dev/null +++ b/Test/senamic_test/zzm_test/test3.cmm @@ -0,0 +1,9 @@ +int func(); // 18 + +int func1(); // 18 +int func1(int a); //19 + +int main(){ + func1(); //2 + return 1; +} diff --git a/Test/senamic_test/zzm_test/test3.output b/Test/senamic_test/zzm_test/test3.output new file mode 100644 index 0000000000000000000000000000000000000000..07e944327a07408ef3f019cd4ea0c320c171c450 --- /dev/null +++ b/Test/senamic_test/zzm_test/test3.output @@ -0,0 +1,3 @@ +Error type 19 at Line 4: Inconsistent declaration of function "func1" +Error type 18 at Line 3: Undefined function "func1" +Error type 18 at Line 1: Undefined function "func" diff --git a/Test/senamic_test/zzm_test/test4.cmm b/Test/senamic_test/zzm_test/test4.cmm new file mode 100755 index 0000000000000000000000000000000000000000..292ad8686f2a32d21622a668eeb4818a6d045d10 --- /dev/null +++ b/Test/senamic_test/zzm_test/test4.cmm @@ -0,0 +1,13 @@ +//瑕佹眰2.2 +int main(){ + int a1 = 1; + int a = 2; + if (1){ + int a1 = 2; + if (a1 == 2) + a = 1; + } + if (a == 1) + a = 1; + return 1; +} \ No newline at end of file diff --git a/Test/senamic_test/zzm_test/test4.output b/Test/senamic_test/zzm_test/test4.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/senamic_test/zzm_test/test5.cmm b/Test/senamic_test/zzm_test/test5.cmm new file mode 100755 index 0000000000000000000000000000000000000000..4c50b36d08f919945d3ee3266212783dc7359865 --- /dev/null +++ b/Test/senamic_test/zzm_test/test5.cmm @@ -0,0 +1,26 @@ +// 瑕佹眰2.3 +struct A{ + int a[2][3]; + float f; + int aa; +}; + +struct B{ + int b[2][3]; + float ff; + int bb; +}; + +int main(){ + struct A a; + struct B b; + a.f = 1.0; + a.aa = 1; + a.a[0][0] = 0; + + b = a; + if (b.ff != 1.0 || b.bb != 1){} + + return 1; + +} diff --git a/Test/senamic_test/zzm_test/test5.output b/Test/senamic_test/zzm_test/test5.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/senamic_test/zzm_test/test6.cmm b/Test/senamic_test/zzm_test/test6.cmm new file mode 100755 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/senamic_test/zzm_test/test6.output b/Test/senamic_test/zzm_test/test6.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/senamic_test/zzm_test/test7.cmm b/Test/senamic_test/zzm_test/test7.cmm new file mode 100755 index 0000000000000000000000000000000000000000..3d406d71fc390ae90b1988718628b2215b0997df --- /dev/null +++ b/Test/senamic_test/zzm_test/test7.cmm @@ -0,0 +1,25 @@ +//瑕佹眰2.3 +struct A{ + int a; +}; + +struct AA{ + int aa; +}; + +struct B{ + struct A sa[10]; + struct AA saa[2]; +}; + +struct BB{ + struct AA ssaa[10]; + struct A ssa[2]; +}; + +int main(){ + struct B sb; + struct BB sbb; + sbb = sb; + return 1; +} \ No newline at end of file diff --git a/Test/senamic_test/zzm_test/test7.output b/Test/senamic_test/zzm_test/test7.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/senamic_test/zzm_test/test8.cmm b/Test/senamic_test/zzm_test/test8.cmm new file mode 100755 index 0000000000000000000000000000000000000000..c8fc7acf3679701693bec22db373d4db466573db --- /dev/null +++ b/Test/senamic_test/zzm_test/test8.cmm @@ -0,0 +1,14 @@ +int func(); + + +int main(int i, float j){ + if (func() == 1) + i = 3; + func[1]; // 10 + + return 1; +} + +int func(){ + return 1; +} diff --git a/Test/senamic_test/zzm_test/test8.output b/Test/senamic_test/zzm_test/test8.output new file mode 100644 index 0000000000000000000000000000000000000000..dff9a995aeeec658782be44cdebcae929322fe12 --- /dev/null +++ b/Test/senamic_test/zzm_test/test8.output @@ -0,0 +1 @@ +Error type 10 at Line 7: Variable is not an array "[" diff --git a/Test/senamic_test/zzm_test/test9.cmm b/Test/senamic_test/zzm_test/test9.cmm new file mode 100755 index 0000000000000000000000000000000000000000..d6f8008edcca8d32fb0c2ca31b97b7d2b2228aec --- /dev/null +++ b/Test/senamic_test/zzm_test/test9.cmm @@ -0,0 +1,16 @@ +struct A{ + int a; +}; + +struct A sa; + +struct sa{ // 16 + float j; +}; + +int main() +{ + sa.a = 1; + sa.b = 1; // 14 + return 1; +} \ No newline at end of file diff --git a/Test/senamic_test/zzm_test/test9.output b/Test/senamic_test/zzm_test/test9.output new file mode 100644 index 0000000000000000000000000000000000000000..17b20b5d4aa43684804d8c66c84ffa7bb07cbacd --- /dev/null +++ b/Test/senamic_test/zzm_test/test9.output @@ -0,0 +1,3 @@ +Error type 16 at Line 7: Duplicated name struct "sa" +Error type 14 at Line 14: Non-existent field "b" +Error type 5 at Line 14: Type mismatched for assignment "=" diff --git a/Test/test.cmm b/Test/test.cmm index c915ef473312fcb275afbcf3bb46df60cdef2738..4b27e2ac53442b68b8f00d2b235dfe334fe82f3a 100644 --- a/Test/test.cmm +++ b/Test/test.cmm @@ -1,136 +1,9 @@ -int global1, global2; - -int; - -/* anonymous structure */ -struct -{ - int field1; -}; - -struct -{ - int field1; - float field2; -} s1, s2; - -/* structure */ -struct Complex -{ - int real; - int imag; -} c1, c2, carray[100], multi_dim[1][2][3]; - -/* nested structure */ -struct Complex_pair -{ - struct Complex x; - struct Complex y; - struct withname - { - int field; - } s1; - struct - { - float field; - } s2; -}; - -// Note: function declaration not allowed - -int main() -{ - /* local variable declarations */ - int a; - int barray[10][2]; - int i = 0; - int a1, a2, a3; - struct Complex c; - struct Complex_pair cp; - - /* main body */ - nonexist_func(1, 2, a, barray[1], barray); - 1; - { - int x; +int main() { + int a,b,c; + if(a == 1 || b == 2 && c == 3) { + return 0; } - - true = 1; - false = true - 1; - if (true) { - return false; + if(a == 1 && b == 2 || c == 3) { + return 0; } - - /* dangling-else problem */ - if (a && true) - if (a && false) - return true; - else - return which_if; - - while (i > 0) { - i = i + 1; - if (some_condition(1, 2, 3)) { - do_nothing(); - } - } - - /* member access */ - c.imag = 1; - c.real = 2; - c.real = c.imag + c.real; - cp.s1.field = 1; - multi_dim[0][some_func()][0].real = 1; - - /* precedence of operators */ - non_exist_bool = true && false || (1 + 2) != (1 + 2 * 3) - > barray[7] <= c.imag = (!a / 8) == 9; - - /* associativity of operators */ - a = -- --b; - a = !!!!!b; - a = b * c * d; - a = b / c / d; - a = b + c + d; - a = b - c - d; - a = b < c < d; - a = b <= c <= d; - a = b > c > d; - a = b >= c >= d; - a = b == c == d; - a = b != c != d; - a = b && c && d; - a = b || c || d; - a = b = c = d = 1; - - return nonexist_func(); -} - -/* - * block comment - * @#$%^&*() - */ - -// line comment #$%^&*()~!@#$%^&*()_+ - -/* function definition */ -int func(int ival, float fval, float arr[10]) -{ - int a = 1; -} - -/* Extra requirements */ - -int extra() -{ - int oct1 = 0123; - int oct2 = 00000000010; - int oct3 = -007; - int hex1 = 0x3f; - int hex2 = 0XABCDEF; - int hex3 = 0xAbCdEf; - float f1 = 1.05e-4; - float f2 = 1.0e111; - float f3 = 0.77e111; - float f4 = 7.0e11; -} +} \ No newline at end of file diff --git a/Test/test/h1.output b/Test/test/h1.output new file mode 100644 index 0000000000000000000000000000000000000000..c0ce6457ab08a7c2e3993048d9b7e8edca6796a9 --- /dev/null +++ b/Test/test/h1.output @@ -0,0 +1,240 @@ +Error type 2 at Line 100: Undefined function "write" +Error type 2 at Line 101: Undefined function "write" +Error type 2 at Line 128: Undefined function "write" +Error type 2 at Line 134: Undefined function "write" +Error type 2 at Line 135: Undefined function "write" +Error type 2 at Line 136: Undefined function "write" +Error type 2 at Line 137: Undefined function "write" +Error type 2 at Line 189: Undefined function "write" +Error type 2 at Line 190: Undefined function "write" +Error type 2 at Line 206: Undefined function "write" +Error type 2 at Line 207: Undefined function "write" +Error type 2 at Line 208: Undefined function "write" +Error type 2 at Line 209: Undefined function "write" +Error type 2 at Line 210: Undefined function "write" +Error type 2 at Line 211: Undefined function "write" +Error type 2 at Line 212: Undefined function "write" +Error type 2 at Line 213: Undefined function "write" +Error type 2 at Line 214: Undefined function "write" +Error type 2 at Line 215: Undefined function "write" +Error type 2 at Line 216: Undefined function "write" +Error type 2 at Line 281: Undefined function "write" +Error type 2 at Line 282: Undefined function "write" +Error type 2 at Line 310: Undefined function "write" +Error type 2 at Line 311: Undefined function "write" +Error type 2 at Line 316: Undefined function "write" +Error type 2 at Line 317: Undefined function "write" +Error type 2 at Line 318: Undefined function "write" +Error type 2 at Line 319: Undefined function "write" +Error type 2 at Line 320: Undefined function "write" +Error type 2 at Line 321: Undefined function "write" +Error type 2 at Line 322: Undefined function "write" +Error type 2 at Line 323: Undefined function "write" +Error type 2 at Line 324: Undefined function "write" +Error type 2 at Line 370: Undefined function "write" +Error type 2 at Line 371: Undefined function "write" +Error type 2 at Line 372: Undefined function "write" +Error type 2 at Line 400: Undefined function "write" +Error type 2 at Line 401: Undefined function "write" +Error type 2 at Line 402: Undefined function "write" +Error type 2 at Line 440: Undefined function "write" +Error type 2 at Line 441: Undefined function "write" +Error type 2 at Line 481: Undefined function "write" +Error type 2 at Line 482: Undefined function "write" +Error type 2 at Line 483: Undefined function "write" +Error type 2 at Line 484: Undefined function "write" +Error type 2 at Line 485: Undefined function "write" +Error type 2 at Line 486: Undefined function "write" +Error type 2 at Line 487: Undefined function "write" +Error type 2 at Line 497: Undefined function "write" +Error type 2 at Line 500: Undefined function "write" +Error type 2 at Line 501: Undefined function "write" +Error type 2 at Line 585: Undefined function "write" +Error type 2 at Line 586: Undefined function "write" +Error type 2 at Line 618: Undefined function "write" +Error type 2 at Line 619: Undefined function "write" +Error type 2 at Line 629: Undefined function "write" +Error type 2 at Line 630: Undefined function "write" +Error type 2 at Line 672: Undefined function "write" +Error type 2 at Line 673: Undefined function "write" +Error type 2 at Line 699: Undefined function "write" +Error type 2 at Line 700: Undefined function "write" +Error type 2 at Line 701: Undefined function "write" +Error type 2 at Line 708: Undefined function "write" +Error type 2 at Line 711: Undefined function "write" +Error type 2 at Line 712: Undefined function "write" +Error type 2 at Line 713: Undefined function "write" +Error type 2 at Line 714: Undefined function "write" +Error type 2 at Line 715: Undefined function "write" +Error type 2 at Line 716: Undefined function "write" +Error type 2 at Line 717: Undefined function "write" +Error type 2 at Line 718: Undefined function "write" +Error type 2 at Line 805: Undefined function "write" +Error type 2 at Line 806: Undefined function "write" +Error type 2 at Line 811: Undefined function "write" +Error type 2 at Line 812: Undefined function "write" +Error type 2 at Line 813: Undefined function "write" +Error type 2 at Line 887: Undefined function "write" +Error type 2 at Line 888: Undefined function "write" +Error type 2 at Line 889: Undefined function "write" +Error type 2 at Line 966: Undefined function "write" +Error type 2 at Line 971: Undefined function "write" +Error type 2 at Line 972: Undefined function "write" +Error type 2 at Line 973: Undefined function "write" +Error type 2 at Line 974: Undefined function "write" +Error type 2 at Line 1024: Undefined function "write" +Error type 2 at Line 1025: Undefined function "write" +Error type 2 at Line 1055: Undefined function "write" +Error type 2 at Line 1056: Undefined function "write" +Error type 2 at Line 1057: Undefined function "write" +Error type 2 at Line 1091: Undefined function "write" +Error type 2 at Line 1092: Undefined function "write" +Error type 2 at Line 1093: Undefined function "write" +Error type 2 at Line 1100: Undefined function "write" +Error type 2 at Line 1101: Undefined function "write" +Error type 2 at Line 1102: Undefined function "write" +Error type 2 at Line 1145: Undefined function "write" +Error type 2 at Line 1146: Undefined function "write" +Error type 2 at Line 1147: Undefined function "write" +Error type 2 at Line 1171: Undefined function "write" +Error type 2 at Line 1195: Undefined function "write" +Error type 2 at Line 1226: Undefined function "write" +Error type 2 at Line 1227: Undefined function "write" +Error type 2 at Line 1232: Undefined function "write" +Error type 2 at Line 1233: Undefined function "write" +Error type 2 at Line 1239: Undefined function "write" +Error type 2 at Line 1240: Undefined function "write" +Error type 2 at Line 1241: Undefined function "write" +Error type 2 at Line 1242: Undefined function "write" +Error type 2 at Line 1243: Undefined function "write" +Error type 2 at Line 1244: Undefined function "write" +Error type 2 at Line 1323: Undefined function "write" +Error type 2 at Line 1364: Undefined function "write" +Error type 2 at Line 1365: Undefined function "write" +Error type 2 at Line 1366: Undefined function "write" +Error type 2 at Line 1430: Undefined function "write" +Error type 2 at Line 1431: Undefined function "write" +Error type 2 at Line 1432: Undefined function "write" +Error type 2 at Line 1433: Undefined function "write" +Error type 2 at Line 1464: Undefined function "write" +Error type 2 at Line 1495: Undefined function "write" +Error type 2 at Line 1496: Undefined function "write" +Error type 2 at Line 1517: Undefined function "write" +Error type 2 at Line 1518: Undefined function "write" +Error type 2 at Line 1548: Undefined function "write" +Error type 2 at Line 1554: Undefined function "write" +Error type 2 at Line 1555: Undefined function "write" +Error type 2 at Line 1560: Undefined function "write" +Error type 2 at Line 1561: Undefined function "write" +Error type 2 at Line 1562: Undefined function "write" +Error type 2 at Line 1655: Undefined function "write" +Error type 2 at Line 1656: Undefined function "write" +Error type 2 at Line 1657: Undefined function "write" +Error type 2 at Line 1704: Undefined function "write" +Error type 2 at Line 1727: Undefined function "write" +Error type 2 at Line 1765: Undefined function "write" +Error type 2 at Line 1770: Undefined function "write" +Error type 2 at Line 1771: Undefined function "write" +Error type 2 at Line 1772: Undefined function "write" +Error type 2 at Line 1784: Undefined function "write" +Error type 2 at Line 1785: Undefined function "write" +Error type 2 at Line 1786: Undefined function "write" +Error type 2 at Line 1787: Undefined function "write" +Error type 2 at Line 1788: Undefined function "write" +Error type 2 at Line 1789: Undefined function "write" +Error type 2 at Line 1790: Undefined function "write" +Error type 2 at Line 1791: Undefined function "write" +Error type 2 at Line 1860: Undefined function "write" +Error type 2 at Line 1861: Undefined function "write" +Error type 2 at Line 1862: Undefined function "write" +Error type 2 at Line 1870: Undefined function "write" +Error type 2 at Line 1871: Undefined function "write" +Error type 2 at Line 1874: Undefined function "write" +Error type 2 at Line 1875: Undefined function "write" +Error type 2 at Line 1876: Undefined function "write" +Error type 2 at Line 1877: Undefined function "write" +Error type 2 at Line 1979: Undefined function "write" +Error type 2 at Line 1980: Undefined function "write" +Error type 2 at Line 1981: Undefined function "write" +Error type 2 at Line 2005: Undefined function "write" +Error type 2 at Line 2016: Undefined function "write" +Error type 2 at Line 2026: Undefined function "write" +Error type 2 at Line 2027: Undefined function "write" +Error type 2 at Line 2100: Undefined function "write" +Error type 2 at Line 2137: Undefined function "write" +Error type 2 at Line 2138: Undefined function "write" +Error type 2 at Line 2139: Undefined function "write" +Error type 2 at Line 2176: Undefined function "write" +Error type 2 at Line 2179: Undefined function "write" +Error type 2 at Line 2180: Undefined function "write" +Error type 2 at Line 2181: Undefined function "write" +Error type 2 at Line 2217: Undefined function "write" +Error type 2 at Line 2268: Undefined function "write" +Error type 2 at Line 2269: Undefined function "write" +Error type 2 at Line 2270: Undefined function "write" +Error type 2 at Line 2271: Undefined function "write" +Error type 2 at Line 2272: Undefined function "write" +Error type 2 at Line 2273: Undefined function "write" +Error type 2 at Line 2276: Undefined function "write" +Error type 2 at Line 2283: Undefined function "write" +Error type 2 at Line 2358: Undefined function "write" +Error type 2 at Line 2359: Undefined function "write" +Error type 2 at Line 2379: Undefined function "write" +Error type 2 at Line 2384: Undefined function "write" +Error type 2 at Line 2385: Undefined function "write" +Error type 2 at Line 2427: Undefined function "write" +Error type 2 at Line 2472: Undefined function "write" +Error type 2 at Line 2473: Undefined function "write" +Error type 2 at Line 2526: Undefined function "write" +Error type 2 at Line 2527: Undefined function "write" +Error type 2 at Line 2560: Undefined function "write" +Error type 2 at Line 2561: Undefined function "write" +Error type 2 at Line 2562: Undefined function "write" +Error type 2 at Line 2589: Undefined function "write" +Error type 2 at Line 2590: Undefined function "write" +Error type 2 at Line 2591: Undefined function "write" +Error type 2 at Line 2619: Undefined function "write" +Error type 2 at Line 2650: Undefined function "write" +Error type 2 at Line 2679: Undefined function "write" +Error type 2 at Line 2680: Undefined function "write" +Error type 2 at Line 2703: Undefined function "write" +Error type 2 at Line 2704: Undefined function "write" +Error type 2 at Line 2735: Undefined function "write" +Error type 2 at Line 2738: Undefined function "write" +Error type 2 at Line 2745: Undefined function "write" +Error type 2 at Line 2746: Undefined function "write" +Error type 2 at Line 2747: Undefined function "write" +Error type 2 at Line 2822: Undefined function "write" +Error type 2 at Line 2823: Undefined function "write" +Error type 2 at Line 2879: Undefined function "write" +Error type 2 at Line 2901: Undefined function "write" +Error type 2 at Line 2902: Undefined function "write" +Error type 2 at Line 2906: Undefined function "write" +Error type 2 at Line 2907: Undefined function "write" +Error type 2 at Line 2913: Undefined function "write" +Error type 2 at Line 2914: Undefined function "write" +Error type 2 at Line 2915: Undefined function "write" +Error type 2 at Line 2916: Undefined function "write" +Error type 2 at Line 2917: Undefined function "write" +Error type 2 at Line 2999: Undefined function "write" +Error type 2 at Line 3000: Undefined function "write" +Error type 2 at Line 3029: Undefined function "write" +Error type 2 at Line 3030: Undefined function "write" +Error type 2 at Line 3053: Undefined function "write" +Error type 2 at Line 3054: Undefined function "write" +Error type 2 at Line 3060: Undefined function "write" +Error type 2 at Line 3106: Undefined function "write" +Error type 2 at Line 3107: Undefined function "write" +Error type 2 at Line 3143: Undefined function "write" +Error type 2 at Line 3171: Undefined function "write" +Error type 2 at Line 3176: Undefined function "write" +Error type 2 at Line 3177: Undefined function "write" +Error type 2 at Line 3202: Undefined function "write" +Error type 2 at Line 3203: Undefined function "write" +Error type 2 at Line 3226: Undefined function "write" +Error type 2 at Line 3232: Undefined function "write" +Error type 2 at Line 3233: Undefined function "write" +Error type 2 at Line 3234: Undefined function "write" +Error type 2 at Line 3235: Undefined function "write" +Error type 2 at Line 3236: Undefined function "write" +Error type 2 at Line 3237: Undefined function "write" diff --git a/Test/test/m1.output b/Test/test/m1.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/test/m10.output b/Test/test/m10.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/test/m12.output b/Test/test/m12.output new file mode 100644 index 0000000000000000000000000000000000000000..26d30fdfac12f781d653efc47f641583fe019e8c --- /dev/null +++ b/Test/test/m12.output @@ -0,0 +1 @@ +Error type 5 at Line 26: Type mismatched for assignment "=" diff --git a/Test/test/m18.output b/Test/test/m18.output new file mode 100644 index 0000000000000000000000000000000000000000..401fa1176d234a61f20910e3e8e70cb2c893eb42 --- /dev/null +++ b/Test/test/m18.output @@ -0,0 +1,9 @@ +Error type 15 at Line 6: Struct redefined field or assign "=" +Error type 7 at Line 9: Type mismatched for operands "" +Error type 7 at Line 22: Type mismatched for operands "" +Error type 2 at Line 25: Undefined function "play_os_labs" +Error type 8 at Line 33: Type mismatched for return "return" +Error type 8 at Line 35: Type mismatched for return "return" +Error type 11 at Line 41: Not a function "argc" +Error type 10 at Line 42: Variable is not an array "[" +Error type 18 at Line 14: Undefined function "play_ff_14" diff --git a/Test/test/mytest1.output b/Test/test/mytest1.output new file mode 100644 index 0000000000000000000000000000000000000000..f7c16210bf5b4528a50aea465878c789ef737b50 --- /dev/null +++ b/Test/test/mytest1.output @@ -0,0 +1,17 @@ +Error type 1 at Line 23: Undefined variable "b" +Error type 2 at Line 25: Undefined function "non_exists_func" +Error type 3 at Line 28: Redefined variable "a" +Error type 4 at Line 33: Redefined function "func_1" +Error type 5 at Line 39: Type mismatched for assignment "=" +Error type 6 at Line 40: The left-hand side of an assignment must be a variable "=" +Error type 7 at Line 41: Type mismatched for operands "" +Error type 8 at Line 42: Type mismatched for return "return" +Error type 9 at Line 46: Function is not applicable for arguments "func_1" +Error type 10 at Line 47: Variable is not an array "[" +Error type 11 at Line 53: Not a function "t" +Error type 12 at Line 54: Not an integer "[" +Error type 13 at Line 56: Illegal use of "." +Error type 14 at Line 57: Non-existent field "a" +Error type 15 at Line 63: Struct redefined field or assign "=" +Error type 17 at Line 64: None Defined Struct "non_exist" +Error type 16 at Line 61: Duplicated name struct "type_2" diff --git a/Test/test/mytest2.output b/Test/test/mytest2.output new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Test/test/mytest3.output b/Test/test/mytest3.output new file mode 100644 index 0000000000000000000000000000000000000000..73261d8b9dded5af67877a6cf6a01d3eced530ad --- /dev/null +++ b/Test/test/mytest3.output @@ -0,0 +1 @@ +Error type 17 at Line 17: None Defined Struct "t2"