mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Add support for inline Cpp declarations. (#6994)
For #6830, add support for inline C++ fragments as a declaration rather than as a packaging directive. For now, this uses `inline Cpp <string-literal>;` as syntax. The prior `import Cpp inline <string-literal>;` is left alone for the time being. We can decide separately whether to remove that. `inline Cpp` requires that there was at least one `import Cpp`. It's not clear to me if that's the right design long-term, but it seems reasonable for now. Assisted-by: Gemini via Google Antigravity
This commit is contained in:
@@ -147,6 +147,9 @@ static constexpr auto DeclIntroducers = [] {
|
||||
set_contextual(Lex::TokenKind::Var, ClassContext, NodeKind::FieldIntroducer,
|
||||
StateKind::FieldDecl);
|
||||
|
||||
set(Lex::TokenKind::Inline, NodeKind::InlineIntroducer,
|
||||
StateKind::InlineDeclAfterIntroducer);
|
||||
|
||||
set_packaging(Lex::TokenKind::Package, NodeKind::PackageIntroducer,
|
||||
StateKind::Package);
|
||||
set_packaging(Lex::TokenKind::Library, NodeKind::LibraryIntroducer,
|
||||
@@ -226,6 +229,7 @@ static auto ResolveAmbiguousTokenAsDeclaration(Context& context,
|
||||
case Lex::TokenKind::Extern:
|
||||
case Lex::TokenKind::Fn:
|
||||
case Lex::TokenKind::Import:
|
||||
case Lex::TokenKind::Inline:
|
||||
case Lex::TokenKind::Interface:
|
||||
case Lex::TokenKind::Let:
|
||||
case Lex::TokenKind::Library:
|
||||
|
||||
Reference in New Issue
Block a user