1 /*
2 * Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com)
3 *
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 # include "config.h"
21
22 # include "parse_misc.h"
23 # include <cstdarg>
24 # include <cstdio>
25 # include <iostream>
26
27 extern const char*vl_file;
28 unsigned error_count = 0;
29 unsigned warn_count = 0;
30 unsigned long based_size = 0;
31
operator <<(std::ostream & o,const YYLTYPE & loc)32 std::ostream& operator << (std::ostream&o, const YYLTYPE&loc)
33 {
34 if (loc.text)
35 o << loc.text << ":";
36 else
37 o << "<>:";
38 o << loc.first_line;
39 return o;
40 }
41
VLwarn(const char * msg)42 void VLwarn(const char*msg)
43 {
44 warn_count += 1;
45 cerr << yylloc.text << ":" << yylloc.first_line << ": " << msg << endl;
46 }
47
VLerror(const char * msg)48 void VLerror(const char*msg)
49 {
50 error_count += 1;
51 cerr << yylloc.text << ":" << yylloc.first_line << ": " << msg << endl;
52 }
53
VLerror(const YYLTYPE & loc,const char * msg,...)54 void VLerror(const YYLTYPE&loc, const char*msg, ...)
55 {
56 va_list ap;
57 va_start(ap, msg);
58
59 fprintf(stderr, "%s:%d: ", loc.text, loc.first_line);
60 vfprintf(stderr, msg, ap);
61 va_end(ap);
62 fprintf(stderr, "\n");
63
64 error_count += 1;
65 based_size = 0; /* Clear the base information if we have an error. */
66 }
67
yywarn(const YYLTYPE & loc,const char * msg)68 void yywarn(const YYLTYPE&loc, const char*msg)
69 {
70 warn_count += 1;
71 cerr << loc << ": warning: " << msg << endl;
72 }
73
VLwrap()74 int VLwrap()
75 {
76 return -1;
77 }
78
79