From a1c7aaadb1942ebf2c60433c9ba3b4431e152e27 Mon Sep 17 00:00:00 2001 From: Annie Date: Mon, 10 Feb 2025 13:22:01 -0500 Subject: [PATCH] Added code to print to file with -tok input and created header file --- runner.c | 24 ++++++++++++++---------- runner.h | 13 +++++++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/runner.c b/runner.c index af078f9..3d467b8 100644 --- a/runner.c +++ b/runner.c @@ -1,20 +1,24 @@ -#define ALPHA_OFFSET 5 -#define TOK_LEN 3 -#define INVALID_ARG "invalid" -#define DIFF_ARG "diff" -#include - -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[]) { diff --git a/runner.h b/runner.h index e69de29..080d5c1 100644 --- a/runner.h +++ b/runner.h @@ -0,0 +1,13 @@ +#define ALPHA_OFFSET 5 +#define TOK_LEN 3 +#define INVALID_ARG "invalid" +#define DIFF_ARG "diff" +#include +#include +#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