iverilog/parse_misc.cc

80 lines
2.0 KiB
C++
Raw Normal View History

1998-11-04 00:28:49 +01:00
/*
* Copyright (c) 1998-2022 Stephen Williams (steve@icarus.com)
1998-11-04 00:28:49 +01: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-29 03:41:23 +02:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1998-11-04 00:28:49 +01:00
*/
# include "config.h"
# include <cstdarg>
# include "parse_misc.h"
# include <cstdio>
2002-06-06 20:57:18 +02:00
# include <iostream>
1998-11-04 00:28:49 +01:00
using namespace std;
1998-11-04 00:28:49 +01:00
extern const char*vl_file;
unsigned error_count = 0;
unsigned warn_count = 0;
unsigned long based_size = 0;
1998-11-04 00:28:49 +01: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-04 00:28:49 +01:00
void VLerror(const char*msg)
{
error_count += 1;
cerr << yylloc.text << ":" << yylloc.first_line << ": " << msg << endl;
1998-11-04 00:28:49 +01:00
}
void VLerror(const YYLTYPE&loc, const char*msg, ...)
1998-11-04 00:28:49 +01:00
{
va_list ap;
va_start(ap, msg);
fprintf(stderr, "%s:%d: ", loc.text, loc.first_line);
vfprintf(stderr, msg, ap);
2014-09-06 00:39:26 +02:00
va_end(ap);
fprintf(stderr, "\n");
error_count += 1;
based_size = 0; /* Clear the base information if we have an error. */
1998-11-04 00:28:49 +01:00
}
void VLwarn(const YYLTYPE&loc, const char*msg)
1998-11-04 00:28:49 +01:00
{
warn_count += 1;
cerr << loc << ": " << msg << endl;
1998-11-04 00:28:49 +01:00
}
int VLwrap()
{
return -1;
}