Skip to content

Commit

Permalink
Updated to accept print as a command argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
njmaysonet committed Jul 12, 2015
1 parent de6e46d commit 2507699
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions parserwithcodegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ symbol symbol_table[MAX_SYMBOL_TABLE_SIZE];
FILE * ifp;
//output file pointer
FILE* ofp;
//flag to print to screen
int consoleFlag = 0;
//Most recent token
int TOKEN;
//most recent identifier or number
Expand Down Expand Up @@ -139,6 +141,11 @@ void printToFile(int op, int L, int M)

//print to the file here
fprintf(ofp,"%d %d %d \n", op, L, M);

if(consoleFlag == 1)
{
printf("%d %d %d \n", op, L, M);
}
}


Expand Down Expand Up @@ -600,6 +607,14 @@ int main()
{
ifp = fopen("lexemelist.txt", "r");
ofp = fopen("parseroutput.txt","w");
//For command directive "-a"
if(argc == 2)
{
if(!strcmp(argv[1],"print"))
{
consoleFlag = 1;
}
}
PROGRAM();
printf("parsing finished\n");
int i;
Expand Down

0 comments on commit 2507699

Please sign in to comment.