diff --git a/.gitignore b/.gitignore index b927c65..b9f8003 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ alpha flex.h grammar.tab.c -grammar.tab.h \ No newline at end of file +grammar.tab.h +.vscode +out +src \ No newline at end of file diff --git a/Makefile b/Makefile index 05aff7a..7ec4e72 100644 --- a/Makefile +++ b/Makefile @@ -25,27 +25,20 @@ debug: CFLAGS += -DDEBUG=1 debug: clean compiler test: - ./$(EXE) ./tests/test_comments.alpha - ./$(EXE) ./tests/test_generalTokenTest.alpha - ./$(EXE) ./tests/test_keywords.alpha - ./$(EXE) ./tests/test_operators.alpha - ./$(EXE) ./tests/test_otherpunc.alpha - ./$(EXE) ./tests/test_simpleIntTest.alpha - ./$(EXE) ./tests/test_simpleLiterals.alpha - ./$(EXE) ./tests/test_real_alpha_file.alpha - ./$(EXE) ./tests/test_real_alpha_2.alpha - ./$(EXE) -tok ./tests/test_comments.alpha - ./$(EXE) -tok ./tests/test_generalTokenTest.alpha - ./$(EXE) -tok ./tests/test_keywords.alpha - ./$(EXE) -tok ./tests/test_operators.alpha - ./$(EXE) -tok ./tests/test_otherpunc.alpha - ./$(EXE) -tok ./tests/test_simpleIntTest.alpha - ./$(EXE) -tok ./tests/test_simpleLiterals.alpha - ./$(EXE) -tok ./tests/test_real_alpha_file.alpha - ./$(EXE) -tok ./tests/test_real_alpha_2.alpha - ./$(EXE) -tok -st ./tests/test_real_alpha_2.alpha - ./$(EXE) -st -tok ./tests/test_operators.alpha - ./$(EXE) -st ./tests/test_keywords.alpha + ./$(EXE) -tok ./tests/sprint1/test_comment_fix1.alpha + ./$(EXE) -tok ./tests/sprint1/test_comment_fix2.alpha + ./$(EXE) -tok ./tests/sprint1/test_comment_issues.alpha + ./$(EXE) -tok ./tests/sprint1/test_comments.alpha + ./$(EXE) -tok ./tests/sprint1/test_general_token.alpha + ./$(EXE) -tok ./tests/sprint1/test_keywords.alpha + ./$(EXE) -tok ./tests/sprint1/test_operators.alpha + ./$(EXE) -tok ./tests/sprint1/test_other_punc.alpha + ./$(EXE) -tok ./tests/sprint1/test_punc_grouping.alpha + ./$(EXE) -tok ./tests/sprint1/test_real_alpha_file1.alpha + ./$(EXE) -tok ./tests/sprint1/test_real_alpha_file2.alpha + ./$(EXE) -tok ./tests/sprint1/test_simple_int.alpha + ./$(EXE) -tok ./tests/sprint1/test_simple_literals.alpha + ./$(EXE) -tok ./tests/sprint1/test_variables.alpha clean: rm -f *.o @@ -56,3 +49,4 @@ clean: rm -f grammar.tab.c rm -f grammar.tab.h rm -f *.st + rm -rf out \ No newline at end of file diff --git a/grammar.y b/grammar.y index 591d80a..c174533 100644 --- a/grammar.y +++ b/grammar.y @@ -52,6 +52,13 @@ %token RESERVE 613 %token RELEASE 614 %token COMMENT 700 -%% +%% + DBLOCK: %empty; + + FUNCTION_DECLARATION: FUNCTION ID COLON ID + | EXTERNAL FUNCTION ID COLON ID + ; + RECORD_DECLARATION: TYPE ID COLON DBLOCK; + ARRAY_DECLARATION: ID ASSIGN RESERVE ID L_PAREN C_INTEGER R_PAREN; %% diff --git a/runner.c b/runner.c index 56fa776..49821f5 100644 --- a/runner.c +++ b/runner.c @@ -115,10 +115,19 @@ int new_file(char *arg, char *alpha) { int type_len; const char *basename = alpha; const char *slash = strchr(alpha, '/'); + while (slash != NULL) { basename = slash + 1; slash = strchr(basename, '/'); } + + mkdir("./out", 0777); + + char *new_basename = calloc(strlen(basename) + 5, sizeof(char)); + strcpy(new_basename, "./out/"); + strcat(new_basename, basename); + basename = new_basename; + if (strcmp(arg, "-tok") == 0) { type_len = TOK_LEN; } else if (strcmp(arg, "-st") == 0) { diff --git a/runner.h b/runner.h index cd5167f..8c83748 100644 --- a/runner.h +++ b/runner.h @@ -12,6 +12,7 @@ #include "typedefs.h" #include #include "symbol_table.h" +#include extern int line_number, column_number; extern char *yytext; diff --git a/tests/sprint1/test_comment_fix1.alpha b/tests/sprint1/test_comment_fix1.alpha new file mode 100644 index 0000000..910a538 --- /dev/null +++ b/tests/sprint1/test_comment_fix1.alpha @@ -0,0 +1 @@ +(***) \ No newline at end of file diff --git a/tests/sprint1/test_comment_fix2.alpha b/tests/sprint1/test_comment_fix2.alpha new file mode 100644 index 0000000..bd710e9 --- /dev/null +++ b/tests/sprint1/test_comment_fix2.alpha @@ -0,0 +1 @@ +(*(**)*) \ No newline at end of file diff --git a/tests/test_comment_issues.alpha b/tests/sprint1/test_comment_issues.alpha similarity index 100% rename from tests/test_comment_issues.alpha rename to tests/sprint1/test_comment_issues.alpha diff --git a/tests/test_comments.alpha b/tests/sprint1/test_comments.alpha similarity index 100% rename from tests/test_comments.alpha rename to tests/sprint1/test_comments.alpha diff --git a/tests/test_generalTokenTest.alpha b/tests/sprint1/test_general_token.alpha similarity index 100% rename from tests/test_generalTokenTest.alpha rename to tests/sprint1/test_general_token.alpha diff --git a/tests/test_keywords.alpha b/tests/sprint1/test_keywords.alpha similarity index 100% rename from tests/test_keywords.alpha rename to tests/sprint1/test_keywords.alpha diff --git a/tests/test_operators.alpha b/tests/sprint1/test_operators.alpha similarity index 100% rename from tests/test_operators.alpha rename to tests/sprint1/test_operators.alpha diff --git a/tests/test_otherpunc.alpha b/tests/sprint1/test_other_punc.alpha similarity index 100% rename from tests/test_otherpunc.alpha rename to tests/sprint1/test_other_punc.alpha diff --git a/tests/test_punctuation_grouping.alpha b/tests/sprint1/test_punc_grouping.alpha similarity index 100% rename from tests/test_punctuation_grouping.alpha rename to tests/sprint1/test_punc_grouping.alpha diff --git a/tests/test_real_alpha_file.alpha b/tests/sprint1/test_real_alpha_file1.alpha similarity index 100% rename from tests/test_real_alpha_file.alpha rename to tests/sprint1/test_real_alpha_file1.alpha diff --git a/tests/test_real_alpha_2.alpha b/tests/sprint1/test_real_alpha_file2.alpha similarity index 100% rename from tests/test_real_alpha_2.alpha rename to tests/sprint1/test_real_alpha_file2.alpha diff --git a/tests/test_simpleIntTest.alpha b/tests/sprint1/test_simple_int.alpha similarity index 100% rename from tests/test_simpleIntTest.alpha rename to tests/sprint1/test_simple_int.alpha diff --git a/tests/test_simpleLiterals.alpha b/tests/sprint1/test_simple_literals.alpha similarity index 100% rename from tests/test_simpleLiterals.alpha rename to tests/sprint1/test_simple_literals.alpha diff --git a/tests/test_variables.alpha b/tests/sprint1/test_variables.alpha similarity index 100% rename from tests/test_variables.alpha rename to tests/sprint1/test_variables.alpha diff --git a/tests/testPath/testPath.alpha b/tests/testPath/testPath.alpha deleted file mode 100644 index fa713c4..0000000 --- a/tests/testPath/testPath.alpha +++ /dev/null @@ -1,23 +0,0 @@ -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_comment_issues.tok b/tests/test_comment_issues.tok deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_operators.alpha~ b/tests/test_operators.alpha~ deleted file mode 100644 index 84d3edd..0000000 --- a/tests/test_operators.alpha~ +++ /dev/null @@ -1,17 +0,0 @@ -+ -- -* -/ -\ -% -< -> -= -:= -=: -: -= -! -& -| -. diff --git a/tests/test_wrong_type.txt b/tests/test_wrong_type.txt deleted file mode 100644 index e69de29..0000000