[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

examples: add a Makefile for C++ short examples

From: Akim Demaille
Subject: examples: add a Makefile for C++ short examples
Date: Fri, 26 Oct 2018 20:40:36 +0200

commit 719782e6ba4e48d0c62904f20f383422773017d8
Author: Akim Demaille <address@hidden>
Date:   Fri Oct 26 08:28:18 2018 +0200

   examples: add a Makefile for C++ short examples

   * examples/c++/Makefile: New.
   * examples/c++/, examples/c++/README: Adjust.

diff --git a/examples/c++/Makefile b/examples/c++/Makefile
new file mode 100644
index 00000000..47e1fb4e
--- /dev/null
+++ b/examples/c++/Makefile
@@ -0,0 +1,21 @@
+# This Makefile is designed to be simple and readable.  It does not
+# aim at portability.  It requires GNU Make.
+BISON = bison
+CXX = g++
+PROGS = simple variant variant-11
+simple: CXXFLAGS = -std=c++14
+variant-11: CXXFLAGS = -std=c++11
+all: $(PROGS)
+ %.hh: %.yy
+       $(BISON) $(BISONFLAGS) -o $*.cc $<
+       $(CXX) $(CXXFLAGS) -o$@ $<
+       rm -f $( $(PROGS)
diff --git a/examples/c++/README b/examples/c++/README
index e4154961..96cb7c9f 100644
--- a/examples/c++/README
+++ b/examples/c++/README
@@ -2,22 +2,30 @@ This directory contains examples of Bison grammar files in 

* Examples in C++

+You can run `make` to compile these examples.  And `make clean` to tidy
** simple.yy - Simple example in C++14
A very simple example in C++, based on variants and symbol constructors.
Variants allow to use any C++ type as semantic value type, and symbol
constructors ensure consistency between declared token type and effective
semantic value.

+Run as `./simple`.
Extracted from the documentation: "A Simple C++ Example".

** variant.yy - Self-contained example in C++98
A varition of simple.yy, in C++98.

+Run as `./variant`.
** variant-11.yy - Self-contained example in modern C++
Another variation of simple.yy, closely related to the previous one, but
exhibiting support for C++11's move semantics.

+Run as `./variant` or `./variant NUMBER`.


diff --git a/examples/c++/ b/examples/c++/
index b9c2f071..b5f8f8fe 100644
--- a/examples/c++/
+++ b/examples/c++/
@@ -61,5 +61,5 @@ if ENABLE_CXX11
  %D%/ $(BISON_IN) $(dist_pkgdata_DATA)

-dist_cxx_DATA = %D%/README %D%/variant.yy %D%/variant-11.yy
-CLEANFILES += %D%/variant.output %D%/variant-11.output
+dist_cxx_DATA = %D%/README %D%/Makefile %D%/variant.yy %D%/variant-11.yy
+CLEANFILES += %D%/simple.output %D%/variant.output %D%/variant-11.output

reply via email to

[Prev in Thread] Current Thread [Next in Thread]