From 06ebf6a87ca1db975bdbf4f7f3126ea7c26ddde6 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Sat, 17 Aug 2019 11:34:48 -0400 Subject: Add basic type checking Squashed commit of WIP-type_check@5dadc4f5667ae69a709dd45c020780f2f424d67e --- main.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 6ded432..da597eb 100644 --- a/main.c +++ b/main.c @@ -129,15 +129,65 @@ int yyerror(msg) char* msg; { fprintf(stderr, "\nError, line %d: %s\n", line_num, msg); -#ifdef DEBUG - fprintf(stderr, "%s\n", yytext); exit(1); -#endif return 0; } int main() { +#ifdef DEBUG_TYPES + printf( + "\nPROG\t\t%d\n" + "VAR\t\t%d\n" + "PROC\t\t%d\n" + "FUNC\t\t%d\n" + "BEG\t\t%d\n" + "END\t\t%d\n" + "ID\t\t%d\n" + "ADDOP\t\t%d\n" + "MULOP\t\t%d\n" + "RELOP\t\t%d\n" + "ASSIGNOP\t\t%d\n" + "ADD\t\t%d\n" + "SUB\t\t%d\n" + "MUL\t\t%d\n" + "DIV\t\t%d\n" + "NOT\t\t%d\n" + "AND\t\t%d\n" + "OR\t\t%d\n" + "EQ\t\t%d\n" + "NE\t\t%d\n" + "LT\t\t%d\n" + "LE\t\t%d\n" + "GT\t\t%d\n" + "GE\t\t%d\n" + "INUM\t\t%d\n" + "RNUM\t\t%d\n" + "INT\t\t%d\n" + "REAL\t\t%d\n" + "BOOL\t\t%d\n" + "ARRAY\t\t%d\n" + "OF\t\t%d\n" + "DOTS\t\t%d\n" + "IF\t\t%d\n" + "ELSE\t\t%d\n" + "THEN\t\t%d\n" + "WHILE\t\t%d\n" + "DO\t\t%d\n" + "FOR\t\t%d\n" + "TO\t\t%d\n" + "DT\t\t%d\n" + "FCALL\t\t%d\n" + "PCALL\t\t%d\n" + "ARRAY_ACCESS\t\t%d\n" + "LIST\t\t%d\n", + + PROG, VAR, PROC, FUNC, BEG, END, ID, ADDOP, MULOP, RELOP, ASSIGNOP, ADD, + SUB, MUL, DIV, NOT, AND, OR, EQ, NE, LT, LE, GT, GE, INUM, RNUM, INT, REAL, + BOOL, ARRAY, OF, DOTS, IF, ELSE, THEN, WHILE, DO, FOR, TO, DT, FCALL, PCALL, + ARRAY_ACCESS, LIST); +#endif + cur_scope = mkscope(); assert(cur_scope); -- cgit v1.1 From 3f1cee416602070225b81deb8c2222a5324f8204 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Sun, 18 Aug 2019 18:31:36 -0400 Subject: Fix clean up header includes --- main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index da597eb..34acd52 100644 --- a/main.c +++ b/main.c @@ -1,3 +1,5 @@ +#include "pc.h" + #include #include #include @@ -5,7 +7,6 @@ #include "node.h" #include "scope.h" #include "y.tab.h" -#include "pc.h" extern char *yytext; extern int line_num; -- cgit v1.1