mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-22 05:43:40 +00:00
ast, read_verilog: refactoring
This commit is contained in:
parent
5af4e05125
commit
242853f1f2
7 changed files with 16 additions and 21 deletions
|
@ -1339,8 +1339,6 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
|
|||
// be instantiated for this type of AST node.
|
||||
IdString type_name;
|
||||
|
||||
current_filename = filename;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
// simply ignore this nodes.
|
||||
|
|
|
@ -1038,8 +1038,6 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
|||
return false;
|
||||
}
|
||||
|
||||
current_filename = filename;
|
||||
|
||||
// we do not look inside a task or function
|
||||
// (but as soon as a task or function is instantiated we process the generated AST as usual)
|
||||
if (type == AST_FUNCTION || type == AST_TASK) {
|
||||
|
@ -1840,8 +1838,6 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
|||
current_scope[it->first] = it->second;
|
||||
}
|
||||
|
||||
current_filename = filename;
|
||||
|
||||
if (type == AST_MODULE || type == AST_INTERFACE)
|
||||
current_scope.clear();
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@ GENFILES += frontends/verilog/verilog_parser.tab.cc
|
|||
GENFILES += frontends/verilog/verilog_parser.tab.hh
|
||||
GENFILES += frontends/verilog/verilog_parser.output
|
||||
GENFILES += frontends/verilog/verilog_lexer.cc
|
||||
GENFILES += frontends/verilog/location.hh
|
||||
GENFILES += frontends/verilog/position.hh
|
||||
GENFILES += frontends/verilog/stack.hh
|
||||
|
||||
frontends/verilog/verilog_parser.tab.cc: frontends/verilog/verilog_parser.y
|
||||
$(Q) mkdir -p $(dir $@)
|
||||
|
|
|
@ -787,15 +787,6 @@ void VERILOG_FRONTEND::verr_at(std::string filename, int begin_line, char const
|
|||
exit(1);
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
void VERILOG_FRONTEND::err_at_loc(parser::location_type loc, char const *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
verr_at(AST::current_filename, loc.begin.line, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
void VERILOG_FRONTEND::err_at_ast(AstSrcLocType loc, char const *fmt, ...)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include "kernel/yosys.h"
|
||||
#include "frontends/ast/ast.h"
|
||||
#include "frontends/verilog/location.hh"
|
||||
|
||||
#if ! defined(yyFlexLexerOnce)
|
||||
#define yyFlexLexer frontend_verilog_yyFlexLexer
|
||||
|
@ -66,10 +65,6 @@ namespace VERILOG_FRONTEND
|
|||
|
||||
};
|
||||
[[noreturn]]
|
||||
extern void verr_at(std::string filename, int begin_line, char const *fmt, va_list ap);
|
||||
[[noreturn]]
|
||||
extern void err_at_loc(frontend_verilog_yy::location loc, char const *fmt, ...);
|
||||
[[noreturn]]
|
||||
extern void err_at_ast(AST::AstSrcLocType loc, char const *fmt, ...);
|
||||
};
|
||||
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
YOSYS_NAMESPACE_BEGIN
|
||||
|
||||
namespace VERILOG_FRONTEND {
|
||||
// lexer input stream
|
||||
[[noreturn]]
|
||||
extern void verr_at(std::string filename, int begin_line, char const *fmt, va_list ap);
|
||||
using parser = frontend_verilog_yy::parser;
|
||||
class VerilogLexer : public frontend_verilog_yyFlexLexer {
|
||||
ParseState* extra;
|
||||
|
|
|
@ -244,6 +244,17 @@
|
|||
node->children.push_back(std::move(rangeNode));
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
extern void verr_at(std::string filename, int begin_line, char const *fmt, va_list ap);
|
||||
[[noreturn]]
|
||||
static void err_at_loc(frontend_verilog_yy::parser::location_type loc, char const *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
verr_at(AST::current_filename, loc.begin.line, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void checkLabelsMatch(const frontend_verilog_yy::parser::location_type& loc, const char *element, const std::string* before, const std::string *after)
|
||||
{
|
||||
if (!before && after)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue