mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-14 01:46:16 +00:00
Fix two parsing bugs that were causing private regression tests to fail.
These were introduced by 0a6d9f4
.
1) While in a paren "(", don't error on newline.
2) Don't parse an extra token when parsing vector ranges. Let the caller parse the next token as necessary.
This commit is contained in:
parent
23f59e0196
commit
4610889d27
2 changed files with 9 additions and 6 deletions
|
@ -360,7 +360,7 @@ void LibertyParser::report_unexpected_token(int tok)
|
||||||
|
|
||||||
// FIXME: the AST needs to be extended to store
|
// FIXME: the AST needs to be extended to store
|
||||||
// these vector ranges.
|
// these vector ranges.
|
||||||
int LibertyParser::parse_vector_range(int tok)
|
void LibertyParser::parse_vector_range(int tok)
|
||||||
{
|
{
|
||||||
// parse vector range [A] or [A:B]
|
// parse vector range [A] or [A:B]
|
||||||
std::string arg;
|
std::string arg;
|
||||||
|
@ -397,7 +397,6 @@ int LibertyParser::parse_vector_range(int tok)
|
||||||
{
|
{
|
||||||
error("Expected ']' on array range.");
|
error("Expected ']' on array range.");
|
||||||
}
|
}
|
||||||
return lexer(arg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LibertyAst *LibertyParser::parse()
|
LibertyAst *LibertyParser::parse()
|
||||||
|
@ -437,8 +436,10 @@ LibertyAst *LibertyParser::parse()
|
||||||
tok = lexer(ast->value);
|
tok = lexer(ast->value);
|
||||||
if (tok == 'v') {
|
if (tok == 'v') {
|
||||||
tok = lexer(str);
|
tok = lexer(str);
|
||||||
if (tok == '[')
|
if (tok == '[') {
|
||||||
tok = parse_vector_range(tok);
|
parse_vector_range(tok);
|
||||||
|
tok = lexer(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while (tok == '+' || tok == '-' || tok == '*' || tok == '/' || tok == '!') {
|
while (tok == '+' || tok == '-' || tok == '*' || tok == '/' || tok == '!') {
|
||||||
ast->value += tok;
|
ast->value += tok;
|
||||||
|
@ -471,9 +472,11 @@ LibertyAst *LibertyParser::parse()
|
||||||
|
|
||||||
if (tok == '[')
|
if (tok == '[')
|
||||||
{
|
{
|
||||||
tok = parse_vector_range(tok);
|
parse_vector_range(tok);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (tok == 'n')
|
||||||
|
continue;
|
||||||
if (tok != 'v') {
|
if (tok != 'v') {
|
||||||
report_unexpected_token(tok);
|
report_unexpected_token(tok);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace Yosys
|
||||||
int lexer(std::string &str);
|
int lexer(std::string &str);
|
||||||
|
|
||||||
void report_unexpected_token(int tok);
|
void report_unexpected_token(int tok);
|
||||||
int parse_vector_range(int tok);
|
void parse_vector_range(int tok);
|
||||||
LibertyAst *parse();
|
LibertyAst *parse();
|
||||||
void error() const;
|
void error() const;
|
||||||
void error(const std::string &str) const;
|
void error(const std::string &str) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue