diff Makefile @ 314:a3e277c58df9 ccdev

Checkpoint parser development for lwcc Beginning of lemon based parser for C including all the infrastructure for calling the lemon generated parser. This requires a translation layer from the preprocessor token numbers to the lemon parser token numbers due to the fact that lemon wants to control the token numbers. Eventually when the lemon parser gets replaced with a hand crafted recursive descent parser, this translation will no longer be required. However, in the interest of getting things working sooner rather than later, using something like lemon is beneficial.
author William Astle <lost@l-w.ca>
date Sun, 17 Nov 2013 11:59:36 -0700
parents 41118fb0a8f2
children 5b8871fd7503
line wrap: on
line diff
--- a/Makefile	Tue Nov 12 20:41:14 2013 -0700
+++ b/Makefile	Sun Nov 17 11:59:36 2013 -0700
@@ -108,7 +108,8 @@
 lwcc_cpp_objs := $(lwcc_cpp_srcs:.c=.o)
 lwcc_cpp_deps := $(lwcc_cpp_srcs:.c=.d)
 
-lwcc_cc_srcs := cc-main.c tree.c parse.c
+# parse_c.c needs to be first here
+lwcc_cc_srcs := parse_c.c cc-main.c tree.c parse.c token_names.c
 lwcc_cc_srcs := $(addprefix lwcc/,$(lwcc_cc_srcs))
 lwcc_cc_objs := $(lwcc_cc_srcs:.c=.o)
 lwcc_cc_deps := $(lwcc_cc_srcs:.c=.d)
@@ -179,9 +180,20 @@
 
 extra_clean := $(extra_clean) *~ */*~
 
+lwcc/parse_c.c lwcc/parse_c.h: lwcc/parse_c.y
+	rm -f lwcc/parse_c.h lwcc/parse_c.c
+	lemon -q lwcc/parse_c.y
+
+lwcc/token_names.c: lwcc/parse_c.h
+	echo "char *ptoken_names[] = {" > $@
+	echo '"TOKEN_NONE",' >> $@
+	cat lwcc/parse_c.h | sed -e 's/#define \(.*\) .*$$/"\1",/g' -e 's/ //g' >> $@
+	echo '"" };' >> $@
+
+
 %.o: %.c
 	@echo "Building dependencies for $@"
-	@$(CC) -MM $(CPPFLAGS) -o $*.d $<
+	@$(CC) -MM -MG $(CPPFLAGS) -o $*.d $<
 	@mv -f $*.d $*.d.tmp
 	@sed -e 's|.*:|$*.o $*.d:|' < $*.d.tmp > $*.d
 	@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d