[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/src/classdef parse.y scan.h scan.l
From: |
Reinhard Mueller |
Subject: |
gnue/geas/src/classdef parse.y scan.h scan.l |
Date: |
Sat, 22 Sep 2001 15:48:10 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Reinhard Mueller <address@hidden> 01/09/22 15:48:09
Modified files:
geas/src/classdef: parse.y scan.h scan.l
Log message:
Restructured error message handling so that error messages are only
printed in the second pass.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/classdef/parse.y.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/classdef/scan.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/geas/src/classdef/scan.l.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
Patches:
Index: gnue/geas/src/classdef/parse.y
diff -u gnue/geas/src/classdef/parse.y:1.10 gnue/geas/src/classdef/parse.y:1.11
--- gnue/geas/src/classdef/parse.y:1.10 Sat Sep 22 14:26:44 2001
+++ gnue/geas/src/classdef/parse.y Sat Sep 22 15:48:09 2001
@@ -19,7 +19,7 @@
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: parse.y,v 1.10 2001/09/22 18:26:44 reinhard Exp $
+ $Id: parse.y,v 1.11 2001/09/22 19:48:09 reinhard Exp $
*/
%{
@@ -57,6 +57,10 @@
void _geas_cd_parse (const char *file, int pass);
+/* error messages */
+
+static void yyerror (const char *message, ...);
+
/* functions that are called wile parsing */
static void _new_module (const gchar *name, geas_cd_access access);
@@ -359,6 +363,26 @@
{
yyparse ();
_geas_cd_scan_end ();
+ }
+}
+
+/* ------------------------------------------------------------------------- *\
+ * Error message output
+\* ------------------------------------------------------------------------- */
+static void
+yyerror (const char *message, ...)
+{
+ va_list va;
+ char *text;
+
+ /* error messages are only output in pass 2 */
+ if (_current_pass == 2)
+ {
+ va_start (va, message);
+ text = g_strdup_vprintf (message, va);
+ va_end (va);
+ _geas_cd_scan_error (text);
+ g_free (text);
}
}
Index: gnue/geas/src/classdef/scan.h
diff -u gnue/geas/src/classdef/scan.h:1.2 gnue/geas/src/classdef/scan.h:1.3
--- gnue/geas/src/classdef/scan.h:1.2 Sat Sep 15 05:28:50 2001
+++ gnue/geas/src/classdef/scan.h Sat Sep 22 15:48:09 2001
@@ -19,7 +19,7 @@
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: scan.h,v 1.2 2001/09/15 09:28:50 reinhard Exp $
+ $Id: scan.h,v 1.3 2001/09/22 19:48:09 reinhard Exp $
*/
#ifndef _SCAN_H
@@ -27,13 +27,8 @@
int _geas_cd_scan_begin (const char *filename);
void _geas_cd_scan_end (void);
+int _geas_cd_scan_error (const char *message);
int yylex (void);
-
-#ifdef __GNUC__
-int yyerror (const char *msg, ...) __attribute__ ((format (printf, 1, 2)));
-#else
-int yyerror (const char *msg, ...);
-#endif
#endif /* _SCAN_H */
Index: gnue/geas/src/classdef/scan.l
diff -u gnue/geas/src/classdef/scan.l:1.5 gnue/geas/src/classdef/scan.l:1.6
--- gnue/geas/src/classdef/scan.l:1.5 Sat Sep 22 14:13:13 2001
+++ gnue/geas/src/classdef/scan.l Sat Sep 22 15:48:09 2001
@@ -19,7 +19,7 @@
along with GEAS; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: scan.l,v 1.5 2001/09/22 18:13:13 reinhard Exp $
+ $Id: scan.l,v 1.6 2001/09/22 19:48:09 reinhard Exp $
*/
%option case-insensitive
@@ -154,12 +154,12 @@
\* ------------------------------------------------------------------------ */
/* FIXME: This must be handled in parse.y or error recovery doesn't work */
-_{WORD} { TTP; yyerror ("leading underscores are not allowed in "
- "identifiers"); }
-{WORD}__{ALPHANUM}+ { TTP; yyerror ("double underscores are not allowed in "
- "identifiers"); }
-{WORD}_ { TTP; yyerror ("trailing underscores are not allowed in "
- "identifiers"); }
+_{WORD} { TTP; _geas_cd_scan_error ("leading underscores are not "
+ "allowed in identifiers"); }
+{WORD}__{ALPHANUM}+ { TTP; _geas_cd_scan_error ("double underscores are not "
+ "allowed in identifiers"); }
+{WORD}_ { TTP; _geas_cd_scan_error ("trailing underscores are not "
+ "allowed in identifiers"); }
{WORD} { TTP; yylval.string = g_strdup (yytext); return (SYMBOL);
}
@@ -189,7 +189,7 @@
yyin = fopen (file, "r");
if (!yyin)
{
- yyerror ("Cannot open file");
+ perror (file);
return (0);
}
@@ -203,11 +203,9 @@
void
_geas_cd_scan_end (void)
{
- _token_line = 0; /* don't display line on error message */
-
if (fclose (yyin))
{
- yyerror ("Cannot close file");
+ perror (_token_file);
}
g_free (_token_file);
@@ -217,39 +215,26 @@
* Output error messages
\* ------------------------------------------------------------------------- */
int
-yyerror (const char *format, ...)
+_geas_cd_scan_error (const char *message)
{
int i;
- va_list va;
- if (_token_line)
- {
- fprintf (stderr, "%s:%d: ", _token_file, _token_line);
- }
- else
- {
- fprintf (stderr, "%s: ", _token_file);
- }
- va_start (va, format);
- vfprintf (stderr, format, va);
- va_end (va);
+ fprintf (stderr, "%s:%d: ", _token_file, _token_line);
+ fprintf (stderr, message);
fprintf (stderr, "\n");
- if (_token_line)
+ fprintf (stderr, "%s\n", _current_line);
+ for (i = 0; i < _token_pos; i++)
{
- fprintf (stderr, "%s\n", _current_line);
- for (i = 0; i < _token_pos; i++)
+ if (_current_line[i] == '\t')
+ {
+ fprintf (stderr, "\t");
+ }
+ else
{
- if (_current_line[i] == '\t')
- {
- fprintf (stderr, "\t");
- }
- else
- {
- fprintf (stderr, " ");
- }
+ fprintf (stderr, " ");
}
- fprintf (stderr, "^\n");
}
+ fprintf (stderr, "^\n");
return (0);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas/src/classdef parse.y scan.h scan.l,
Reinhard Mueller <=