Files
iverilog/parse_misc.cc
T

80 lines
2.0 KiB
C++
Raw Normal View History

1998-11-03 23:28:49 +00:00
/*
* Copyright (c) 1998-2022 Stephen Williams ([email protected])
1998-11-03 23:28:49 +00:00
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2012-08-28 18:41:23 -07:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1998-11-03 23:28:49 +00:00
*/
# include "config.h"
2012-02-19 10:29:50 -08:00
# include <cstdarg>
# include "parse_misc.h"
2012-02-19 10:29:50 -08:00
# include <cstdio>
2002-06-06 18:57:18 +00:00
# include <iostream>
1998-11-03 23:28:49 +00:00
using namespace std;
1998-11-03 23:28:49 +00:00
extern const char*vl_file;
1998-11-07 17:05:05 +00:00
unsigned error_count = 0;
unsigned warn_count = 0;
unsigned long based_size = 0;
1998-11-03 23:28:49 +00:00
std::ostream& operator << (std::ostream&o, const YYLTYPE&loc)
{
if (loc.text)
o << loc.text << ":";
else
o << "<>:";
o << loc.first_line;
return o;
}
2019-05-17 15:22:39 +02:00
void VLwarn(const char*msg)
{
2019-05-17 16:17:08 +02:00
warn_count += 1;
cerr << yylloc.text << ":" << yylloc.first_line << ": " << msg << endl;
2019-05-17 15:22:39 +02:00
}
1998-11-03 23:28:49 +00:00
void VLerror(const char*msg)
{
1998-11-07 17:05:05 +00:00
error_count += 1;
cerr << yylloc.text << ":" << yylloc.first_line << ": " << msg << endl;
1998-11-03 23:28:49 +00:00
}
2012-02-19 10:29:50 -08:00
void VLerror(const YYLTYPE&loc, const char*msg, ...)
1998-11-03 23:28:49 +00:00
{
2012-02-19 10:29:50 -08:00
va_list ap;
va_start(ap, msg);
fprintf(stderr, "%s:%d: ", loc.text, loc.first_line);
2012-02-19 10:29:50 -08:00
vfprintf(stderr, msg, ap);
2014-09-05 15:39:26 -07:00
va_end(ap);
2012-02-19 10:29:50 -08:00
fprintf(stderr, "\n");
1998-11-07 17:05:05 +00:00
error_count += 1;
based_size = 0; /* Clear the base information if we have an error. */
1998-11-03 23:28:49 +00:00
}
void VLwarn(const YYLTYPE&loc, const char*msg)
1998-11-03 23:28:49 +00:00
{
1998-11-07 17:05:05 +00:00
warn_count += 1;
cerr << loc << ": " << msg << endl;
1998-11-03 23:28:49 +00:00
}
int VLwrap()
{
return -1;
}