Skip to content

Commit 5cea801

Browse files
authored
Merge pull request #1075 from YosysHQ/gatecat/ecp5-lpf-errors
ecp5: Improve error handling for missing end-"
2 parents 3338227 + d210a5a commit 5cea801

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ecp5/lpf.cc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,22 @@ bool Arch::apply_lpf(std::string filename, std::istream &in)
4444
auto isempty = [](const std::string &str) {
4545
return std::all_of(str.begin(), str.end(), [](char c) { return isblank(c) || c == '\r' || c == '\n'; });
4646
};
47-
auto strip_quotes = [](const std::string &str) {
48-
if (str.at(0) == '"') {
49-
NPNR_ASSERT(str.back() == '"');
50-
return str.substr(1, str.size() - 2);
51-
} else {
52-
return str;
53-
}
54-
};
55-
5647
try {
5748
if (!in)
5849
log_error("failed to open LPF file\n");
5950
std::string line;
6051
std::string linebuf;
6152
int lineno = 0;
53+
auto strip_quotes = [&](const std::string &str) {
54+
if (str.at(0) == '"') {
55+
if (str.back() != '"') {
56+
log_error("expected '\"' at end of string '%s' (on line %d)\n", str.c_str(), lineno);
57+
}
58+
return str.substr(1, str.size() - 2);
59+
} else {
60+
return str;
61+
}
62+
};
6263
while (std::getline(in, line)) {
6364
++lineno;
6465
size_t cstart = line.find('#');

0 commit comments

Comments
 (0)