Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Aug 7, 2024
1 parent dad1705 commit 4220b3a
Show file tree
Hide file tree
Showing 11 changed files with 2,057 additions and 2,048 deletions.
3 changes: 1 addition & 2 deletions bindings/python/CompBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ void registerCompilation(py::module_& m) {
.def("addSearchExtension", &SourceLoader::addSearchExtension, "extension"_a)
.def("addLibraryMaps", &SourceLoader::addLibraryMaps, "pattern"_a, "basePath"_a,
"optionBag"_a)
.def("addSDFFiles", &SourceLoader::addSDFFiles, "pattern"_a, "basePath"_a,
"optionBag"_a)
.def("addSDFFiles", &SourceLoader::addSDFFiles, "pattern"_a, "basePath"_a, "optionBag"_a)
.def("addSeparateUnit", &SourceLoader::addSeparateUnit, "filePatterns"_a, "includePaths"_a,
"defines"_a, "libraryName"_a)
.def("loadSources", &SourceLoader::loadSources)
Expand Down
3,782 changes: 1,891 additions & 1,891 deletions docs/grammar.md

Large diffs are not rendered by default.

264 changes: 132 additions & 132 deletions docs/grammar_sdf.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/slang/driver/SourceLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class SLANG_EXPORT SourceLoader {
const Bag& optionBag, bool expandEnvVars,
flat_hash_set<std::filesystem::path>& seenMaps);
void addSDFFilesInternal(std::string_view pattern, const std::filesystem::path& basePath,
const Bag& optionBag);
const Bag& optionBag);
void createLibrary(const syntax::LibraryDeclarationSyntax& syntax,
const std::filesystem::path& basePath);
LoadResult loadAndParse(const FileEntry& fileEntry, const Bag& optionBag,
Expand Down
19 changes: 10 additions & 9 deletions include/slang/syntax/SyntaxTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ class SLANG_EXPORT SyntaxTree {
/// @a options is an optional bag of lexer, preprocessor, and parser options.
/// @return the created and parsed syntax tree.
static std::shared_ptr<SyntaxTree> fromSDFFile(std::string_view path,
SourceManager& sourceManager,
const Bag& options = {});
SourceManager& sourceManager,
const Bag& options = {});

/// Creates a syntax tree from a standard delay format (SDF) located in memory.
/// @a text is the actual source code text.
Expand All @@ -197,19 +197,20 @@ class SLANG_EXPORT SyntaxTree {
/// @a options is an optional bag of lexer, preprocessor, and parser options.
/// @return the created and parsed syntax tree.
static std::shared_ptr<SyntaxTree> fromSDFText(std::string_view text,
SourceManager& sourceManager,
std::string_view name = "source"sv,
std::string_view path = "",
const Bag& options = {});
SourceManager& sourceManager,
std::string_view name = "source"sv,
std::string_view path = "",
const Bag& options = {});

/// Creates a syntax tree from a standard delay format (SDF) already loaded into a source buffer.
/// Creates a syntax tree from a standard delay format (SDF) already loaded into a source
/// buffer.
/// @a buffer is the loaded source buffer.
/// @a sourceManager is the manager that owns the buffer.
/// @a options is an optional bag of lexer, preprocessor, and parser options.
/// @return the created and parsed syntax tree.
static std::shared_ptr<SyntaxTree> fromSDFBuffer(const SourceBuffer& buffer,
SourceManager& sourceManager,
const Bag& options = {});
SourceManager& sourceManager,
const Bag& options = {});

/// Gets any diagnostics generated while parsing.
Diagnostics& diagnostics() { return diagnosticsBuffer; }
Expand Down
12 changes: 10 additions & 2 deletions scripts/grammar_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@

ourdir = os.path.dirname(os.path.realpath(__file__))

infs = [open(os.path.join(ourdir, "grammar.txt")), open(os.path.join(ourdir, "grammar_sdf.txt"))]
outfs = [open(os.path.join(ourdir, "../docs/grammar.md"), "w"), open(os.path.join(ourdir, "../docs/grammar_sdf.md"), "w")]
infs = [
open(os.path.join(ourdir, "grammar.txt")),
open(os.path.join(ourdir, "grammar_sdf.txt")),
]
outfs = [
open(os.path.join(ourdir, "../docs/grammar.md"), "w"),
open(os.path.join(ourdir, "../docs/grammar_sdf.md"), "w"),
]

outfs[0].write("# SystemVerilog\n")
outfs[1].write("# Standard Delay Format (SDF)\n")


def entry(line):
match = re.match(r"(\w+) ::=", line)
if match:
Expand Down Expand Up @@ -48,6 +55,7 @@ def replacer(m):
if saved_match:
entry(saved_match)


for i, inf in enumerate(infs):
outf = outfs[i]
for line in inf:
Expand Down
4 changes: 2 additions & 2 deletions source/driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ void Driver::addStandardArgs() {
sourceLoader.addSDFFiles(value, {}, optionBag);
return "";
},
"One or more standard delay format files to parse",
"<file-pattern>[,...]", CommandLineFlags::CommaList);
"One or more standard delay format files to parse", "<file-pattern>[,...]",
CommandLineFlags::CommaList);

cmdLine.add(
"-y,--libdir",
Expand Down
4 changes: 2 additions & 2 deletions source/driver/SourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void SourceLoader::addLibraryMaps(std::string_view pattern, const fs::path& base
}

void SourceLoader::addSDFFiles(std::string_view pattern, const fs::path& basePath,
const Bag& optionBag) {
const Bag& optionBag) {
addSDFFilesInternal(pattern, basePath, optionBag);
}

Expand Down Expand Up @@ -158,7 +158,7 @@ void SourceLoader::addLibraryMapsInternal(std::string_view pattern, const fs::pa
}

void SourceLoader::addSDFFilesInternal(std::string_view pattern, const fs::path& basePath,
const Bag& optionBag) {
const Bag& optionBag) {
SmallVector<fs::path> files;
std::error_code ec;
svGlob(basePath, pattern, GlobMode::Files, files, /* expandEnvVars=*/false, ec);
Expand Down
6 changes: 4 additions & 2 deletions source/parsing/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,8 @@ Token Lexer::lexToken(KeywordVersion keywordVersion) {
// Parse SDF '0z'/'1z' lexemes
if (isSDFFile() and peek() == 'z' and (c == '0' or c == '1')) {
advance();
return (c == '0') ? create(TokenKind::SDFEdgeIdent0Z): create(TokenKind::SDFEdgeIdent1Z);
return (c == '0') ? create(TokenKind::SDFEdgeIdent0Z)
: create(TokenKind::SDFEdgeIdent1Z);
}

// back up so that lexNumericLiteral can look at this digit again
Expand Down Expand Up @@ -591,7 +592,8 @@ Token Lexer::lexToken(KeywordVersion keywordVersion) {
scanIdentifier();

// might be a keyword
auto table = (!isSDFFile()) ? LF::getKeywordTable(keywordVersion) : LF::getKeywordTable(KeywordVersion::v1497_2001);
auto table = (!isSDFFile()) ? LF::getKeywordTable(keywordVersion)
: LF::getKeywordTable(KeywordVersion::v1497_2001);

SLANG_ASSERT(table);
if (auto it = table->find(lexeme()); it != table->end())
Expand Down
2 changes: 1 addition & 1 deletion source/parsing/LexerFacts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ std::string_view LexerFacts::getTokenKindText(TokenKind kind) {
case TokenKind::SDFVoltageKeyword: return "VOLTAGE";
case TokenKind::SDFWaveformKeyword: return "WAVEFORM";
case TokenKind::SDFWidthKeyword: return "WIDTH";

// SDF special tokens
case TokenKind::SDFEdgeIdent0Z: return "0Z";
case TokenKind::SDFEdgeIdent1Z: return "1Z";
Expand Down
7 changes: 3 additions & 4 deletions tests/unittests/parsing/SDFParsingTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ TEST_CASE("SDF file correct (unformatted and with comments") {
)*/
)";

auto &unit = parseSDFUnit(text);
auto& unit = parseSDFUnit(text);
CHECK_DIAGNOSTICS_EMPTY;
REQUIRE(unit.kind == SyntaxKind::SDFUnit);
REQUIRE(unit.members.size() == 1);
Expand Down Expand Up @@ -1774,14 +1774,13 @@ TEST_CASE("correct SDF simple file") {
)
)";

auto &unit = parseSDFUnit(text);
auto& unit = parseSDFUnit(text);
CHECK_DIAGNOSTICS_EMPTY;
REQUIRE(unit.kind == SyntaxKind::SDFUnit);
REQUIRE(unit.members.size() == 1);
REQUIRE(unit.members[0]->kind == SyntaxKind::SDFDelayFile);
}


TEST_CASE("SDF file incorrect (invalid order of SDF file attributes/invalid number of SDFDelayFile "
"members/no specified cells)") {
auto& text = R"(
Expand Down Expand Up @@ -1833,7 +1832,7 @@ TEST_CASE("SDF file incorrect (invalid timing check values)") {
(IOPATH CLK Q (0.341:0.341:0.341) (0.379:0.379:0.379))
(IOPATH RESET_B.d Q () (0.000:0.000:0.000))
)
)
)
(TIMINGCHECK
(REMOVAL (posedge RESET_B) (posedge CLK) (0.348:0.348:0.348))
(RECOVERY (posedge RESET_B) (posedge CLK) (-0.255:-0.255:-0.255))
Expand Down

0 comments on commit 4220b3a

Please sign in to comment.