Implement parsing observe declarations (#6674)

This implements parsing of the
[`observe`](https://docs.carbon-lang.dev/docs/design/generics/details.html#observing-a-type-implements-an-interface)
declarations.

- Added states and node kinds.
- Added node categories.
- Added a diagnostic for invalid keywords/operators.
- Implemented parser state handlers.
- Added structs to `typed_nodes.h`.
- Added parser tests.
This commit is contained in:
Özgür
2026-02-26 19:21:19 +00:00
committed by GitHub
parent 34651f429f
commit d11ee4b2b1
16 changed files with 407 additions and 16 deletions
@@ -8,6 +8,7 @@
#include "toolchain/parse/context.h"
#include "toolchain/parse/handle.h"
#include "toolchain/parse/node_kind.h"
#include "toolchain/parse/state.h"
namespace Carbon::Parse {
@@ -130,6 +131,8 @@ static constexpr auto DeclIntroducers = [] {
StateKind::TypeAfterIntroducerAsInterface);
set(Lex::TokenKind::Namespace, NodeKind::NamespaceStart,
StateKind::Namespace);
set(Lex::TokenKind::Observe, NodeKind::ObserveIntroducer,
StateKind::ObserveAfterIntroducer);
set(Lex::TokenKind::Require, NodeKind::RequireIntroducer,
StateKind::RequireAfterIntroducer);
set_contextual(Lex::TokenKind::Let, RegularContext, NodeKind::LetIntroducer,