Added code to print to file with -tok input and created header file

This commit is contained in:
Annie
2025-02-10 13:22:01 -05:00
parent f0f96dec8d
commit a1c7aaadb1
2 changed files with 27 additions and 10 deletions

View File

@ -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[]) {

View File

@ -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