summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-05-03 08:17:05 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-05-03 09:20:08 +0200
commitccaa8e29f92170a92ef2d38128d122aec59e6dbe (patch)
treeebc87c93f5ad32a5bd8d1ac8cdced36daf0a988b
parent76c3bccf405a2940bd891d95bcf92b182de6e5fa (diff)
downloadbison-ccaa8e29f92170a92ef2d38128d122aec59e6dbe.tar.gz
c++: provide backward compatibility on by_type
To write unit tests for their scanners, some users depended on symbol_type::token(): Lexer lex("12345"); symbol_type t = lex.nextToken(); assert(t.token() == token::INTLIT); assert(t.value.as<int>() == 12345); But symbol_type::token() was removed in Bison 3.5 because it relied on a conversion table. So users had to find other patterns, such as assert(t.type_get() == by_type(token::INTLIT).type_get()); which relies on several private implementation details. As part of transitioning from "token type" to "token kind", and making this a public and documented interface, "by_type" was renamed "by_kind" and "type_get()" was renamed as "kind()". The latter had backward compatibility mechanisms, not the former. In Bison 3.6 none of this should be used, but rather assert(t.kind() == symbol_kind::S_INTLIT); Reported by Pramod Kumbhar. https://lists.gnu.org/r/bug-bison/2020-05/msg00012.html * data/skeletons/c++.m4 (by_type): Make it an alias to by_kind.
-rw-r--r--THANKS1
-rw-r--r--data/skeletons/c++.m43
2 files changed, 4 insertions, 0 deletions
diff --git a/THANKS b/THANKS
index 157efc00..805c744f 100644
--- a/THANKS
+++ b/THANKS
@@ -155,6 +155,7 @@ Petr Machata pmachata@redhat.com
Pho pho@cielonegro.org
Piotr Gackiewicz gacek@intertel.com.pl
Piotr MarciƄczyk piomar123@gmail.com
+Pramod Kumbhar pramod.s.kumbhar@gmail.com
Quentin Hocquet hocquet@gostai.com
Quoc Peyrot chojin@lrde.epita.fr
R Blake blakers@mac.com
diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4
index 8bc70fdf..59c94ce0 100644
--- a/data/skeletons/c++.m4
+++ b/data/skeletons/c++.m4
@@ -414,6 +414,9 @@ m4_define([b4_symbol_type_define],
symbol_kind_type kind_;
};
+ /// Backward compatibility for a private implementation detail.
+ typedef by_kind by_type;
+
/// "External" symbols: returned by the scanner.
struct symbol_type : basic_symbol<by_kind>
{]b4_variant_if([[