mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add a macro for introducer tokens. (#4031)
Playing with the macro suggestion on #4028, replace DeclKind with some templating that asserts the in-use token is an introducer token. This allows type-safe usage of Lex::TokenKind, reducing the benefit of a separate enum while improving stdout (since now this will ostream as the keyword name).
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Carbon::Check {
|
||||
|
||||
auto HandleAliasIntroducer(Context& context,
|
||||
Parse::AliasIntroducerId /*node_id*/) -> bool {
|
||||
context.decl_introducer_state_stack().Push(DeclIntroducerState::Alias);
|
||||
context.decl_introducer_state_stack().Push<Lex::TokenKind::Alias>();
|
||||
context.decl_name_stack().PushScopeAndStartName();
|
||||
return true;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ auto HandleAlias(Context& context, Parse::AliasId /*node_id*/) -> bool {
|
||||
PopNameComponentWithoutParams(context, Lex::TokenKind::Alias));
|
||||
|
||||
auto introducer =
|
||||
context.decl_introducer_state_stack().Pop(DeclIntroducerState::Alias);
|
||||
context.decl_introducer_state_stack().Pop<Lex::TokenKind::Alias>();
|
||||
LimitModifiersOnDecl(context, introducer, KeywordModifierSet::Access);
|
||||
if (introducer.modifier_set.HasAnyOf(KeywordModifierSet::Access)) {
|
||||
context.TODO(introducer.modifier_node_id(ModifierOrder::Access),
|
||||
|
||||
Reference in New Issue
Block a user