mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
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.
This commit is contained in:
1
THANKS
1
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
|
||||
|
||||
@@ -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([[
|
||||
|
||||
Reference in New Issue
Block a user