[Redbutton-devel] SF.net SVN: redbutton: [406] redbutton-author/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-09-21 12:55:22
|
Revision: 406
http://redbutton.svn.sourceforge.net/redbutton/?rev=406&view=rev
Author: skilvington
Date: 2007-09-21 05:55:18 -0700 (Fri, 21 Sep 2007)
Log Message:
-----------
don't generate an object if there were any parsing errors
Modified Paths:
--------------
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
redbutton-author/trunk/parser.l.footer
redbutton-author/trunk/parser.l.header
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/mhegc.c 2007-09-21 12:55:18 UTC (rev 406)
@@ -43,6 +43,7 @@
char *prog_name = argv[0];
int arg;
struct node asn1obj;
+ unsigned int nerrs;
while((arg = getopt(argc, argv, "v")) != EOF)
{
@@ -79,6 +80,10 @@
if(next_token())
parse_error("Unexpected text after InterchangedObject");
+ /* don't generate an object if there were any errors */
+ if((nerrs = nparse_errors()) > 0)
+ fatal("%u parsing error%s", nerrs, (nerrs == 1) ? "" : "s");
+
/* assert */
if(asn1obj.siblings != NULL)
fatal("Top level object has siblings");
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/parser.c.header 2007-09-21 12:55:18 UTC (rev 406)
@@ -10,12 +10,17 @@
* lexer functions we need to provide
*/
-int yylineno = 1;
+unsigned int yylineno = 1;
+unsigned int yynerrs = 0;
void
yyerror(const char *str)
{
fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
+
+ yynerrs ++;
+
+ return;
}
int
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/parser.h.header 2007-09-21 12:55:18 UTC (rev 406)
@@ -40,6 +40,7 @@
char *token_text(void);
void parse_error(const char *, ...);
+unsigned int nparse_errors(void);
void verbose(const char *, ...);
void vverbose(const char *, ...);
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/parser.l.footer 2007-09-21 12:55:18 UTC (rev 406)
@@ -87,3 +87,9 @@
return;
}
+unsigned int
+nparse_errors(void)
+{
+ return yynerrs;
+}
+
Modified: redbutton-author/trunk/parser.l.header
===================================================================
--- redbutton-author/trunk/parser.l.header 2007-09-20 16:10:41 UTC (rev 405)
+++ redbutton-author/trunk/parser.l.header 2007-09-21 12:55:18 UTC (rev 406)
@@ -5,7 +5,8 @@
#include <errno.h>
#include "parser.h"
#include "tokens.h"
-extern int yylineno;
+extern unsigned int yylineno;
+extern unsigned int yynerrs;
%}
%%
\/\/[^\n\r\f]* return COMMENT;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|