3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-27 08:28:45 +00:00

neater errors, lost in the sauce of source

This commit is contained in:
Emil J. Tywoniak 2025-06-18 18:05:48 +02:00
parent 242853f1f2
commit 6ac9f79de6
13 changed files with 196 additions and 245 deletions

View file

@ -4,18 +4,20 @@
#include "kernel/yosys.h"
#include "frontends/ast/ast.h"
#include "frontends/verilog/verilog_parser.tab.hh"
#include <string>
YOSYS_NAMESPACE_BEGIN
namespace VERILOG_FRONTEND {
[[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;
ParseMode* mode;
public:
VerilogLexer(ParseState* e, ParseMode* m) : frontend_verilog_yyFlexLexer(e->lexin), extra(e), mode(m) {}
parser::location_type out_loc; // TODO private?
VerilogLexer(ParseState* e, ParseMode* m, std::string* filename) : frontend_verilog_yyFlexLexer(e->lexin), extra(e), mode(m) {
out_loc.begin.filename = filename;
}
~VerilogLexer() override {}
// autogenerated body due to YY_DECL
parser::symbol_type nextToken();
@ -24,19 +26,9 @@ namespace VERILOG_FRONTEND {
parser::symbol_type terminate() {
return parser::make_FRONTEND_VERILOG_YYEOF(out_loc);
}
parser::location_type out_loc;
[[noreturn]]
void err(char const *fmt, ...)
{
va_list args;
va_start(args, fmt);
verr_at(AST::current_filename, yylineno, fmt, args);
}
private:
std::vector<std::string> fn_stack;
std::vector<int> ln_stack;
parser::location_type real_loc;
parser::location_type old_loc;
int LexerInput(char* buf, int max_size) override {
return readsome(*extra->lexin, buf, max_size);
}