* src/parse-gram.y (rules_or_grammar_declaration): Add an error

recovery rule, and forbid extensions when --yacc.
(gram_error): Use complain_at.
* src/reader.c (reader): Exit if there were parse errors.
This commit is contained in:
Akim Demaille
2002-07-09 14:48:01 +00:00
parent c5f5043618
commit b275314e2d
5 changed files with 209 additions and 174 deletions

View File

@@ -30,6 +30,7 @@
%{
#include "system.h"
#include "complain.h"
#include "muscle_tab.h"
#include "files.h"
#include "getargs.h"
@@ -338,6 +339,14 @@ grammar:
rules_or_grammar_declaration:
rules
| grammar_declaration ";"
{
if (yacc_flag)
complain_at (@$, _("POSIX forbids declarations in the grammar"));
}
| error ";"
{
yyerrok;
}
;
rules:
@@ -453,6 +462,5 @@ void
gram_error (gram_control_t *control ATTRIBUTE_UNUSED,
location_t *yylloc, const char *msg)
{
LOCATION_PRINT (stderr, *yylloc);
fprintf (stderr, ": %s\n", msg);
complain_at (*yylloc, "%s", msg);
}