diff --git a/runner.c b/runner.c index 8e9474c..d2e0890 100644 --- a/runner.c +++ b/runner.c @@ -21,17 +21,12 @@ int main(int argc, char *argv[]) { arg = TOK_ARG; //it is a -tok arg with a valid alpha file at argv[2] yyin = fopen(argv[2], "r"); } - token = yylex(); - fprintf(stderr, "made it here"); - while (token != 0) { + while (0 != (token = yylex())) { if (arg == TOK_ARG) { fprintf(output, "%d %d %3d \"%s\"\n", line_number, column_number, token, yytext); } - token = yylex(); - fprintf(stderr, "made it past yylex"); } - fprintf(stderr, "returned 0\n"); return 0; } @@ -43,6 +38,19 @@ char *is_tok(int argc, char *argv[]) { if (is_alpha_file(input_prog, file_len) != 0) { return INVALID_ARG; } + + int ignore_path = 0; + int count_since_slash = 0; + for (int i = 0; i < file_len; i++) { + count_since_slash++; + if (input_prog[i] == '/') { + ignore_path += count_since_slash; + count_since_slash = 0; + } + } + + file_len -= ignore_path; + input_prog += ignore_path; char* FILE_tok = calloc(sizeof(char), file_len - ALPHA_OFFSET + TOK_LEN); strncpy(FILE_tok, input_prog, file_len - ALPHA_OFFSET); //copy name of prog before .alpha strcpy(FILE_tok + sizeof(char) * (file_len - ALPHA_OFFSET), ".tok"); //add .tok to end of file name diff --git a/tests/testPath/testPath.alpha b/tests/testPath/testPath.alpha new file mode 100644 index 0000000..fa713c4 --- /dev/null +++ b/tests/testPath/testPath.alpha @@ -0,0 +1,23 @@ +This is a test +9combined 7okens +12345 +893247892 +combined'DueToUnknownChar _validtoken __validtoken1 _valid_token2 validToken3_ +true false +null while !wrong if when +else type function +return external as +string _NOte_that_was_not_reserved +([)]{}:;,->"\ ++-*/% +<= +:= +"This is not a valid +String" +"This is a valid String" +!| +.. +(* this is a comment *) +(*Not a comment +$^& +> \ No newline at end of file diff --git a/tests/test_operators.alpha~ b/tests/test_operators.alpha~ new file mode 100644 index 0000000..84d3edd --- /dev/null +++ b/tests/test_operators.alpha~ @@ -0,0 +1,17 @@ ++ +- +* +/ +\ +% +< +> += +:= +=: +: += +! +& +| +.