Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search for interface files when using -y #752

Merged
merged 9 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ cmake-build-*/
prefix/
CMakeLists.txt.user
CMakeUserPresets.json
.ccls
3 changes: 3 additions & 0 deletions include/slang/parsing/ParserMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ struct SLANG_EXPORT ParserMetadata {
/// A list of all class declarations parsed.
std::vector<const syntax::ClassDeclarationSyntax*> classDecls;

/// A list of all interface port headers parsed.
std::vector<const syntax::InterfacePortHeaderSyntax*> interfacePorts;
AndrewNolte marked this conversation as resolved.
Show resolved Hide resolved

/// The EOF token, if one has already been consumed by the parser.
/// Otherwise an empty token.
Token eofToken;
Expand Down
6 changes: 6 additions & 0 deletions source/driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,12 @@ bool Driver::parseAllSources() {
missing.emplace(name);
}
}

for (auto intf : meta.interfacePorts) {
std::string_view name = intf->nameOrKeyword.valueText();
if (knownNames.find(name) == knownNames.end() && name != "interface")
missing.emplace(name);
}
};

for (auto& tree : syntaxTrees)
Expand Down
18 changes: 17 additions & 1 deletion source/parsing/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,23 @@ AnsiPortListSyntax& Parser::parseAnsiPortList(Token openParen) {
TokenKind::Comma, closeParen,
RequireItems::False, diag::ExpectedAnsiPort,
[this] { return &parseAnsiPort(); });
return factory.ansiPortList(openParen, buffer.copy(alloc), closeParen);
AnsiPortListSyntax* portList = &factory.ansiPortList(openParen, buffer.copy(alloc), closeParen);

// put interface ports in metadata

for (auto port : portList->ports) {
if (port->kind != SyntaxKind::ImplicitAnsiPort)
continue;
ImplicitAnsiPortSyntax* ansiport = &port->as<ImplicitAnsiPortSyntax>();

if (ansiport->header->kind != SyntaxKind::InterfacePortHeader)
continue;
InterfacePortHeaderSyntax* goodheader = &ansiport->header->as<InterfacePortHeaderSyntax>();

meta.interfacePorts.push_back(goodheader);
}

return *portList;
}
AndrewNolte marked this conversation as resolved.
Show resolved Hide resolved

ModuleHeaderSyntax& Parser::parseModuleHeader() {
Expand Down
5 changes: 5 additions & 0 deletions source/parsing/ParserMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class MetadataVisitor : public SyntaxVisitor<MetadataVisitor> {
visitDefault(syntax);
}

void handle(const InterfacePortHeaderSyntax& syntax) {
meta.interfacePorts.push_back(&syntax);
visitDefault(syntax);
}

void handle(const DefParamSyntax& syntax) {
meta.hasDefparams = true;
visitDefault(syntax);
Expand Down