Add more package and import support. (#3402)

This should cover:

```
library "lib" api;
import Foo library default;
import library default;
import library "lib";
```

This splits out `PackageName` and `LibraryName` to their own parse nodes
so that checking can ignore them and still get a balanced parse tree
(otherwise, we essentially need to implement handling of the parse nodes
only to remove the identifiers/string literals -- the optional names
mean we can't blindly do that as before). For reference, these nodes
don't need to be handled because CheckParseTree will need to directly
funnel import information along with checked IRs.
This commit is contained in:
Jon Ross-Perkins authored and GitHub committed 2023-11-16 17:09:36 +00:00
1 parent 49d46bd8a4
commit 204c04dbb9
42 files changed
+762 -298

No files matched your search

+5 -1
View File
@@ -30,11 +30,15 @@ auto HandleDeclScopeLoop(Context& context) -> void {
context.PopAndDiscardState();
return;
}
// `import` and `package` manage their packaging state.
// `import`, `library`, and `package` manage their packaging state.
case Lex::TokenKind::Import: {
context.PushState(State::Import);
return;
}
case Lex::TokenKind::Library: {
context.PushState(State::Library);
return;
}
case Lex::TokenKind::Package: {
context.PushState(State::Package);
return;