mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user