From 23f59e0196fd6275f1f6267f59ed7f358704c9f5 Mon Sep 17 00:00:00 2001 From: Sean Luchen Date: Mon, 31 Mar 2025 10:47:39 -0700 Subject: [PATCH] Support array ranges for identifiers in the Liberty parser. This change only handles the case `id : id[range] ;`. --- passes/techmap/libparse.cc | 4 +++- passes/techmap/libparse.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/passes/techmap/libparse.cc b/passes/techmap/libparse.cc index 09afcf9f3..d85e9d915 100644 --- a/passes/techmap/libparse.cc +++ b/passes/techmap/libparse.cc @@ -436,7 +436,9 @@ LibertyAst *LibertyParser::parse() if (tok == ':' && ast->value.empty()) { tok = lexer(ast->value); if (tok == 'v') { - tok = lexer(str); + tok = lexer(str); + if (tok == '[') + tok = parse_vector_range(tok); } while (tok == '+' || tok == '-' || tok == '*' || tok == '/' || tok == '!') { ast->value += tok; diff --git a/passes/techmap/libparse.h b/passes/techmap/libparse.h index 686a2b49f..61ae4d334 100644 --- a/passes/techmap/libparse.h +++ b/passes/techmap/libparse.h @@ -105,8 +105,8 @@ namespace Yosys */ int lexer(std::string &str); - void report_unexpected_token(int tok); - int parse_vector_range(int tok); + void report_unexpected_token(int tok); + int parse_vector_range(int tok); LibertyAst *parse(); void error() const; void error(const std::string &str) const;