Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding begin and end program tacs

  • Loading branch information...
commit 0834739c51428d93347e2f60c3a8ac8a8843ceb7 1 parent 96f6380
@ab3nd authored
View
7 pascal_subset/pascal.y
@@ -73,14 +73,17 @@ program:
declarations
subprogram_declarations
compound_statement
- '.' { TAC* program = catTAC($1, $3); //preamble and identifier list
+ '.' { TAC* program = makeTAC(START_PROG_TAC, NULL, NULL, $1->result);
+ program = catTAC(program, $1); //preamble
+ program = catTAC(program, $3); //identifier list
program = catTAC(program, $6); //global variable declarations
if($7 != NULL)
{
program = catTAC(program, $7); //subprogram declarations
}
program = catTAC(program, $8); //main code
- program = catTAC(program, endFunc());
+ program = catTAC(program, endFunc());
+ program = catTAC(program, makeTAC(END_PROG_TAC, NULL, NULL, NULL));
dumpTable(program);
$$ = program;
}
View
6 pascal_subset/prettyprint.c
@@ -334,6 +334,12 @@ void printTACs(TAC* start)
case LOAD_VAR_TAC:
printf("LOAD_VAR_TAC name: %s\n", start->result->name);
break;
+ case START_PROG_TAC:
+ printf("START_PROG_TAC name: %s\n", start->result->name);
+ break;
+ case END_PROG_TAC:
+ printf("END_PROG_TAC\n");
+ break;
case LOAD_CONST_TAC:
printf("LOAD_CONST_TAC value: ");
if(start->result->type_info.type == INTEGER_T)
View
12 pascal_subset/symbol.h
@@ -13,11 +13,13 @@
*/
typedef enum {CONST_T, VAR_T, FUNC_T, PROC_T, REF_T, IDENT_T, LABEL_T} SYM_TYPE;
typedef enum {INTEGER_T, REAL_T, STRING_T, SCOPE_T, NAME_T} VAR_TYPE;
-typedef enum {BOGUS_TAC, ASSIGN_TAC, LE_TAC, GE_TAC, NE_TAC, EQUALS_TAC, LT_TAC, GT_TAC,
- MUL_TAC, DIV_TAC, MOD_TAC, AND_TAC, ADD_TAC, SUB_TAC, NOT_TAC,
- OR_TAC, POSI_TAC, NEG_TAC, FUNC_TAC, VAR_TAC, ARG_TAC,
- CALL_TAC, LABEL_TAC, BEGIN_FUNC_TAC, END_FUNC_TAC, JZERO_TAC,
- JUMP_TAC, LOAD_VAR_TAC, LOAD_CONST_TAC} TAC_TYPE;
+typedef enum {BOGUS_TAC, ASSIGN_TAC, LE_TAC, GE_TAC, NE_TAC,
+ EQUALS_TAC, LT_TAC, GT_TAC,MUL_TAC, DIV_TAC,
+ MOD_TAC, AND_TAC, ADD_TAC, SUB_TAC, NOT_TAC,
+ OR_TAC, POSI_TAC, NEG_TAC, FUNC_TAC, VAR_TAC,
+ ARG_TAC, CALL_TAC, LABEL_TAC, BEGIN_FUNC_TAC, END_FUNC_TAC,
+ JZERO_TAC, JUMP_TAC, LOAD_VAR_TAC, LOAD_CONST_TAC, START_PROG_TAC,
+ END_PROG_TAC} TAC_TYPE;
typedef struct symbol SYM_ENTRY;
typedef struct tac TAC;
typedef struct enode ENODE;
Please sign in to comment.
Something went wrong with that request. Please try again.