mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 15:51:04 +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:
@@ -30,7 +30,7 @@ auto HandleFunctionIntroducer(Context& context,
|
||||
// Push the bracketing node.
|
||||
context.node_stack().Push(node_id);
|
||||
// Optional modifiers and the name follow.
|
||||
context.decl_introducer_state_stack().Push(DeclIntroducerState::Fn);
|
||||
context.decl_introducer_state_stack().Push<Lex::TokenKind::Fn>();
|
||||
context.decl_name_stack().PushScopeAndStartName();
|
||||
return true;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ static auto BuildFunctionDecl(Context& context,
|
||||
auto [parent_scope_inst_id, parent_scope_inst] =
|
||||
context.name_scopes().GetInstIfValid(name_context.parent_scope_id);
|
||||
auto introducer =
|
||||
context.decl_introducer_state_stack().Pop(DeclIntroducerState::Fn);
|
||||
context.decl_introducer_state_stack().Pop<Lex::TokenKind::Fn>();
|
||||
DiagnoseModifiers(context, introducer, is_definition, parent_scope_inst_id,
|
||||
parent_scope_inst);
|
||||
if (introducer.modifier_set.HasAnyOf(KeywordModifierSet::Access)) {
|
||||
|
||||
Reference in New Issue
Block a user