Mercurial > hg > index.cgi
comparison Makefile @ 498:1bd2d590d734
Rejig parser to eliminate lemon
No longer use lemon for building the parser. It adds too much complexity,
really, and a hand written recursive descent parser is far more flexible.
The current iteration can handle exactly one statement: "return <int>".
author | William Astle <lost@l-w.ca> |
---|---|
date | Thu, 08 Aug 2019 23:32:23 -0600 |
parents | 5b8871fd7503 |
children | c3099c5d9d3e |
comparison
equal
deleted
inserted
replaced
497:4b865c9d4371 | 498:1bd2d590d734 |
---|---|
106 lwcc_cpp_srcs := cpp-main.c | 106 lwcc_cpp_srcs := cpp-main.c |
107 lwcc_cpp_srcs := $(addprefix lwcc/,$(lwcc_cpp_srcs)) | 107 lwcc_cpp_srcs := $(addprefix lwcc/,$(lwcc_cpp_srcs)) |
108 lwcc_cpp_objs := $(lwcc_cpp_srcs:.c=.o) | 108 lwcc_cpp_objs := $(lwcc_cpp_srcs:.c=.o) |
109 lwcc_cpp_deps := $(lwcc_cpp_srcs:.c=.d) | 109 lwcc_cpp_deps := $(lwcc_cpp_srcs:.c=.d) |
110 | 110 |
111 # parse_c.c needs to be first here | 111 lwcc_cc_srcs := cc-main.c tree.c cc-parse.c |
112 lwcc_cc_srcs := parse_c.c cc-main.c tree.c parse.c token_names.c | |
113 lwcc_cc_srcs := $(addprefix lwcc/,$(lwcc_cc_srcs)) | 112 lwcc_cc_srcs := $(addprefix lwcc/,$(lwcc_cc_srcs)) |
114 lwcc_cc_objs := $(lwcc_cc_srcs:.c=.o) | 113 lwcc_cc_objs := $(lwcc_cc_srcs:.c=.o) |
115 lwcc_cc_deps := $(lwcc_cc_srcs:.c=.d) | 114 lwcc_cc_deps := $(lwcc_cc_srcs:.c=.d) |
116 | 115 |
117 lwcc_cpplib_srcs := cpp.c lex.c token.c preproc.c symbol.c | 116 lwcc_cpplib_srcs := cpp.c lex.c token.c preproc.c symbol.c |
177 alldeps := $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) ($lwobjdump_deps) $(lwcc_deps) | 176 alldeps := $(lwasm_deps) $(lwlink_deps) $(lwar_deps) $(lwlib_deps) ($lwobjdump_deps) $(lwcc_deps) |
178 | 177 |
179 -include $(alldeps) | 178 -include $(alldeps) |
180 | 179 |
181 extra_clean := $(extra_clean) *~ */*~ | 180 extra_clean := $(extra_clean) *~ */*~ |
182 | |
183 lwcc/parse_c.c lwcc/parse_c.h: lwcc/parse_c.y | |
184 rm -f lwcc/parse_c.h lwcc/parse_c.c | |
185 lemon -q lwcc/parse_c.y | |
186 | |
187 lwcc/token_names.c: lwcc/parse_c.h | |
188 echo "char *ptoken_names[] = {" > $@ | |
189 echo '"TOKEN_NONE",' >> $@ | |
190 cat lwcc/parse_c.h | sed -e 's/#define \(.*\) .*$$/"\1",/g' -e 's/ //g' >> $@ | |
191 echo '"" };' >> $@ | |
192 | |
193 | 181 |
194 %.o: %.c | 182 %.o: %.c |
195 @echo "Building dependencies for $@" | 183 @echo "Building dependencies for $@" |
196 @$(CC) -MM -MG $(CPPFLAGS) -o $*.d $< | 184 @$(CC) -MM -MG $(CPPFLAGS) -o $*.d $< |
197 @mv -f $*.d $*.d.tmp | 185 @mv -f $*.d $*.d.tmp |