mirror of https://github.com/YosysHQ/yosys.git
libparse: fix space before closing paren in expressions
This commit is contained in:
parent
547e254a9b
commit
4fac7a1b20
|
|
@ -191,7 +191,7 @@ LibertyExpression LibertyExpression::parse(Lexer &s, int min_prio) {
|
||||||
char c = s.peek();
|
char c = s.peek();
|
||||||
auto lhs = LibertyExpression{};
|
auto lhs = LibertyExpression{};
|
||||||
|
|
||||||
while (isspace(c)) {
|
while (isspace(c) || c == '"') {
|
||||||
if (s.empty())
|
if (s.empty())
|
||||||
return lhs;
|
return lhs;
|
||||||
s.next();
|
s.next();
|
||||||
|
|
@ -221,7 +221,6 @@ LibertyExpression LibertyExpression::parse(Lexer &s, int min_prio) {
|
||||||
warn(ss.str());
|
warn(ss.str());
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (s.empty())
|
if (s.empty())
|
||||||
break;
|
break;
|
||||||
|
|
@ -264,9 +263,10 @@ LibertyExpression LibertyExpression::parse(Lexer &s, int min_prio) {
|
||||||
s.next();
|
s.next();
|
||||||
c = s.peek();
|
c = s.peek();
|
||||||
}
|
}
|
||||||
if (char_is_nice_binop(c)) {
|
if (char_is_nice_binop(c) || c == ')') {
|
||||||
// We found a real binop, so this space wasn't an AND
|
// We found a real binop, so this space wasn't an AND
|
||||||
// and we just discard it as meaningless whitespace
|
// and we just discard it as meaningless whitespace
|
||||||
|
// Closing paren is also always terminating here
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace RTLIL {
|
||||||
void checkAll(std::initializer_list<std::string> expressions, std::string expected) {
|
void checkAll(std::initializer_list<std::string> expressions, std::string expected) {
|
||||||
for (const auto& e : expressions) {
|
for (const auto& e : expressions) {
|
||||||
auto helper = LibertyExpression::Lexer(e);
|
auto helper = LibertyExpression::Lexer(e);
|
||||||
auto tree_s = LibertyExpression::parse(helper).str();
|
auto tree_s = LibertyExpression::parse(helper).sexpr_str();
|
||||||
EXPECT_EQ(tree_s, expected);
|
EXPECT_EQ(tree_s, expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -82,6 +82,11 @@ namespace RTLIL {
|
||||||
}, "(and (pin \"x\")\n"
|
}, "(and (pin \"x\")\n"
|
||||||
" (not (pin \"y\")))"
|
" (not (pin \"y\")))"
|
||||||
);
|
);
|
||||||
|
checkAll({
|
||||||
|
"( D & EN )",
|
||||||
|
}, "(and (pin \"D\")\n"
|
||||||
|
" (pin \"EN\"))"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue