mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
examples: sort them per language and complete them
Convert some of the READMEs to Markdown, which is now more common, and nicely displayed in some git hosting services. Add missing READMEs and Makefiles. Generate XML, HTML and Dot files. Be sure to ship the test files. Complete CLEANFILES to remove all generated files. * examples/calc++: Move into... * examples/c++: here. * examples/mfcalc, examples/rpcalc: Move into... * examples/c: here. * examples/README.md, examples/c++/calc++/Makefile, examples/c/local.mk, * examples/c/mfcalc/Makefile, examples/c/rpcalc/Makefile, * examples/d/README.md, examples/java/README.md: New files. * examples/test (medir): Be robust to deeper directory nesting.
This commit is contained in:
7
examples/c/rpcalc/.gitignore
vendored
Normal file
7
examples/c/rpcalc/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/calc.h
|
||||
/rpcalc
|
||||
/rpcalc.c
|
||||
/rpcalc.h
|
||||
/rpcalc.output
|
||||
/rpcalc.stamp
|
||||
/rpcalc.y
|
||||
25
examples/c/rpcalc/Makefile
Normal file
25
examples/c/rpcalc/Makefile
Normal file
@@ -0,0 +1,25 @@
|
||||
# This Makefile is designed to be simple and readable. It does not
|
||||
# aim at portability. It requires GNU Make.
|
||||
|
||||
BASE = rpcalc
|
||||
BISON = bison
|
||||
XSLTPROC = xsltproc
|
||||
|
||||
all: $(BASE)
|
||||
|
||||
%.c %.xml %.gv: %.y
|
||||
$(BISON) $(BISONFLAGS) --xml --graph=$*.gv -o $*.c $<
|
||||
|
||||
%: %.c
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
run: $(BASE)
|
||||
@echo "Type arithmetic expressions in reverse polish notation. Quit with ctrl-d."
|
||||
./$<
|
||||
|
||||
html: $(BASE).html
|
||||
%.html: %.xml
|
||||
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $$($(BISON) --print-datadir)/xslt/xml2xhtml.xsl $<
|
||||
|
||||
clean:
|
||||
rm -f $(BASE) $(BASE).c $(BASE).html $(BASE).xml $(BASE).gv
|
||||
43
examples/c/rpcalc/local.mk
Normal file
43
examples/c/rpcalc/local.mk
Normal file
@@ -0,0 +1,43 @@
|
||||
## Copyright (C) 2005-2006, 2008-2015, 2018 Free Software Foundation,
|
||||
## Inc.
|
||||
##
|
||||
## This program is free software: you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation, either version 3 of the License, or
|
||||
## (at your option) any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
## -------------------- ##
|
||||
## Building & testing. ##
|
||||
## -------------------- ##
|
||||
|
||||
BUILT_SOURCES += $(rpcalc_sources)
|
||||
CLEANFILES += %D%/rpcalc.[ch] %D%/rpcalc.output
|
||||
CLEANDIRS += %D%/*.dSYM
|
||||
|
||||
rpcalc_extracted = %D%/rpcalc.y
|
||||
rpcalc_sources = $(rpcalc_extracted)
|
||||
extracted += $(rpcalc_extracted)
|
||||
|
||||
check_PROGRAMS += %D%/rpcalc
|
||||
nodist_%C%_rpcalc_SOURCES = $(rpcalc_sources)
|
||||
# Don't use gnulib's system headers.
|
||||
%C%_rpcalc_CPPFLAGS = -I$(top_builddir)/%D%
|
||||
%C%_rpcalc_LDADD = -lm
|
||||
|
||||
dist_TESTS += %D%/rpcalc.test
|
||||
|
||||
## ------------ ##
|
||||
## Installing. ##
|
||||
## ------------ ##
|
||||
|
||||
rpcalcdir = $(docdir)/%D%
|
||||
rpcalc_DATA = $(rpcalc_extracted)
|
||||
dist_rpcalc_DATA = %D%/Makefile
|
||||
46
examples/c/rpcalc/rpcalc.test
Executable file
46
examples/c/rpcalc/rpcalc.test
Executable file
@@ -0,0 +1,46 @@
|
||||
#! /bin/sh
|
||||
|
||||
# Copyright (C) 2005-2015, 2018 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cat >input <<EOF
|
||||
1 2 3 * +
|
||||
EOF
|
||||
run 0 7
|
||||
|
||||
cat >input <<EOF
|
||||
1.1 2.2 3.3 * +
|
||||
EOF
|
||||
run 0 8.36
|
||||
|
||||
cat >input <<EOF
|
||||
1 2 + 3 *
|
||||
EOF
|
||||
run 0 9
|
||||
|
||||
cat >input <<EOF
|
||||
1 2 3 4 5 6 7 8 9 * * * * * * * *
|
||||
EOF
|
||||
run 0 362880
|
||||
|
||||
cat >input <<EOF
|
||||
3 7 + 3 4 5 * + - n
|
||||
EOF
|
||||
run 0 13
|
||||
|
||||
cat >input <<EOF
|
||||
3 4 ^
|
||||
EOF
|
||||
run 0 81
|
||||
Reference in New Issue
Block a user