mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 20:11:12 +01:00
Add parse support for 'import', brush up 'package' a little. (#3347)
This detects ordering issues with the `package` and `import` statements. `library` is changed from package-specific to instead be generic between the two, since structurally it's non-specific. The next step would be to start exposing the results for the driver to make ordering decisions for checking. That'll involve further modifications to this code, but this felt like a reasonable change point because it's the extent of the parser enforcement, and still causes significant refactoring. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
428d11323a
commit
c9458fe30a
@@ -31,12 +31,6 @@ auto Tree::Parse(Lex::TokenizedBuffer& tokens, DiagnosticConsumer& consumer,
|
||||
|
||||
context.PushState(State::DeclarationScopeLoop);
|
||||
|
||||
// The package should always be the first token, if it's present. Any other
|
||||
// use is invalid.
|
||||
if (context.PositionIs(Lex::TokenKind::Package)) {
|
||||
context.PushState(State::Package);
|
||||
}
|
||||
|
||||
while (!context.state_stack().empty()) {
|
||||
// clang warns on unhandled enum values; clang-tidy is incorrect here.
|
||||
// NOLINTNEXTLINE(bugprone-switch-missing-default-case)
|
||||
|
||||
Reference in New Issue
Block a user