glr2.cc: make the example more C++

Currently the example really looks like C.  Instead of a union of
structs to implement the AST, use a hierarchy.  It would be nice to
feature a C++17 version with std variants.

* examples/c++/glr/c++-types.yy (Node, free_node, new_nterm)
(new_term): Move into...
* examples/c++/glr/ast.hh: here, a proper C++ hierarchy.
This commit is contained in:
Akim Demaille
2020-12-13 08:22:23 +01:00
parent 855d46678a
commit b2d35f5cb8
3 changed files with 125 additions and 122 deletions

View File

@@ -37,6 +37,7 @@ $(%C%_c___types_OBJECTS): $(cxx_types_sources_generated)
if ENABLE_CXX
check_PROGRAMS += %D%/c++-types
nodist_%C%_c___types_SOURCES = \
%D%/ast.hh \
%D%/c++-types.cc \
%D%/c++-types.hh
# Don't use gnulib's system headers.