diff --git a/a.out b/a.out deleted file mode 100644 index 8540d49..0000000 Binary files a/a.out and /dev/null differ diff --git a/src/codegen.h~ b/src/codegen.h~ deleted file mode 100644 index 2d4c660..0000000 --- a/src/codegen.h~ +++ /dev/null @@ -1,2 +0,0 @@ -/* Code Generation File - Contains functions to generate assembly code */ - diff --git a/src/grammar.y b/src/grammar.y index 9d5d5a3..a29ae39 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -87,6 +87,7 @@ %token RESERVE 613 %token RELEASE 614 %token COMMENT 700 +%token INCLUDE 901 //precedence order %left ASSIGN @@ -106,6 +107,7 @@ program: prototype_or_definition_list + | include_list prototype_or_definition_list ; @@ -123,7 +125,19 @@ prototype_or_definition_list: prototype: L_PAREN EXTERNAL R_PAREN FUNCTION ID COLON ID + ; + + +include_list: + include_statement SEMI_COLON include_list + | include_statement + ; + + + +include_statement: + INCLUDE C_STRING SEMI_COLON ; diff --git a/src/lexicalStructure.lex b/src/lexicalStructure.lex index 7034997..a8bd8af 100644 --- a/src/lexicalStructure.lex +++ b/src/lexicalStructure.lex @@ -19,6 +19,8 @@ SCHAR \\n|\\t|\\\"|[^\"\n\\] %% +"#include" { if(tok_flag != NULL) {print_tok(INCLUDE);} incr(line_number,column_number,INCLUDE); return INCLUDE; } + "integer" { if(tok_flag != NULL) {print_tok(T_INTEGER);} incr(line_number,column_number,T_INTEGER); yylval.tn = integ; return T_INTEGER; } "address" { if(tok_flag != NULL) {print_tok(T_ADDRESS);} incr(line_number,column_number,T_ADDRESS); yylval.tn = addr; return T_ADDRESS; } "Boolean" { if(tok_flag != NULL) {print_tok(T_INTEGER);} incr(line_number,column_number,T_INTEGER); yylval.tn = boo; return T_BOOLEAN; } diff --git a/src/typedefs.h b/src/typedefs.h index 3b75b3a..15fe996 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -56,4 +56,5 @@ // comments #define COMMENT 700 //Additional tokens -#define ACCESS 801 \ No newline at end of file +#define ACCESS 801 +#define INCLUDE 901 \ No newline at end of file diff --git a/tests/sprint1/test/sp1_include.alpha b/tests/sprint1/test/sp1_include.alpha new file mode 100644 index 0000000..190d02c --- /dev/null +++ b/tests/sprint1/test/sp1_include.alpha @@ -0,0 +1,4 @@ +(* TEST: [-tok -asc -tc] *) +#include "alpha.h"; +#include "alpha.h"; +#include "alpha.h"; \ No newline at end of file