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
+2
View File
@@ -4,6 +4,7 @@
#include <optional>
#include "toolchain/lex/token_kind.h"
#include "toolchain/parse/context.h"
#include "toolchain/parse/handle.h"
@@ -64,6 +65,7 @@ auto HandleStatement(Context& context) -> void {
case Lex::TokenKind::Let:
case Lex::TokenKind::Library:
case Lex::TokenKind::Namespace:
case Lex::TokenKind::Observe:
// We intentionally don't handle Package here, because `package.` can be
// used at the start of an expression, and it's not worth disambiguating it.
case Lex::TokenKind::Var: {