comparison GEMBASSY-1.0.3/gsoap/src/error2.c @ 0:8300eb051bea draft

Initial upload
author ktnyt
date Fri, 26 Jun 2015 05:19:29 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8300eb051bea
1 /*
2 error2.c
3
4 Error handling.
5
6 gSOAP XML Web services tools
7 Copyright (C) 2000-2008, Robert van Engelen, Genivia Inc. All Rights Reserved.
8 This part of the software is released under one of the following licenses:
9 GPL or Genivia's license for commercial use.
10 --------------------------------------------------------------------------------
11 GPL license.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT ANY
19 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
20 PARTICULAR PURPOSE. See the GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License along with
23 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
24 Place, Suite 330, Boston, MA 02111-1307 USA
25
26 Author contact information:
27 engelen@genivia.com / engelen@acm.org
28
29 This program is released under the GPL with the additional exemption that
30 compiling, linking, and/or using OpenSSL is allowed.
31 --------------------------------------------------------------------------------
32 A commercial use license is available from Genivia, Inc., contact@genivia.com
33 --------------------------------------------------------------------------------
34 */
35
36 #include "soapcpp2.h"
37
38 #ifdef HAVE_CONFIG_H
39 #include "soapcpp2_yacc.h"
40 #else
41 #include "soapcpp2_yacc.tab.h"
42 #endif
43
44 #define MAXERR 10
45
46 extern char yytext[]; /* lexeme found by the lexical analyzer */
47
48 static int lexerrno = 0;
49 static int synerrno = 0;
50 static int semerrno = 0;
51 static int semwarno = 0;
52
53 char errbuf[1024]; /* to hold error messages */
54
55 /*
56 yyerror - called by parser from an error production with nonterminal `error'
57 */
58 void yyerror(char *s)
59 { fprintf(stderr, "%s(%d): %s\n", filename, yylineno, s);
60 }
61
62 /*
63 lexerror - called by lexical analyzer upon failure to recognize a token
64 */
65 void lexerror(const char *s)
66 { fprintf(stderr, "%s(%d): %s: %s\n", filename, yylineno, s, yytext);
67 if (lexerrno++ >= MAXERR)
68 execerror("too many syntactic errors, bailing out");
69 }
70
71 /*
72 synerror - called by a semantic action in the yacc grammar
73 */
74 void synerror(const char *s)
75 { fprintf(stderr, "%s(%d): Syntax error: %s\n", filename, yylineno-1, s);
76 if (synerrno++ >= MAXERR)
77 execerror("too many syntactic errors, bailing out");
78 }
79
80 /*
81 semerror - report semantic error from static checking
82 */
83 void semerror(const char *s)
84 { fprintf(stderr, "\n%s(%d): **ERROR**: %s\n\n", filename, yylineno, s);
85 if (semerrno++ >= MAXERR)
86 execerror("too many semantic errors, bailing out");
87 }
88
89 /*
90 semwarn - report semantic warning from static checking
91 */
92 void semwarn(const char *s)
93 { fprintf(stderr, "\n%s(%d): *WARNING*: %s\n\n", filename, yylineno, s);
94 semwarno++;
95 }
96
97 /*
98 compliancewarn - report compliance warning
99 */
100 void compliancewarn(const char *s)
101 { fprintf(stderr, "Compliance warning: %s\n", s);
102 }
103
104 /*
105 typerror - report type error (a semantic error)
106 */
107 void typerror(const char *s)
108 { fprintf(stderr, "%s(%d): Type error: %s\n", filename, yylineno, s);
109 if (semerrno++ >= MAXERR)
110 execerror("too many semantic errors, bailing out");
111 }
112
113 /*
114 execerror - print error message and terminate execution
115 */
116 void execerror(const char *s)
117 { fprintf(stderr, "Critical error: %s\n", s);
118 exit(1);
119 }
120
121 /*
122 progerror - called when check(expr) failed, i.e. upon programming error
123 */
124 void progerror(const char *s, const char *f, int l)
125 { fprintf(stderr, "Program failure: %s in file %s line %d\n", s, f, l);
126 exit(1);
127 }
128
129 /*
130 errstat - show error statistics
131 */
132 int errstat(void)
133 { if (!lexerrno && !synerrno && !semerrno)
134 { fprintf(stderr, "\nCompilation successful ");
135 if (semwarno)
136 fprintf(stderr, "(%d warning%s)\n\n", semwarno, semwarno>1?"s":"");
137 else
138 fprintf(stderr, "\n\n");
139 return 0;
140 }
141 fprintf(stderr, "\nThere were errors:\n");
142 if (lexerrno)
143 fprintf(stderr, "%d lexical error%s\n", lexerrno, lexerrno>1?"s":"");
144 if (synerrno)
145 fprintf(stderr, "%d syntax error%s\n", synerrno, synerrno>1?"s":"");
146 if (semerrno)
147 fprintf(stderr, "%d semantic error%s\n", semerrno, semerrno>1?"s":"");
148 if (semwarno)
149 fprintf(stderr, "%d warning%s\n", semwarno, semwarno>1?"s":"");
150 fprintf(stderr, "\n");
151 return -1;
152 }