Skip to content

Commit 77ff696

Browse files
committed
Merge branch 'master' of github.com:yugeshk/CS335
2 parents 3621c49 + fa53382 commit 77ff696

26 files changed

+183
-740
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,6 @@ make
114114
./bin/symtab <path_to_c_file> -o <file_name>.dot
115115
```
116116

117-
## Final Project
117+
## Final Project
118+
119+
The final stage of this project is a functional compiler to translate C source to MIPS and run it. Tip-of-Tree of the `master` branch has code for the final outcome of the project. Usage information is provided above.

src/3ac.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ void arithmetic_optimise(Quad* q){
494494
else if(oper=="/"){
495495

496496
if(y==0){
497-
error_msg("Division by zero not possible",line_num);
498497
return;
499498
}
500499
else{

src/expression.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,17 @@ Expression *create_postfix_expr_voidfun( Identifier *fi ) {
249249
Expression *create_postfix_expr_fun( Identifier *fi, ArgumentExprList *ae ) {
250250
PostfixExpression *P = new PostfixExpression();
251251

252-
if ( fi->value == "printf" || fi->value == "scanf" ) {
253-
// XXX:
254-
/* Hack : To support printf for now */
255-
P->type = Type( INT_T, 0, true );
256-
P->add_children( fi, ae );
257-
P->res = new_temp();
258-
create_new_call( P->res, fi->value );
259-
// emit( P->res, "call", new_3id( fi->value ), new_3const( 0, INT3 ) );
260-
return P;
261-
}
252+
// if ( fi->value == "printf" || fi->value == "scanf" ) {
253+
// error_msg("Use functions in lib/lib.asm",line_num)
254+
// // XXX:
255+
// /* Hack : To support printf for now */
256+
// // P->type = Type( INT_T, 0, true );
257+
// // P->add_children( fi, ae );
258+
// // P->res = new_temp();
259+
// // create_new_call( P->res, fi->value );
260+
// // emit( P->res, "call", new_3id( fi->value ), new_3const( 0, INT3 ) );
261+
// return P;
262+
// }
262263

263264
SymTabEntry *ste = global_symbol_table.get_symbol_from_table( fi->value );
264265
if ( ste == nullptr ) {

tests/3ac_1.c

Lines changed: 0 additions & 44 deletions
This file was deleted.

tests/3ac_2.c

Lines changed: 0 additions & 55 deletions
This file was deleted.

tests/3ac_3.c

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/3ac_4.c

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/ack.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,5 @@ int main(){
2222
c=scan_int();
2323
A = ack(b,c);
2424
print_int(A);
25-
exit();
2625
return 0;
2726
}

tests/binary_search.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ void print_char(char c);
33
int scan_int();
44
void print_string(char *);
55
// return index at which the no. is present else -1
6-
int binary_search(int * arr,int low, int high,int to_find){
6+
int binary_search(int arr[100],int low, int high,int to_find){
77
int mid,i;
88
if(low>high){
99
return -1;

tests/test11.c renamed to tests/bool_2.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ int main(){
1313
int *p;
1414
int fd;
1515
char str[10];
16-
if ( false ) {
16+
if ( false || true) {
1717
print_int(1);
1818
}
19+
20+
if ( false && true) {
21+
print_int(2);
22+
}
1923
return 0;
2024
}

0 commit comments

Comments
 (0)