From 6bdc28b8feb6bd6001c1b52475e9b8128b9faf2f Mon Sep 17 00:00:00 2001 From: Riley Smith Date: Thu, 14 Nov 2024 17:47:59 -0800 Subject: [PATCH] make it compile on code.cs --- lab-5/main.c | 2 +- lab-5/parser.bison | 2 +- lab-5/token.h | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lab-5/main.c b/lab-5/main.c index 404b46d..2169a20 100644 --- a/lab-5/main.c +++ b/lab-5/main.c @@ -16,7 +16,7 @@ extern int yylex(); /* Clunky: Declare the result of the parser from parser.bison */ -struct stmt *parser_result; +extern struct stmt *parser_result; int main(int argc, char *argv[]) { printf("Lab 6 Example Interpreter Compiler\n"); diff --git a/lab-5/parser.bison b/lab-5/parser.bison index c80a2a7..46ab055 100644 --- a/lab-5/parser.bison +++ b/lab-5/parser.bison @@ -24,7 +24,7 @@ void yyerror(const char*); extern int yylineno; -struct stmt *parser_result = 0; +extern struct stmt *parser_result = 0; %} diff --git a/lab-5/token.h b/lab-5/token.h index ebb85f5..2d3b180 100644 --- a/lab-5/token.h +++ b/lab-5/token.h @@ -111,7 +111,19 @@ extern int yydebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef int YYSTYPE; +union YYSTYPE +{ +#line 91 "parser.bison" + + struct expr *expr; + struct stmt *stmt; + struct decl *decl; + struct type *type; + +#line 124 "token.h" + +}; +typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif