diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-30 00:36:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-30 00:36:36 +0000 |
commit | 71944203de65adf42c9fa9db7c4bd2b3c83ade1e (patch) | |
tree | 287237c4869b5e06f6888de89072b3e877cd5652 /clang/lib/Parse/Parser.cpp | |
parent | 607fb707506ac6ab0d4bfb8334b9f3f7dc40c90a (diff) | |
download | bcm5719-llvm-71944203de65adf42c9fa9db7c4bd2b3c83ade1e.tar.gz bcm5719-llvm-71944203de65adf42c9fa9db7c4bd2b3c83ade1e.zip |
Switch the module-loading interfaces and parser from a simple
top-level module name to a module path (e.g., std.vector). We're still
missing a number of pieces for this actually to do something.
llvm-svn: 145462
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 834e741e303..eb6dc443c9d 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1570,16 +1570,29 @@ Parser::DeclGroupPtrTy Parser::ParseModuleImport() { "Improper start to module import"); SourceLocation ImportLoc = ConsumeToken(); - // Parse the module name. - if (!Tok.is(tok::identifier)) { - Diag(Tok, diag::err_module_expected_ident); - SkipUntil(tok::semi); - return DeclGroupPtrTy(); - } + llvm::SmallVector<std::pair<IdentifierInfo *, SourceLocation>, 2> Path; + + // Parse the module path. + do { + if (!Tok.is(tok::identifier)) { + Diag(Tok, diag::err_module_expected_ident); + SkipUntil(tok::semi); + return DeclGroupPtrTy(); + } + + // Record this part of the module path. + Path.push_back(std::make_pair(Tok.getIdentifierInfo(), Tok.getLocation())); + ConsumeToken(); + + if (Tok.is(tok::period)) { + ConsumeToken(); + continue; + } + + break; + } while (true); - IdentifierInfo &ModuleName = *Tok.getIdentifierInfo(); - SourceLocation ModuleNameLoc = ConsumeToken(); - DeclResult Import = Actions.ActOnModuleImport(ImportLoc, ModuleName, ModuleNameLoc); + DeclResult Import = Actions.ActOnModuleImport(ImportLoc, Path); ExpectAndConsumeSemi(diag::err_module_expected_semi); if (Import.isInvalid()) return DeclGroupPtrTy(); |