mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
examples: add an example with a reentrant parser in Flex+Bison
Suggested by Eric S. Raymond. https://lists.gnu.org/archive/html/bison-patches/2019-02/msg00066.html * examples/c/reentrant-calc/Makefile, examples/c/reentrant-calc/README.md, * examples/c/reentrant-calc/parse.y, examples/c/reentrant-calc/scan.l * examples/c/reentrant-calc/lexcalc.test, * examples/c/reentrant-calc/local.mk: New.
This commit is contained in:
35
examples/c/reentrant-calc/Makefile
Normal file
35
examples/c/reentrant-calc/Makefile
Normal file
@@ -0,0 +1,35 @@
|
||||
# This Makefile is designed to be simple and readable. It does not
|
||||
# aim at portability. It requires GNU Make.
|
||||
|
||||
BASE = lexcalc
|
||||
BISON = bison
|
||||
FLEX = flex
|
||||
XSLTPROC = xsltproc
|
||||
|
||||
all: $(BASE)
|
||||
|
||||
%.c %.h %.xml %.gv: %.y
|
||||
$(BISON) $(BISONFLAGS) --defines --xml --graph=$*.gv -o $*.c $<
|
||||
|
||||
%.c %.h: %.l
|
||||
$(FLEX) $(FLEXFLAGS) -o$*.c --header-file=$*.h $<
|
||||
|
||||
scan.o: parse.h
|
||||
parse.o: scan.h
|
||||
$(BASE): parse.o scan.o
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
run: $(BASE)
|
||||
@echo "Type arithmetic expressions. Quit with ctrl-d."
|
||||
./$<
|
||||
|
||||
html: parse.html
|
||||
%.html: %.xml
|
||||
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||
|
||||
CLEANFILES = \
|
||||
$(BASE) *.o \
|
||||
parse.[ch] parse.output parse.xml parse.html parse.gv \
|
||||
scan.c
|
||||
clean:
|
||||
rm -f $(CLEANFILES)
|
||||
Reference in New Issue
Block a user