* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
* Copyright (c) 1987 by Ed James, UC Berkeley. All rights reserved.
* Copy permission is hereby granted provided that this notice is
* retained on all partial or complete copies.
* For more info on this and all of my stuff, mail edjames@berkeley.edu.
static char sccsid[] = "@(#)grammar.y 8.1 (Berkeley) %G%";
bunch_of_defs { if (checkdefs() < 0) return (errors); } bunch_of_lines
if (sp->num_exits + sp->num_airports < 2)
yyerror("Need at least 2 airports and/or exits.");
if (sp->update_secs != 0)
return (yyerror("Redefinition of 'update'."));
return (yyerror("'update' is too small."));
NewplaneOp '=' ConstOp ';'
if (sp->newplane_time != 0)
return (yyerror("Redefinition of 'newplane'."));
return (yyerror("'newplane' is too small."));
return (yyerror("Redefinition of 'height'."));
return (yyerror("'height' is too small."));
return (yyerror("Redefinition of 'width'."));
return (yyerror("'width' is too small."));
BeaconOp ':' Bpoint_list ';'
| ExitOp ':' Epoint_list ';'
| LineOp ':' Lline_list ';'
| AirportOp ':' Apoint_list ';'
if (sp->num_beacons % REALLOC == 0) {
sp->beacon = (BEACON *) malloc((sp->num_beacons
+ REALLOC) * sizeof (BEACON));
sp->beacon = (BEACON *) realloc(sp->beacon,
(sp->num_beacons + REALLOC) *
return (yyerror("No memory available."));
sp->beacon[sp->num_beacons].x = $2;
sp->beacon[sp->num_beacons].y = $3;
'(' ConstOp ConstOp DirOp ')'
if (sp->num_exits % REALLOC == 0) {
sp->exit = (EXIT *) malloc((sp->num_exits +
REALLOC) * sizeof (EXIT));
sp->exit = (EXIT *) realloc(sp->exit,
(sp->num_exits + REALLOC) *
return (yyerror("No memory available."));
sp->exit[sp->num_exits].x = $2;
sp->exit[sp->num_exits].y = $3;
sp->exit[sp->num_exits].dir = dir;
'(' ConstOp ConstOp DirOp ')'
if (sp->num_airports % REALLOC == 0) {
sp->airport=(AIRPORT *)malloc((sp->num_airports
+ REALLOC) * sizeof(AIRPORT));
sp->airport = (AIRPORT *) realloc(sp->airport,
(sp->num_airports + REALLOC) *
return (yyerror("No memory available."));
sp->airport[sp->num_airports].x = $2;
sp->airport[sp->num_airports].y = $3;
sp->airport[sp->num_airports].dir = dir;
'[' '(' ConstOp ConstOp ')' '(' ConstOp ConstOp ')' ']'
if (sp->num_lines % REALLOC == 0) {
sp->line = (LINE *) malloc((sp->num_lines +
REALLOC) * sizeof (LINE));
sp->line = (LINE *) realloc(sp->line,
(sp->num_lines + REALLOC) *
return (yyerror("No memory available."));
sp->line[sp->num_lines].p1.x = $3;
sp->line[sp->num_lines].p1.y = $4;
sp->line[sp->num_lines].p2.x = $7;
sp->line[sp->num_lines].p2.y = $8;
check_line($3, $4, $7, $8);
if (!(x == 0) && !(x == sp->width - 1) &&
!(y == 0) && !(y == sp->height - 1))
yyerror("edge value not on edge.");
if (x < 1 || x >= sp->width - 1)
yyerror("X value out of range.");
if (y < 1 || y >= sp->height - 1)
yyerror("Y value out of range.");
if (x < 0 || x >= sp->width)
yyerror("X value out of range.");
if (y < 0 || y >= sp->height)
yyerror("Y value out of range.");
check_line(x1, y1, x2, y2)
if (!(d1 == d2) && !(d1 == 0) && !(d2 == 0))
yyerror("Bad line endpoints.");
fprintf(stderr, "\"%s\": line %d: %s\n", file, line, s);
case 00: if (dir != 3) bad++; break;
case 01: if (dir < 1 || dir > 3) bad++; break;
case 02: if (dir != 1) bad++; break;
case 10: if (dir < 3 || dir > 5) bad++; break;
case 12: if (dir > 1 && dir < 7) bad++; break;
case 20: if (dir != 5) bad++; break;
case 21: if (dir < 5) bad++; break;
case 22: if (dir != 7) bad++; break;
yyerror("Unknown value in checkdir! Get help!");
yyerror("Bad direction for entrance at exit.");
yyerror("'width' undefined.");
yyerror("'height' undefined.");
if (sp->update_secs == 0) {
yyerror("'update' undefined.");
if (sp->newplane_time == 0) {
yyerror("'newplane' undefined.");