* src/reader.c (grammar_current_rule_check): Also check that $$

is used.
Take the rule to check as argument, hence rename as...
(grammar_rule_check): this.
* src/reader.h, src/reader.c (grammar_rule_begin, grammar_rule_end):
Rename as...
(grammar_rule_begin, grammar_rule_end): these, for consistency.
(grammar_midrule_action, grammar_symbol_append): Now static.
* tests/torture.at (input): Don't rely on the default action
being always performed.
* tests/calc.at: "Set" $$ even when the action is "cut" with
YYERROR or other.
* tests/actions.at (Exotic Dollars): Instead of using unused
values, check that the warning is issued.
This commit is contained in:
Akim Demaille
2005-12-27 17:50:00 +00:00
parent f8e1c9e55b
commit 8f3596a633
11 changed files with 217 additions and 193 deletions

View File

@@ -50,13 +50,12 @@ my $max = $ARGV[0] || 10;
print <<EOF;
]AT_DATA_GRAMMAR_PROLOGUE[
%error-verbose
%debug
%{
#include <stdio.h>
#include <stdlib.h>
#define YYERROR_VERBOSE 1
#define YYDEBUG 1
static int yylex (void);
static void yyerror (const char *msg);
%}
@@ -166,24 +165,25 @@ my $max = $ARGV[0] || 10;
print <<EOF;
]AT_DATA_GRAMMAR_PROLOGUE[
%error-verbose
%debug
%{
#include <stdio.h>
#include <stdlib.h>
#define YYERROR_VERBOSE 1
#define YYDEBUG 1
static int yylex (void);
static void yyerror (const char *msg);
%}
EOF
%token
EOF
for my $size (1 .. $max)
{
print "%token t$size $size \"$size\"\n";
print " t$size $size \"$size\"\n";
};
print <<EOF;
%%
EOF
@@ -258,7 +258,7 @@ AT_CLEANUP
# AT_DATA_LOOK_AHEAD_TOKENS_GRAMMAR(FILE-NAME, SIZE)
# -------------------------------------------
# --------------------------------------------------
# Create FILE-NAME, containing a self checking parser for a grammar
# requiring SIZE look-ahead tokens.
m4_define([AT_DATA_LOOK_AHEAD_TOKENS_GRAMMAR],
@@ -270,12 +270,12 @@ use Text::Wrap;
my $max = $ARGV[0] || 10;
print <<EOF;
%error-verbose
%debug
%{
#include <stdio.h>
#include <stdlib.h>
#define YYERROR_VERBOSE 1
#define YYDEBUG 1
# include <stdio.h>
# include <stdlib.h>
# include <assert.h>
static int yylex (void);
static void yyerror (const char *msg);
@@ -295,25 +295,26 @@ print
map { "n$_" } (1 .. $max)),
"\n";
print "%token\n";
for my $count (1 .. $max)
{
print "%token t$count $count \"$count\"\n";
print " t$count $count \"$count\"\n";
};
print <<EOF;
%%
input:
exp { if (\@S|@1 != 1) abort (); \$\$ = \@S|@1; }
| input exp { if (\@S|@2 != \@S|@1 + 1) abort (); \$\$ = \@S|@2; }
exp { assert (\@S|@1 == 1); \$\$ = \@S|@1; }
| input exp { assert (\@S|@2 == \@S|@1 + 1); \$\$ = \@S|@2; }
;
exp:
n1 "1" { if (\@S|@1 != 1) abort (); }
n1 "1" { assert (\@S|@1 == 1); \@S|@\@S|@ = \@S|@1; }
EOF
for my $count (2 .. $max)
{
print "| n$count \"$count\" { if (\@S|@1 != $count) abort (); }\n";
print "| n$count \"$count\" { assert (\@S|@1 == $count); \@S|@\@S|@ = \@S|@1; }\n";
};
print ";\n";