* tests/glr-regression.at (Duplicated user destructor for lookahead):

Mark it as expected to fail.
Cast result of malloc; problem reported by twlevo@xs4all.nl.
* tests/actions.at, tests/calc.at, tests/glr-regression.at:
Don't start user-code symbols with "yy", to avoid name space problems.
This commit is contained in:
Paul Eggert
2005-09-19 21:08:21 +00:00
parent c7e8607f6b
commit a9739e7c4c
4 changed files with 42 additions and 34 deletions

View File

@@ -1,3 +1,11 @@
2005-09-19 Paul Eggert <eggert@cs.ucla.edu>
* tests/glr-regression.at (Duplicated user destructor for lookahead):
Mark it as expected to fail.
Cast result of malloc; problem reported by twlevo@xs4all.nl.
* tests/actions.at, tests/calc.at, tests/glr-regression.at:
Don't start user-code symbols with "yy", to avoid name space problems.
2005-09-19 Akim Demaille <akim@epita.fr> 2005-09-19 Akim Demaille <akim@epita.fr>
Remove the traits, failed experiment. Remove the traits, failed experiment.

View File

@@ -286,7 +286,7 @@ thing:
; ;
%% %%
/* Alias to ARGV[1]. */ /* Alias to ARGV[1]. */
const char *yysource = 0; const char *source = 0;
static int static int
yylex (]AT_LEX_FORMALS[) yylex (]AT_LEX_FORMALS[)
@@ -303,12 +303,12 @@ yylex (]AT_LEX_FORMALS[)
AT_LOC.last_line = AT_LOC.last_column = AT_LOC.first_line + 9; AT_LOC.last_line = AT_LOC.last_column = AT_LOC.first_line + 9;
])[ ])[
if (yysource[c]) if (source[c])
printf ("sending: '%c'", yysource[c]); printf ("sending: '%c'", source[c]);
else else
printf ("sending: EOF"); printf ("sending: EOF");
printf (" (%d@%d-%d)\n", c, RANGE (]AT_LOC[)); printf (" (%d@%d-%d)\n", c, RANGE (]AT_LOC[));
return yysource[c]; return source[c];
} }
]AT_LALR1_CC_IF( ]AT_LALR1_CC_IF(
@@ -340,7 +340,7 @@ main (int argc, const char *argv[])
int status; int status;
yydebug = !!getenv ("YYDEBUG"); yydebug = !!getenv ("YYDEBUG");
assert (argc == 2); assert (argc == 2);
yysource = argv[1]; source = argv[1];
status = yyparse (); status = yyparse ();
switch (status) switch (status)
{ {

View File

@@ -77,8 +77,8 @@ static void yyerror (AT_YYERROR_ARG_LOC_IF([YYLTYPE *yylloc, ])
const char *s const char *s
);])[ );])[
static int yylex (]AT_LEX_FORMALS[); static int yylex (]AT_LEX_FORMALS[);
static int yygetc (]AT_LEX_FORMALS[); static int get_char (]AT_LEX_FORMALS[);
static void yyungetc (]AT_LEX_PRE_FORMALS[ int c); static void unget_char (]AT_LEX_PRE_FORMALS[ int c);
%} %}
/* Bison Declarations */ /* Bison Declarations */
@@ -125,7 +125,7 @@ exp:
; ;
%% %%
/* The input. */ /* The input. */
static FILE *yyin; static FILE *input;
]AT_LALR1_CC_IF( ]AT_LALR1_CC_IF(
[/* A C++ error reporting function. */ [/* A C++ error reporting function. */
@@ -168,9 +168,9 @@ AT_YYERROR_SEES_LOC_IF([
static YYLTYPE last_yylloc; static YYLTYPE last_yylloc;
])[ ])[
static int static int
yygetc (]AT_LEX_FORMALS[) get_char (]AT_LEX_FORMALS[)
{ {
int res = getc (yyin); int res = getc (input);
]AT_USE_LEX_ARGS[; ]AT_USE_LEX_ARGS[;
]AT_LOCATION_IF([ ]AT_LOCATION_IF([
last_yylloc = AT_LOC; last_yylloc = AT_LOC;
@@ -192,37 +192,37 @@ AT_LALR1_CC_IF(
static void static void
yyungetc (]AT_LEX_PRE_FORMALS[ int c) unget_char (]AT_LEX_PRE_FORMALS[ int c)
{ {
]AT_USE_LEX_ARGS[; ]AT_USE_LEX_ARGS[;
]AT_LOCATION_IF([ ]AT_LOCATION_IF([
/* Wrong when C == `\n'. */ /* Wrong when C == `\n'. */
AT_LOC = last_yylloc; AT_LOC = last_yylloc;
])[ ])[
ungetc (c, yyin); ungetc (c, input);
} }
static int static int
read_signed_integer (]AT_LEX_FORMALS[) read_signed_integer (]AT_LEX_FORMALS[)
{ {
int c = yygetc (]AT_LEX_ARGS[); int c = get_char (]AT_LEX_ARGS[);
int sign = 1; int sign = 1;
int n = 0; int n = 0;
]AT_USE_LEX_ARGS[; ]AT_USE_LEX_ARGS[;
if (c == '-') if (c == '-')
{ {
c = yygetc (]AT_LEX_ARGS[); c = get_char (]AT_LEX_ARGS[);
sign = -1; sign = -1;
} }
while (isdigit (c)) while (isdigit (c))
{ {
n = 10 * n + (c - '0'); n = 10 * n + (c - '0');
c = yygetc (]AT_LEX_ARGS[); c = get_char (]AT_LEX_ARGS[);
} }
yyungetc (]AT_LEX_PRE_ARGS[ c); unget_char (]AT_LEX_PRE_ARGS[ c);
return sign * n; return sign * n;
} }
@@ -258,7 +258,7 @@ yylex (]AT_LEX_FORMALS[)
])])[ ])])[
/* Skip white space. */ /* Skip white space. */
while ((c = yygetc (]AT_LEX_ARGS[)) == ' ' || c == '\t') while ((c = get_char (]AT_LEX_ARGS[)) == ' ' || c == '\t')
{ {
]AT_LOCATION_IF([AT_LALR1_CC_IF( ]AT_LOCATION_IF([AT_LALR1_CC_IF(
[ AT_LOC.begin = AT_LOC.end;], [ AT_LOC.begin = AT_LOC.end;],
@@ -270,7 +270,7 @@ yylex (]AT_LEX_FORMALS[)
/* process numbers */ /* process numbers */
if (c == '.' || isdigit (c)) if (c == '.' || isdigit (c))
{ {
yyungetc (]AT_LEX_PRE_ARGS[ c); unget_char (]AT_LEX_PRE_ARGS[ c);
]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[); ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[);
return NUM; return NUM;
} }
@@ -308,11 +308,11 @@ main (int argc, const char **argv)
alarm (100); alarm (100);
if (argc == 2) if (argc == 2)
yyin = fopen (argv[1], "r"); input = fopen (argv[1], "r");
else else
yyin = stdin; input = stdin;
if (!yyin) if (!input)
{ {
perror (argv[1]); perror (argv[1]);
return 3; return 3;

View File

@@ -121,8 +121,6 @@ AT_DATA_GRAMMAR([glr-regr2a.y],
%{ %{
#define YYSTYPE char const * #define YYSTYPE char const *
#define yyfalse 0
#define yytrue 1
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
@@ -168,14 +166,14 @@ var_printer: 'v'
%% %%
FILE *yyin = NULL; FILE *input = NULL;
int int
yylex (void) yylex (void)
{ {
char buf[50]; char buf[50];
char *s; char *s;
switch (fscanf (yyin, " %1[a-z,]", buf)) { switch (fscanf (input, " %1[a-z,]", buf)) {
case 1: case 1:
return buf[0]; return buf[0];
case EOF: case EOF:
@@ -183,7 +181,7 @@ yylex (void)
default: default:
break; break;
} }
if (fscanf (yyin, "%49s", buf) != 1) if (fscanf (input, "%49s", buf) != 1)
return 0; return 0;
if (sizeof buf - 1 <= strlen (buf)) if (sizeof buf - 1 <= strlen (buf))
abort (); abort ();
@@ -201,8 +199,8 @@ yyerror (char const *s)
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
yyin = stdin; input = stdin;
if (argc == 2 && !(yyin = fopen (argv[1], "r"))) return 3; if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
return yyparse (); return yyparse ();
} }
]]) ]])
@@ -290,7 +288,7 @@ static void yyerror(char const * s) {
fprintf(stderr,"error: %s\n",s); fprintf(stderr,"error: %s\n",s);
} }
FILE *yyin = NULL; FILE *input = NULL;
int P[] = { P1, P2 }; int P[] = { P1, P2 };
int O[] = { O1, O2 }; int O[] = { O1, O2 };
@@ -299,7 +297,7 @@ int T[] = { T1, T2, T3, T4 };
int yylex (void) int yylex (void)
{ {
char inp[3]; char inp[3];
if (fscanf (yyin, "%2s", inp) == EOF) if (fscanf (input, "%2s", inp) == EOF)
return 0; return 0;
switch (inp[0]) switch (inp[0])
{ {
@@ -311,8 +309,8 @@ int yylex (void)
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
yyin = stdin; input = stdin;
if (argc == 2 && !(yyin = fopen (argv[1], "r"))) return 3; if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3;
return yyparse (); return yyparse ();
} }
]]) ]])
@@ -603,7 +601,7 @@ stack2: 'a' ;
static int static int
yylex (void) yylex (void)
{ {
yylval.count = malloc (sizeof (int)); yylval.count = (int *) malloc (sizeof (int));
if (!yylval.count) if (!yylval.count)
{ {
fprintf (stderr, "Test inconclusive.\n"); fprintf (stderr, "Test inconclusive.\n");
@@ -631,8 +629,10 @@ AT_CHECK([[bison -o glr-regr7.c glr-regr7.y]], 0, [],
]) ])
AT_COMPILE([glr-regr7]) AT_COMPILE([glr-regr7])
AT_CHECK([[exit 77; ./glr-regr7]], 2, [], AT_CHECK([[./glr-regr7]], 2, [],
[memory exhausted [memory exhausted
]) ])
AT_XFAIL_IF(:)
AT_CLEANUP AT_CLEANUP