Added code to print to file with -tok input and created header file
This commit is contained in:
24
runner.c
24
runner.c
@ -1,20 +1,24 @@
|
||||
#define ALPHA_OFFSET 5
|
||||
#define TOK_LEN 3
|
||||
#define INVALID_ARG "invalid"
|
||||
#define DIFF_ARG "diff"
|
||||
#include <string.h>
|
||||
|
||||
int main(int argc, char* argv);
|
||||
char *is_tok(int argc, char* argv);
|
||||
#include "runner.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char *check_input;
|
||||
|
||||
int token;
|
||||
//check_input can be compared to INVALID_ARG and DIFF_ARG to determine if -tok and holds the generated file name if it is
|
||||
check_input = is_tok(argc, argv);
|
||||
FILE * output = fopen(check_input, "w");
|
||||
|
||||
return 0; //not sure what to do yet
|
||||
if (check_input == INVALID_ARG) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (0 != (token = yylex())) {
|
||||
if (check_input != DIFF_ARG) {
|
||||
fprintf(output, "%d %d %3d \"%s\"\n", line_number, column_number, token, yytext);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *is_tok(int argc, char *argv[]) {
|
||||
|
13
runner.h
13
runner.h
@ -0,0 +1,13 @@
|
||||
#define ALPHA_OFFSET 5
|
||||
#define TOK_LEN 3
|
||||
#define INVALID_ARG "invalid"
|
||||
#define DIFF_ARG "diff"
|
||||
#include <string.h>
|
||||
#include <std.io>
|
||||
#include "lex.yy.c"
|
||||
|
||||
extern int line_number, column_number;
|
||||
extern char *yytext;
|
||||
|
||||
int main(int argc, char* argv);
|
||||
char *is_tok(int argc, char* argv);#define ALPHA_OFFSET 5
|
||||
|
Reference in New Issue
Block a user