From b3e6aa9658718b8a217ab4ac4618aa8c8229313d Mon Sep 17 00:00:00 2001 From: Lee Date: Fri, 13 Oct 2023 20:33:08 +0800 Subject: [PATCH] Change c files to cpp files --- Makefile | 16 ++++++++-------- lexer.l | 2 +- main.cpp | 2 +- parser.y | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 9a866aef..6971ae09 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,9 @@ YACC = bison # -d: generate header with default name YFLAGS = --verbose --debug -d -# Note that lex.yy.c is excluded deliberately, as "lex.yy.c" is considered a -# header file (it's included by "y.tab.c"). -OBJS := $(shell find . -name "*.cpp") y.tab.o +# Note that lex.yy.cpp is excluded deliberately, as "lex.yy.cpp" is considered a +# header file (it's included by "y.tab.cpp"). +OBJS := $(shell find . -name "*.cpp" ! -name "y.tab.cpp" ! -name "lex.yy.cpp" ) y.tab.o OBJS := $(OBJS:.cpp=.o) DEPS = $(OBJS:.o=.d) @@ -25,11 +25,11 @@ test: $(TARGET) $(TARGET): $(OBJS) $(CXX) $(CXXFLAGS) $(OBJS) -o $@ -lex.yy.c: lexer.l +lex.yy.cpp: lexer.l $(LEX) -o $@ $< -y.tab.h: y.tab.c -y.tab.c: parser.y lex.yy.c +y.tab.hpp: y.tab.cpp +y.tab.cpp: parser.y lex.yy.cpp $(YACC) $(YFLAGS) $< -o $@ # @@ -38,10 +38,10 @@ y.tab.c: parser.y lex.yy.c # dependency explicit to enforce the ordering. # -main.o: %.o: %.cpp y.tab.h +main.o: %.o: %.cpp y.tab.hpp clean: - rm -rf *.s *.o lex.yy.c y.tab.c y.tab.h *.output *.ssa $(TARGET) $(OBJS) $(DEPS) + rm -rf *.s *.o lex.yy.* y.tab.* *.output *.ssa $(TARGET) $(OBJS) $(DEPS) make -C test/ clean -include $(DEPS) diff --git a/lexer.l b/lexer.l index fa59d3b4..2a22f628 100644 --- a/lexer.l +++ b/lexer.l @@ -15,7 +15,7 @@ #include #include -#include "y.tab.h" +#include "y.tab.hpp" // Use LINENO for the actual line number in the source code // yylineno has advanced to the next line when we reference it. diff --git a/main.cpp b/main.cpp index 6ed18adb..171e7404 100644 --- a/main.cpp +++ b/main.cpp @@ -10,7 +10,7 @@ #include "scope.hpp" #include "type_checker.hpp" #include "util.hpp" -#include "y.tab.h" +#include "y.tab.hpp" /// @brief Where the generated code goes. std::ofstream output; diff --git a/parser.y b/parser.y index 59045ecc..533189f5 100644 --- a/parser.y +++ b/parser.y @@ -6,7 +6,7 @@ #include #include "ast.hpp" -#include "lex.yy.c" +#include "lex.yy.cpp" #include "type.hpp" extern std::unique_ptr program;